2014-11-21 10:51:34 +00:00
|
|
|
/*
|
|
|
|
* MARS Long Distance Replication Software
|
|
|
|
*
|
|
|
|
* This file is part of MARS project: http://schoebel.github.io/mars/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010-2014 Thomas Schoebel-Theuer
|
|
|
|
* Copyright (C) 2011-2014 1&1 Internet AG
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2011-02-23 20:48:06 +00:00
|
|
|
#ifndef MARS_COPY_H
|
|
|
|
#define MARS_COPY_H
|
|
|
|
|
|
|
|
#include <linux/wait.h>
|
|
|
|
|
2021-07-12 08:29:40 +00:00
|
|
|
#define INPUT_A 0
|
|
|
|
#define INPUT_B 1
|
|
|
|
#define COPY_INPUT_NR 2
|
2011-02-23 20:48:06 +00:00
|
|
|
|
2017-05-18 12:18:54 +00:00
|
|
|
extern int mars_copy_strict_write_order;
|
2017-04-04 05:59:02 +00:00
|
|
|
extern int mars_copy_timeout;
|
2013-07-18 12:42:07 +00:00
|
|
|
extern int mars_copy_read_prio;
|
|
|
|
extern int mars_copy_write_prio;
|
2013-07-22 07:15:53 +00:00
|
|
|
extern int mars_copy_read_max_fly;
|
|
|
|
extern int mars_copy_write_max_fly;
|
2013-01-09 10:30:33 +00:00
|
|
|
|
2017-04-11 06:27:24 +00:00
|
|
|
extern atomic_t global_copy_read_flight;
|
|
|
|
extern atomic_t global_copy_write_flight;
|
|
|
|
|
2022-02-21 13:07:06 +00:00
|
|
|
enum _copy_state {
|
2012-12-20 09:34:55 +00:00
|
|
|
COPY_STATE_RESET = -1,
|
|
|
|
COPY_STATE_START = 0, // don't change this, it _must_ be zero
|
|
|
|
COPY_STATE_START2,
|
2012-08-02 08:16:55 +00:00
|
|
|
COPY_STATE_READ1,
|
|
|
|
COPY_STATE_READ2,
|
|
|
|
COPY_STATE_READ3,
|
|
|
|
COPY_STATE_WRITE,
|
|
|
|
COPY_STATE_WRITTEN,
|
|
|
|
COPY_STATE_CLEANUP,
|
|
|
|
COPY_STATE_FINISHED,
|
2022-02-21 13:07:06 +00:00
|
|
|
} __packed;
|
2011-06-10 13:57:52 +00:00
|
|
|
|
|
|
|
struct copy_state {
|
|
|
|
struct mref_object *table[2];
|
2011-06-17 11:32:38 +00:00
|
|
|
bool active[2];
|
2022-02-21 13:07:06 +00:00
|
|
|
enum _copy_state state;
|
2012-08-20 14:12:31 +00:00
|
|
|
bool writeout;
|
2021-04-16 09:04:52 +00:00
|
|
|
unsigned short len;
|
2011-06-10 13:57:52 +00:00
|
|
|
short error;
|
2011-02-23 20:48:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct copy_mref_aspect {
|
|
|
|
GENERIC_ASPECT(mref);
|
2017-04-07 05:56:28 +00:00
|
|
|
struct copy_input *input;
|
2011-02-23 20:48:06 +00:00
|
|
|
struct copy_brick *brick;
|
2022-11-28 19:58:13 +00:00
|
|
|
#ifdef CONFIG_MARS_DEBUG
|
|
|
|
/* paranoia, only for testing */
|
2022-05-19 21:56:57 +00:00
|
|
|
loff_t orig_ref_pos;
|
2022-11-28 19:58:13 +00:00
|
|
|
int orig_ref_len;
|
|
|
|
#endif
|
2022-05-19 21:56:57 +00:00
|
|
|
unsigned saved_queue;
|
|
|
|
unsigned saved_index;
|
2011-02-23 20:48:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct copy_brick {
|
|
|
|
MARS_BRICK(copy);
|
|
|
|
// parameters
|
2012-09-25 15:41:07 +00:00
|
|
|
struct mars_limiter *copy_limiter;
|
2012-02-01 12:47:35 +00:00
|
|
|
loff_t copy_start;
|
|
|
|
loff_t copy_end; // stop working if == 0
|
2011-05-26 14:32:32 +00:00
|
|
|
int io_prio;
|
|
|
|
int append_mode; // 1 = passively, 2 = actively
|
2012-08-20 14:12:31 +00:00
|
|
|
bool verify_mode; // 0 = copy, 1 = checksum+compare
|
2012-08-02 08:16:55 +00:00
|
|
|
bool repair_mode; // whether to repair in case of verify errors
|
2012-08-20 14:12:31 +00:00
|
|
|
bool recheck_mode; // whether to re-check after repairs (costs performance)
|
2011-05-26 14:32:32 +00:00
|
|
|
bool utilize_mode; // utilize already copied data
|
2012-08-20 14:12:31 +00:00
|
|
|
bool abort_mode; // abort on IO error (default is retry forever)
|
2011-05-26 14:32:32 +00:00
|
|
|
// readonly from outside
|
2011-06-17 11:32:38 +00:00
|
|
|
loff_t copy_last; // current working position
|
2017-03-01 06:23:36 +00:00
|
|
|
loff_t copy_dirty; // end of current working area
|
2019-02-19 09:18:29 +00:00
|
|
|
struct lamport_time copy_last_stamp;
|
2022-12-02 21:17:33 +00:00
|
|
|
struct lamport_time copy_shutdown_started;
|
2011-11-04 16:23:52 +00:00
|
|
|
int copy_error;
|
2012-08-22 12:37:34 +00:00
|
|
|
int copy_error_count;
|
2012-08-02 08:16:55 +00:00
|
|
|
int verify_ok_count;
|
|
|
|
int verify_error_count;
|
2011-02-23 20:48:06 +00:00
|
|
|
bool low_dirty;
|
2012-01-22 17:18:39 +00:00
|
|
|
bool is_aborting;
|
2011-02-23 20:48:06 +00:00
|
|
|
// internal
|
2012-02-01 12:47:35 +00:00
|
|
|
bool trigger;
|
2019-01-31 19:31:38 +00:00
|
|
|
bool terminated;
|
2022-06-16 09:22:31 +00:00
|
|
|
loff_t stable_copy_start;
|
|
|
|
loff_t stable_copy_end;
|
2022-02-21 16:39:58 +00:00
|
|
|
bool clash;
|
2012-12-20 10:22:41 +00:00
|
|
|
atomic_t total_clash_count;
|
2011-02-23 20:48:06 +00:00
|
|
|
atomic_t io_flight;
|
2013-07-22 07:15:53 +00:00
|
|
|
atomic_t copy_read_flight;
|
|
|
|
atomic_t copy_write_flight;
|
2011-03-07 05:55:10 +00:00
|
|
|
long long last_jiffies;
|
2011-02-23 20:48:06 +00:00
|
|
|
wait_queue_head_t event;
|
|
|
|
struct task_struct *thread;
|
copy: constify state table subpages
I have seen some "strange" behaviour so infrequently, so I am unsure whether
this is a bugfix at all.
I am unsure, whether this _suspected_ bug would be in gcc, or whether
the bug would be mine.
If it is mine, then I assumed that gcc would produce better machine code
than required by ISO C.
Currently, I don't (yet) have the newest version of the ISO C standard,
so I cannot claim the truth.
Whatever: I found the _suspected_ bug by _dissassembling_ before vs after this
patch had been applied:
.type copy_brick_construct, @function .type copy_brick_construct, @function
copy_brick_construct: copy_brick_construct:
> pushq %r13 #
pushq %r12 # pushq %r12 #
pushq %rbp # | # block/mars/kernel/mars_copy.c: st = brick_block_alloc(0, PAGE_SIZE);
movl $1155, %edx #, <
> pushq %rbp #
pushq %rbx # pushq %rbx #
movl $4096, %esi #, <
movq %rdi, %rbx # brick, brick | movq %rdi, %r12 # brick, brick
> movl $4096, %esi #,
xorl %edi, %edi # xorl %edi, %edi #
call _brick_block_alloc # call _brick_block_alloc #
movq %rax, %rdx #, tmp99 | movq %rax, %rbx #, _res_
movl $1024, %ecx #, tmp102 movl $1024, %ecx #, tmp102
movq %rax, 408(%rbx) # tmp99, brick_11(D)->st <
movq %rdx, %rdi # tmp99, tmp99 <
xorl %eax, %eax # tmp101 xorl %eax, %eax # tmp101
xorl %ebp, %ebp # ivtmp.179 | movq %rbx, %rdi # _res_, _res_
xorl %r12d, %r12d # tmp106 <
rep stosl rep stosl
> xorl %ebp, %ebp # ivtmp.174
> xorl %r13d, %r13d # tmp105
.L26: .L26:
movl $1172, %edx #, | movl $1177, %edx #,
movl $4096, %esi #, movl $4096, %esi #,
xorl %edi, %edi # xorl %edi, %edi #
call _brick_block_alloc # call _brick_block_alloc #
movq %rax, %rdx #, tmp103 movq %rax, %rdx #, tmp103
movq 408(%rbx), %rax # brick_11(D)->st, brick_11(D)->st | movq %rdx, (%rbx,%rbp,8) # tmp103, MEM[base: _res__9, index: ivtmp.174_28, step:
> incq %rbp # ivtmp.174
movl $1024, %ecx #, tmp107 | movq %rax, %rdi # tmp103, _res_
movq %rdx, %rdi # tmp103, tmp103 | movl $1024, %ecx #, tmp106
movq %rdx, (%rax,%rbp) # tmp103, *_4 <
addq $8, %rbp #, ivtmp.179 <
movl %r12d, %eax # tmp106, tmp106 <
cmpq $2048, %rbp #, ivtmp.179 | cmpq $256, %rbp #, ivtmp.174
rep stosl rep stosl
jne .L26 #, jne .L26 #,
leaq 376(%rbx), %rdi #, tmp108 | leaq 376(%r12), %rdi #, tmp107
movq $__key.72209, %rdx #, | movq $__key.72227, %rdx #,
movq $.LC3, %rsi #, movq $.LC3, %rsi #,
call __init_waitqueue_head # call __init_waitqueue_head #
> # block/mars/kernel/mars_copy.c: brick->st = st;
> movq %rbx, 408(%r12) # _res_, brick_10(D)->st
xorl %eax, %eax # xorl %eax, %eax #
popq %rbx # popq %rbx #
popq %rbp # popq %rbp #
popq %r12 # popq %r12 #
> popq %r13 #
ret ret
Hint: the 2-dimenional array indexing looks _suspicious_ to me.
But analysis is not as easy as one might assume.
Please help me:
If this would be really a bug in gcc (I am not sure), it should be fixed
by the upstream of gcc. Please contact me if you know / can show that
(a) if it is _really_ a bug (currently very hard to reproduce via MARS), and
(b) the bug is really in gcc but not mine (unsure for now), and
(c) how to convert this into a _reproducer_ for the gcc team.
I am not sure whether this is a _full_ reproducer, because it might
depend on the arch (amd64) and/or on specific Linux kernel compile options.
I don't have the time for ananlysis of all of these, or maybe even more
thingies to do.
2022-02-23 07:30:20 +00:00
|
|
|
void *const *st;
|
2011-02-23 20:48:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct copy_input {
|
|
|
|
MARS_INPUT(copy);
|
2017-04-07 05:56:28 +00:00
|
|
|
loff_t check_hint;
|
2011-02-23 20:48:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct copy_output {
|
|
|
|
MARS_OUTPUT(copy);
|
|
|
|
};
|
|
|
|
|
|
|
|
MARS_TYPES(copy);
|
|
|
|
|
|
|
|
#endif
|