2023-02-15 16:32:41

by Christoph Böhmwalder

[permalink] [raw]
Subject: [PATCH 0/7] Assorted DRBD refactoring

Another set of "backported" DRBD refactoring patches to bring the
in-tree version closer to out-of-tree.

These are (hopefully) no-ops, pretty much just preparation for future
upstreaming work.

Andreas Gruenbacher (3):
drbd: Rip out the ERR_IF_CNT_IS_NEGATIVE macro
drbd: Add peer device parameter to whole-bitmap I/O handlers
drbd: INFO_bm_xfer_stats(): Pass a peer device argument

Christoph Böhmwalder (4):
drbd: drbd_uuid_compare: pass a peer_device
drbd: pass a peer_device to more bitmap functions
drbd: pass drbd_peer_device to __req_mod
drbd: Pass a peer device to the resync and online verify functions

drivers/block/drbd/drbd_actlog.c | 13 ++--
drivers/block/drbd/drbd_bitmap.c | 13 +++-
drivers/block/drbd/drbd_int.h | 119 +++++++++++++++--------------
drivers/block/drbd/drbd_main.c | 72 ++++++++++-------
drivers/block/drbd/drbd_nl.c | 19 +++--
drivers/block/drbd/drbd_receiver.c | 102 +++++++++++++------------
drivers/block/drbd/drbd_req.c | 30 +++++---
drivers/block/drbd/drbd_req.h | 11 ++-
drivers/block/drbd/drbd_state.c | 29 ++++---
drivers/block/drbd/drbd_worker.c | 114 ++++++++++++++-------------
10 files changed, 291 insertions(+), 231 deletions(-)


base-commit: a06377c5d01eeeaa52ad979b62c3c72efcc3eff0
--
2.39.1



2023-02-15 16:32:41

by Christoph Böhmwalder

[permalink] [raw]
Subject: [PATCH 2/7] drbd: Add peer device parameter to whole-bitmap I/O handlers

From: Andreas Gruenbacher <[email protected]>

Pass a peer device parameter through the bitmap I/O functions to the I/O
handlers. In after_state_ch(), set that parameter when queuing the
drbd_send_bitmap operation so that this operation knows where to send the
bitmap.

Signed-off-by: Andreas Gruenbacher <[email protected]>
Signed-off-by: Christoph Böhmwalder <[email protected]>
---
drivers/block/drbd/drbd_bitmap.c | 7 ++--
drivers/block/drbd/drbd_int.h | 23 ++++++++-----
drivers/block/drbd/drbd_main.c | 55 ++++++++++++++++++------------
drivers/block/drbd/drbd_nl.c | 14 ++++----
drivers/block/drbd/drbd_receiver.c | 6 ++--
drivers/block/drbd/drbd_state.c | 7 ++--
6 files changed, 67 insertions(+), 45 deletions(-)

diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
index 289876ffbc31..7d8e3b02a1da 100644
--- a/drivers/block/drbd/drbd_bitmap.c
+++ b/drivers/block/drbd/drbd_bitmap.c
@@ -1216,7 +1216,9 @@ static int bm_rw(struct drbd_device *device, const unsigned int flags, unsigned
* drbd_bm_read() - Read the whole bitmap from its on disk location.
* @device: DRBD device.
*/
-int drbd_bm_read(struct drbd_device *device) __must_hold(local)
+int drbd_bm_read(struct drbd_device *device,
+ struct drbd_peer_device *peer_device) __must_hold(local)
+
{
return bm_rw(device, BM_AIO_READ, 0);
}
@@ -1227,7 +1229,8 @@ int drbd_bm_read(struct drbd_device *device) __must_hold(local)
*
* Will only write pages that have changed since last IO.
*/
-int drbd_bm_write(struct drbd_device *device) __must_hold(local)
+int drbd_bm_write(struct drbd_device *device,
+ struct drbd_peer_device *peer_device) __must_hold(local)
{
return bm_rw(device, 0, 0);
}
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 772023ace749..63919781fe30 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -541,9 +541,10 @@ struct drbd_md_io {

struct bm_io_work {
struct drbd_work w;
+ struct drbd_peer_device *peer_device;
char *why;
enum bm_flag flags;
- int (*io_fn)(struct drbd_device *device);
+ int (*io_fn)(struct drbd_device *device, struct drbd_peer_device *peer_device);
void (*done)(struct drbd_device *device, int rv);
};

@@ -1041,7 +1042,7 @@ extern int drbd_send_drequest_csum(struct drbd_peer_device *, sector_t sector,
enum drbd_packet cmd);
extern int drbd_send_ov_request(struct drbd_peer_device *, sector_t sector, int size);

-extern int drbd_send_bitmap(struct drbd_device *device);
+extern int drbd_send_bitmap(struct drbd_device *device, struct drbd_peer_device *peer_device);
extern void drbd_send_sr_reply(struct drbd_peer_device *, enum drbd_state_rv retcode);
extern void conn_send_sr_reply(struct drbd_connection *connection, enum drbd_state_rv retcode);
extern int drbd_send_rs_deallocated(struct drbd_peer_device *, struct drbd_peer_request *);
@@ -1065,17 +1066,19 @@ extern void drbd_md_clear_flag(struct drbd_device *device, int flags)__must_hold
extern int drbd_md_test_flag(struct drbd_backing_dev *, int);
extern void drbd_md_mark_dirty(struct drbd_device *device);
extern void drbd_queue_bitmap_io(struct drbd_device *device,
- int (*io_fn)(struct drbd_device *),
+ int (*io_fn)(struct drbd_device *, struct drbd_peer_device *),
void (*done)(struct drbd_device *, int),
char *why, enum bm_flag flags);
extern int drbd_bitmap_io(struct drbd_device *device,
- int (*io_fn)(struct drbd_device *),
+ int (*io_fn)(struct drbd_device *, struct drbd_peer_device *),
char *why, enum bm_flag flags);
extern int drbd_bitmap_io_from_worker(struct drbd_device *device,
- int (*io_fn)(struct drbd_device *),
+ int (*io_fn)(struct drbd_device *, struct drbd_peer_device *),
char *why, enum bm_flag flags);
-extern int drbd_bmio_set_n_write(struct drbd_device *device) __must_hold(local);
-extern int drbd_bmio_clear_n_write(struct drbd_device *device) __must_hold(local);
+extern int drbd_bmio_set_n_write(struct drbd_device *device,
+ struct drbd_peer_device *peer_device) __must_hold(local);
+extern int drbd_bmio_clear_n_write(struct drbd_device *device,
+ struct drbd_peer_device *peer_device) __must_hold(local);

/* Meta data layout
*
@@ -1284,9 +1287,11 @@ extern void _drbd_bm_set_bits(struct drbd_device *device,
const unsigned long s, const unsigned long e);
extern int drbd_bm_test_bit(struct drbd_device *device, unsigned long bitnr);
extern int drbd_bm_e_weight(struct drbd_device *device, unsigned long enr);
-extern int drbd_bm_read(struct drbd_device *device) __must_hold(local);
+extern int drbd_bm_read(struct drbd_device *device,
+ struct drbd_peer_device *peer_device) __must_hold(local);
extern void drbd_bm_mark_for_writeout(struct drbd_device *device, int page_nr);
-extern int drbd_bm_write(struct drbd_device *device) __must_hold(local);
+extern int drbd_bm_write(struct drbd_device *device,
+ struct drbd_peer_device *peer_device) __must_hold(local);
extern void drbd_bm_reset_al_hints(struct drbd_device *device) __must_hold(local);
extern int drbd_bm_write_hinted(struct drbd_device *device) __must_hold(local);
extern int drbd_bm_write_lazy(struct drbd_device *device, unsigned upper_idx) __must_hold(local);
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 2c764f7ee4a7..5d98017497e4 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -1198,10 +1198,11 @@ static int fill_bitmap_rle_bits(struct drbd_device *device,
* code upon failure.
*/
static int
-send_bitmap_rle_or_plain(struct drbd_device *device, struct bm_xfer_ctx *c)
+send_bitmap_rle_or_plain(struct drbd_peer_device *device, struct bm_xfer_ctx *c)
{
- struct drbd_socket *sock = &first_peer_device(device)->connection->data;
- unsigned int header_size = drbd_header_size(first_peer_device(device)->connection);
+ struct drbd_device *device = peer_device->device;
+ struct drbd_socket *sock = &peer_device->connection->data;
+ unsigned int header_size = drbd_header_size(peer_device->connection);
struct p_compressed_bm *p = sock->sbuf + header_size;
int len, err;

@@ -1212,7 +1213,7 @@ send_bitmap_rle_or_plain(struct drbd_device *device, struct bm_xfer_ctx *c)

if (len) {
dcbp_set_code(p, RLE_VLI_Bits);
- err = __send_command(first_peer_device(device)->connection, device->vnr, sock,
+ err = __send_command(peer_device->connection, device->vnr, sock,
P_COMPRESSED_BITMAP, sizeof(*p) + len,
NULL, 0);
c->packets[0]++;
@@ -1233,7 +1234,8 @@ send_bitmap_rle_or_plain(struct drbd_device *device, struct bm_xfer_ctx *c)
len = num_words * sizeof(*p);
if (len)
drbd_bm_get_lel(device, c->word_offset, num_words, p);
- err = __send_command(first_peer_device(device)->connection, device->vnr, sock, P_BITMAP, len, NULL, 0);
+ err = __send_command(peer_device->connection, device->vnr, sock, P_BITMAP,
+ len, NULL, 0);
c->word_offset += num_words;
c->bit_offset = c->word_offset * BITS_PER_LONG;

@@ -1254,7 +1256,8 @@ send_bitmap_rle_or_plain(struct drbd_device *device, struct bm_xfer_ctx *c)
}

/* See the comment at receive_bitmap() */
-static int _drbd_send_bitmap(struct drbd_device *device)
+static int _drbd_send_bitmap(struct drbd_device *device,
+ struct drbd_peer_device *peer_device)
{
struct bm_xfer_ctx c;
int err;
@@ -1285,20 +1288,20 @@ static int _drbd_send_bitmap(struct drbd_device *device)
};

do {
- err = send_bitmap_rle_or_plain(device, &c);
+ err = send_bitmap_rle_or_plain(peer_device, &c);
} while (err > 0);

return err == 0;
}

-int drbd_send_bitmap(struct drbd_device *device)
+int drbd_send_bitmap(struct drbd_device *device, struct drbd_peer_device *peer_device)
{
- struct drbd_socket *sock = &first_peer_device(device)->connection->data;
+ struct drbd_socket *sock = &peer_device->connection->data;
int err = -1;

mutex_lock(&sock->mutex);
if (sock->socket)
- err = !_drbd_send_bitmap(device);
+ err = !_drbd_send_bitmap(device, peer_device);
mutex_unlock(&sock->mutex);
return err;
}
@@ -3406,7 +3409,9 @@ void drbd_uuid_set_bm(struct drbd_device *device, u64 val) __must_hold(local)
*
* Sets all bits in the bitmap and writes the whole bitmap to stable storage.
*/
-int drbd_bmio_set_n_write(struct drbd_device *device) __must_hold(local)
+int drbd_bmio_set_n_write(struct drbd_device *device,
+ struct drbd_peer_device *peer_device) __must_hold(local)
+
{
int rv = -EIO;

@@ -3414,7 +3419,7 @@ int drbd_bmio_set_n_write(struct drbd_device *device) __must_hold(local)
drbd_md_sync(device);
drbd_bm_set_all(device);

- rv = drbd_bm_write(device);
+ rv = drbd_bm_write(device, peer_device);

if (!rv) {
drbd_md_clear_flag(device, MDF_FULL_SYNC);
@@ -3430,11 +3435,13 @@ int drbd_bmio_set_n_write(struct drbd_device *device) __must_hold(local)
*
* Clears all bits in the bitmap and writes the whole bitmap to stable storage.
*/
-int drbd_bmio_clear_n_write(struct drbd_device *device) __must_hold(local)
+int drbd_bmio_clear_n_write(struct drbd_device *device,
+ struct drbd_peer_device *peer_device) __must_hold(local)
+
{
drbd_resume_al(device);
drbd_bm_clear_all(device);
- return drbd_bm_write(device);
+ return drbd_bm_write(device, peer_device);
}

static int w_bitmap_io(struct drbd_work *w, int unused)
@@ -3453,7 +3460,7 @@ static int w_bitmap_io(struct drbd_work *w, int unused)

if (get_ldev(device)) {
drbd_bm_lock(device, work->why, work->flags);
- rv = work->io_fn(device);
+ rv = work->io_fn(device, work->peer_device);
drbd_bm_unlock(device);
put_ldev(device);
}
@@ -3488,11 +3495,12 @@ static int w_bitmap_io(struct drbd_work *w, int unused)
* put_ldev().
*/
void drbd_queue_bitmap_io(struct drbd_device *device,
- int (*io_fn)(struct drbd_device *),
+ int (*io_fn)(struct drbd_device *, struct drbd_peer_device *),
void (*done)(struct drbd_device *, int),
- char *why, enum bm_flag flags)
+ char *why, enum bm_flag flags,
+ struct drbd_peer_device *peer_device)
{
- D_ASSERT(device, current == first_peer_device(device)->connection->worker.task);
+ D_ASSERT(device, current == peer_device->connection->worker.task);

D_ASSERT(device, !test_bit(BITMAP_IO_QUEUED, &device->flags));
D_ASSERT(device, !test_bit(BITMAP_IO, &device->flags));
@@ -3501,6 +3509,7 @@ void drbd_queue_bitmap_io(struct drbd_device *device,
drbd_err(device, "FIXME going to queue '%s' but '%s' still pending?\n",
why, device->bm_io_work.why);

+ device->bm_io_work.peer_device = peer_device;
device->bm_io_work.io_fn = io_fn;
device->bm_io_work.done = done;
device->bm_io_work.why = why;
@@ -3512,7 +3521,7 @@ void drbd_queue_bitmap_io(struct drbd_device *device,
* application IO does not conflict anyways. */
if (flags == BM_LOCKED_CHANGE_ALLOWED || atomic_read(&device->ap_bio_cnt) == 0) {
if (!test_and_set_bit(BITMAP_IO_QUEUED, &device->flags))
- drbd_queue_work(&first_peer_device(device)->connection->sender_work,
+ drbd_queue_work(&peer_device->connection->sender_work,
&device->bm_io_work.w);
}
spin_unlock_irq(&device->resource->req_lock);
@@ -3528,8 +3537,10 @@ void drbd_queue_bitmap_io(struct drbd_device *device,
* freezes application IO while that the actual IO operations runs. This
* functions MAY NOT be called from worker context.
*/
-int drbd_bitmap_io(struct drbd_device *device, int (*io_fn)(struct drbd_device *),
- char *why, enum bm_flag flags)
+int drbd_bitmap_io(struct drbd_device *device,
+ int (*io_fn)(struct drbd_device *, struct drbd_peer_device *),
+ char *why, enum bm_flag flags,
+ struct drbd_peer_device *peer_device)
{
/* Only suspend io, if some operation is supposed to be locked out */
const bool do_suspend_io = flags & (BM_DONT_CLEAR|BM_DONT_SET|BM_DONT_TEST);
@@ -3541,7 +3552,7 @@ int drbd_bitmap_io(struct drbd_device *device, int (*io_fn)(struct drbd_device *
drbd_suspend_io(device);

drbd_bm_lock(device, why, flags);
- rv = io_fn(device);
+ rv = io_fn(device, peer_device);
drbd_bm_unlock(device);

if (do_suspend_io)
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 60757ac31701..07a52c5a2989 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -1053,7 +1053,7 @@ drbd_determine_dev_size(struct drbd_device *device, enum dds_flags flags, struct
la_size_changed ? "size changed" : "md moved");
/* next line implicitly does drbd_suspend_io()+drbd_resume_io() */
drbd_bitmap_io(device, md_moved ? &drbd_bm_write_all : &drbd_bm_write,
- "size changed", BM_LOCKED_MASK);
+ "size changed", BM_LOCKED_MASK, NULL);

/* on-disk bitmap and activity log is authoritative again
* (unless there was an IO error meanwhile...) */
@@ -2027,13 +2027,15 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
drbd_info(device, "Assuming that all blocks are out of sync "
"(aka FullSync)\n");
if (drbd_bitmap_io(device, &drbd_bmio_set_n_write,
- "set_n_write from attaching", BM_LOCKED_MASK)) {
+ "set_n_write from attaching", BM_LOCKED_MASK,
+ NULL)) {
retcode = ERR_IO_MD_DISK;
goto force_diskless_dec;
}
} else {
if (drbd_bitmap_io(device, &drbd_bm_read,
- "read from attaching", BM_LOCKED_MASK)) {
+ "read from attaching", BM_LOCKED_MASK,
+ NULL)) {
retcode = ERR_IO_MD_DISK;
goto force_diskless_dec;
}
@@ -2972,7 +2974,7 @@ int drbd_adm_invalidate(struct sk_buff *skb, struct genl_info *info)
retcode = drbd_request_state(device, NS(disk, D_INCONSISTENT));
if (retcode >= SS_SUCCESS) {
if (drbd_bitmap_io(device, &drbd_bmio_set_n_write,
- "set_n_write from invalidate", BM_LOCKED_MASK))
+ "set_n_write from invalidate", BM_LOCKED_MASK, NULL))
retcode = ERR_IO_MD_DISK;
}
} else
@@ -3052,7 +3054,7 @@ int drbd_adm_invalidate_peer(struct sk_buff *skb, struct genl_info *info)
if (retcode >= SS_SUCCESS) {
if (drbd_bitmap_io(device, &drbd_bmio_set_susp_al,
"set_n_write from invalidate_peer",
- BM_LOCKED_SET_ALLOWED))
+ BM_LOCKED_SET_ALLOWED, NULL))
retcode = ERR_IO_MD_DISK;
}
} else
@@ -4148,7 +4150,7 @@ int drbd_adm_new_c_uuid(struct sk_buff *skb, struct genl_info *info)

if (args.clear_bm) {
err = drbd_bitmap_io(device, &drbd_bmio_clear_n_write,
- "clear_n_write from new_c_uuid", BM_LOCKED_MASK);
+ "clear_n_write from new_c_uuid", BM_LOCKED_MASK, NULL);
if (err) {
drbd_err(device, "Writing bitmap failed with %d\n", err);
retcode = ERR_IO_MD_DISK;
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 757f4692b5bd..424748f6e4fa 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -3591,7 +3591,7 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_peer_device *peer_device,
if (abs(hg) >= 2) {
drbd_info(device, "Writing the whole bitmap, full sync required after drbd_sync_handshake.\n");
if (drbd_bitmap_io(device, &drbd_bmio_set_n_write, "set_n_write from sync_handshake",
- BM_LOCKED_SET_ALLOWED))
+ BM_LOCKED_SET_ALLOWED, NULL))
return C_MASK;
}

@@ -4270,7 +4270,7 @@ static int receive_uuids(struct drbd_connection *connection, struct packet_info
drbd_info(device, "Accepted new current UUID, preparing to skip initial sync\n");
drbd_bitmap_io(device, &drbd_bmio_clear_n_write,
"clear_n_write from receive_uuids",
- BM_LOCKED_TEST_ALLOWED);
+ BM_LOCKED_TEST_ALLOWED, NULL);
_drbd_uuid_set(device, UI_CURRENT, p_uuid[UI_CURRENT]);
_drbd_uuid_set(device, UI_BITMAP, 0);
_drbd_set_state(_NS2(device, disk, D_UP_TO_DATE, pdsk, D_UP_TO_DATE),
@@ -5214,7 +5214,7 @@ static int drbd_disconnected(struct drbd_peer_device *peer_device)

if (get_ldev(device)) {
drbd_bitmap_io(device, &drbd_bm_write_copy_pages,
- "write from disconnected", BM_LOCKED_CHANGE_ALLOWED);
+ "write from disconnected", BM_LOCKED_CHANGE_ALLOWED, NULL);
put_ldev(device);
}

diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c
index 75d13ea0024f..0b335ddd6d12 100644
--- a/drivers/block/drbd/drbd_state.c
+++ b/drivers/block/drbd/drbd_state.c
@@ -1518,8 +1518,9 @@ static void abw_start_sync(struct drbd_device *device, int rv)
}

int drbd_bitmap_io_from_worker(struct drbd_device *device,
- int (*io_fn)(struct drbd_device *),
- char *why, enum bm_flag flags)
+ int (*io_fn)(struct drbd_device *, struct drbd_peer_device *),
+ char *why, enum bm_flag flags,
+ struct drbd_peer_device *peer_device)
{
int rv;

@@ -1529,7 +1530,7 @@ int drbd_bitmap_io_from_worker(struct drbd_device *device,
atomic_inc(&device->suspend_cnt);

drbd_bm_lock(device, why, flags);
- rv = io_fn(device);
+ rv = io_fn(device, peer_device);
drbd_bm_unlock(device);

drbd_resume_io(device);
--
2.39.1


2023-02-15 16:32:41

by Christoph Böhmwalder

[permalink] [raw]
Subject: [PATCH 5/7] drbd: pass a peer_device to more bitmap functions

Signed-off-by: Christoph Böhmwalder <[email protected]>
---
drivers/block/drbd/drbd_bitmap.c | 6 ++++--
drivers/block/drbd/drbd_int.h | 15 ++++++++++-----
drivers/block/drbd/drbd_main.c | 4 ++--
drivers/block/drbd/drbd_nl.c | 5 +++--
drivers/block/drbd/drbd_receiver.c | 2 +-
drivers/block/drbd/drbd_state.c | 12 +++++++-----
drivers/block/drbd/drbd_worker.c | 3 ++-
7 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
index 7d8e3b02a1da..6ac8c54b44c7 100644
--- a/drivers/block/drbd/drbd_bitmap.c
+++ b/drivers/block/drbd/drbd_bitmap.c
@@ -1241,7 +1241,8 @@ int drbd_bm_write(struct drbd_device *device,
*
* Will write all pages.
*/
-int drbd_bm_write_all(struct drbd_device *device) __must_hold(local)
+int drbd_bm_write_all(struct drbd_device *device,
+ struct drbd_peer_device *peer_device) __must_hold(local)
{
return bm_rw(device, BM_AIO_WRITE_ALL_PAGES, 0);
}
@@ -1267,7 +1268,8 @@ int drbd_bm_write_lazy(struct drbd_device *device, unsigned upper_idx) __must_ho
* verify is aborted due to a failed peer disk, while local IO continues, or
* pending resync acks are still being processed.
*/
-int drbd_bm_write_copy_pages(struct drbd_device *device) __must_hold(local)
+int drbd_bm_write_copy_pages(struct drbd_device *device,
+ struct drbd_peer_device *peer_device) __must_hold(local)
{
return bm_rw(device, BM_AIO_COPY_PAGES, 0);
}
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 8b4d06e10365..345e96ceb47c 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -66,6 +66,7 @@ extern int drbd_proc_details;

struct drbd_device;
struct drbd_connection;
+struct drbd_peer_device;

/* Defines to control fault insertion */
enum {
@@ -1068,13 +1069,15 @@ extern void drbd_md_mark_dirty(struct drbd_device *device);
extern void drbd_queue_bitmap_io(struct drbd_device *device,
int (*io_fn)(struct drbd_device *, struct drbd_peer_device *),
void (*done)(struct drbd_device *, int),
- char *why, enum bm_flag flags);
+ char *why, enum bm_flag flags,
+ struct drbd_peer_device *peer_device);
extern int drbd_bitmap_io(struct drbd_device *device,
int (*io_fn)(struct drbd_device *, struct drbd_peer_device *),
- char *why, enum bm_flag flags);
+ char *why, enum bm_flag flags, struct drbd_peer_device *);
extern int drbd_bitmap_io_from_worker(struct drbd_device *device,
int (*io_fn)(struct drbd_device *, struct drbd_peer_device *),
- char *why, enum bm_flag flags);
+ char *why, enum bm_flag flags,
+ struct drbd_peer_device *peer_device);
extern int drbd_bmio_set_n_write(struct drbd_device *device,
struct drbd_peer_device *peer_device) __must_hold(local);
extern int drbd_bmio_clear_n_write(struct drbd_device *device,
@@ -1295,8 +1298,10 @@ extern int drbd_bm_write(struct drbd_device *device,
extern void drbd_bm_reset_al_hints(struct drbd_device *device) __must_hold(local);
extern int drbd_bm_write_hinted(struct drbd_device *device) __must_hold(local);
extern int drbd_bm_write_lazy(struct drbd_device *device, unsigned upper_idx) __must_hold(local);
-extern int drbd_bm_write_all(struct drbd_device *device) __must_hold(local);
-extern int drbd_bm_write_copy_pages(struct drbd_device *device) __must_hold(local);
+extern int drbd_bm_write_all(struct drbd_device *device,
+ struct drbd_peer_device *peer_device) __must_hold(local);
+extern int drbd_bm_write_copy_pages(struct drbd_device *device,
+ struct drbd_peer_device *peer_device) __must_hold(local);
extern size_t drbd_bm_words(struct drbd_device *device);
extern unsigned long drbd_bm_bits(struct drbd_device *device);
extern sector_t drbd_bm_capacity(struct drbd_device *device);
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 6f2955f2dcc9..6647f84f3879 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -1198,7 +1198,7 @@ static int fill_bitmap_rle_bits(struct drbd_device *device,
* code upon failure.
*/
static int
-send_bitmap_rle_or_plain(struct drbd_peer_device *device, struct bm_xfer_ctx *c)
+send_bitmap_rle_or_plain(struct drbd_peer_device *peer_device, struct bm_xfer_ctx *c)
{
struct drbd_device *device = peer_device->device;
struct drbd_socket *sock = &peer_device->connection->data;
@@ -1269,7 +1269,7 @@ static int _drbd_send_bitmap(struct drbd_device *device,
if (drbd_md_test_flag(device->ldev, MDF_FULL_SYNC)) {
drbd_info(device, "Writing the whole bitmap, MDF_FullSync was set.\n");
drbd_bm_set_all(device);
- if (drbd_bm_write(device)) {
+ if (drbd_bm_write(device, peer_device)) {
/* write_bm did fail! Leave full sync flag set in Meta P_DATA
* but otherwise process as per normal - need to tell other
* side that a full resync is required! */
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 07a52c5a2989..8967298968f3 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -3007,11 +3007,12 @@ static int drbd_adm_simple_request_state(struct sk_buff *skb, struct genl_info *
return 0;
}

-static int drbd_bmio_set_susp_al(struct drbd_device *device) __must_hold(local)
+static int drbd_bmio_set_susp_al(struct drbd_device *device,
+ struct drbd_peer_device *peer_device) __must_hold(local)
{
int rv;

- rv = drbd_bmio_set_n_write(device);
+ rv = drbd_bmio_set_n_write(device, peer_device);
drbd_suspend_al(device);
return rv;
}
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 8605b5154a7e..e352880c70b5 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -4878,7 +4878,7 @@ static int receive_bitmap(struct drbd_connection *connection, struct packet_info
if (device->state.conn == C_WF_BITMAP_T) {
enum drbd_state_rv rv;

- err = drbd_send_bitmap(device);
+ err = drbd_send_bitmap(device, peer_device);
if (err)
goto out;
/* Omit CS_ORDERED with this state transition to avoid deadlocks. */
diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c
index 0b335ddd6d12..c92dc6093b0a 100644
--- a/drivers/block/drbd/drbd_state.c
+++ b/drivers/block/drbd/drbd_state.c
@@ -1810,7 +1810,7 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os,
device->state.conn == C_WF_BITMAP_S)
drbd_queue_bitmap_io(device, &drbd_send_bitmap, NULL,
"send_bitmap (WFBitMapS)",
- BM_LOCKED_TEST_ALLOWED);
+ BM_LOCKED_TEST_ALLOWED, peer_device);

/* Lost contact to peer's copy of the data */
if (lost_contact_to_peer_data(os.pdsk, ns.pdsk)) {
@@ -1840,7 +1840,7 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os,
* No harm done if the bitmap still changes,
* redirtied pages will follow later. */
drbd_bitmap_io_from_worker(device, &drbd_bm_write,
- "demote diskless peer", BM_LOCKED_SET_ALLOWED);
+ "demote diskless peer", BM_LOCKED_SET_ALLOWED, peer_device);
put_ldev(device);
}

@@ -1852,7 +1852,7 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os,
/* No changes to the bitmap expected this time, so assert that,
* even though no harm was done if it did change. */
drbd_bitmap_io_from_worker(device, &drbd_bm_write,
- "demote", BM_LOCKED_TEST_ALLOWED);
+ "demote", BM_LOCKED_TEST_ALLOWED, peer_device);
put_ldev(device);
}

@@ -1889,7 +1889,8 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os,
/* no other bitmap changes expected during this phase */
drbd_queue_bitmap_io(device,
&drbd_bmio_set_n_write, &abw_start_sync,
- "set_n_write from StartingSync", BM_LOCKED_TEST_ALLOWED);
+ "set_n_write from StartingSync", BM_LOCKED_TEST_ALLOWED,
+ peer_device);

/* first half of local IO error, failure to attach,
* or administrative detach */
@@ -2012,7 +2013,8 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os,
if ((os.conn > C_CONNECTED && os.conn < C_AHEAD) &&
(ns.conn == C_CONNECTED || ns.conn >= C_AHEAD) && get_ldev(device)) {
drbd_queue_bitmap_io(device, &drbd_bm_write_copy_pages, NULL,
- "write from resync_finished", BM_LOCKED_CHANGE_ALLOWED);
+ "write from resync_finished", BM_LOCKED_CHANGE_ALLOWED,
+ peer_device);
put_ldev(device);
}

diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c
index f46738040d6b..68d5ba4af17d 100644
--- a/drivers/block/drbd/drbd_worker.c
+++ b/drivers/block/drbd/drbd_worker.c
@@ -1945,6 +1945,7 @@ static void drbd_ldev_destroy(struct drbd_device *device)

static void go_diskless(struct drbd_device *device)
{
+ struct drbd_peer_device *peer_device = first_peer_device(device);
D_ASSERT(device, device->state.disk == D_FAILED);
/* we cannot assert local_cnt == 0 here, as get_ldev_if_state will
* inc/dec it frequently. Once we are D_DISKLESS, no one will touch
@@ -1970,7 +1971,7 @@ static void go_diskless(struct drbd_device *device)
* Any modifications would not be expected anymore, though.
*/
if (drbd_bitmap_io_from_worker(device, drbd_bm_write,
- "detach", BM_LOCKED_TEST_ALLOWED)) {
+ "detach", BM_LOCKED_TEST_ALLOWED, peer_device)) {
if (test_bit(WAS_READ_ERROR, &device->flags)) {
drbd_md_set_flag(device, MDF_FULL_SYNC);
drbd_md_sync(device);
--
2.39.1


2023-02-15 16:32:41

by Christoph Böhmwalder

[permalink] [raw]
Subject: [PATCH 4/7] drbd: drbd_uuid_compare: pass a peer_device

Signed-off-by: Christoph Böhmwalder <[email protected]>
---
drivers/block/drbd/drbd_receiver.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index aa896db1767d..8605b5154a7e 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -3226,10 +3226,11 @@ static void drbd_uuid_dump(struct drbd_device *device, char *text, u64 *uuid,
-1096 requires proto 96
*/

-static int drbd_uuid_compare(struct drbd_device *const device, enum drbd_role const peer_role, int *rule_nr) __must_hold(local)
+static int drbd_uuid_compare(struct drbd_peer_device *const peer_device,
+ enum drbd_role const peer_role, int *rule_nr) __must_hold(local)
{
- struct drbd_peer_device *const peer_device = first_peer_device(device);
- struct drbd_connection *const connection = peer_device ? peer_device->connection : NULL;
+ struct drbd_connection *const connection = peer_device->connection;
+ struct drbd_device *device = peer_device->device;
u64 self, peer;
int i, j;

@@ -3465,7 +3466,7 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_peer_device *peer_device,
drbd_uuid_dump(device, "peer", device->p_uuid,
device->p_uuid[UI_SIZE], device->p_uuid[UI_FLAGS]);

- hg = drbd_uuid_compare(device, peer_role, &rule_nr);
+ hg = drbd_uuid_compare(peer_device, peer_role, &rule_nr);
spin_unlock_irq(&device->ldev->md.uuid_lock);

drbd_info(device, "uuid_compare()=%d by rule %d\n", hg, rule_nr);
--
2.39.1


2023-02-15 16:32:41

by Christoph Böhmwalder

[permalink] [raw]
Subject: [PATCH 6/7] drbd: pass drbd_peer_device to __req_mod

In preparation to support multiple connections, we need to know which
one we need to modify the request state for.

Originally-from: Lars Ellenberg <[email protected]>
Signed-off-by: Christoph Böhmwalder <[email protected]>
---
drivers/block/drbd/drbd_main.c | 13 +++++++++----
drivers/block/drbd/drbd_receiver.c | 18 ++++++++++--------
drivers/block/drbd/drbd_req.c | 21 +++++++++++++--------
drivers/block/drbd/drbd_req.h | 11 +++++++----
drivers/block/drbd/drbd_worker.c | 14 +++++++-------
5 files changed, 46 insertions(+), 31 deletions(-)

diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 6647f84f3879..83987e7a5ef2 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -231,9 +231,11 @@ void tl_release(struct drbd_connection *connection, unsigned int barrier_nr,
}
req = list_prepare_entry(tmp, &connection->transfer_log, tl_requests);
list_for_each_entry_safe_from(req, r, &connection->transfer_log, tl_requests) {
+ struct drbd_peer_device *peer_device;
if (req->epoch != expect_epoch)
break;
- _req_mod(req, BARRIER_ACKED);
+ peer_device = conn_peer_device(connection, req->device->vnr);
+ _req_mod(req, BARRIER_ACKED, peer_device);
}
spin_unlock_irq(&connection->resource->req_lock);

@@ -256,10 +258,13 @@ void tl_release(struct drbd_connection *connection, unsigned int barrier_nr,
/* must hold resource->req_lock */
void _tl_restart(struct drbd_connection *connection, enum drbd_req_event what)
{
+ struct drbd_peer_device *peer_device;
struct drbd_request *req, *r;

- list_for_each_entry_safe(req, r, &connection->transfer_log, tl_requests)
- _req_mod(req, what);
+ list_for_each_entry_safe(req, r, &connection->transfer_log, tl_requests) {
+ peer_device = conn_peer_device(connection, req->device->vnr);
+ _req_mod(req, what, peer_device);
+ }
}

void tl_restart(struct drbd_connection *connection, enum drbd_req_event what)
@@ -297,7 +302,7 @@ void tl_abort_disk_io(struct drbd_device *device)
continue;
if (req->device != device)
continue;
- _req_mod(req, ABORT_DISK_IO);
+ _req_mod(req, ABORT_DISK_IO, NULL);
}
spin_unlock_irq(&connection->resource->req_lock);
}
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index e352880c70b5..856c0e3a6630 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -2138,7 +2138,7 @@ static int receive_DataReply(struct drbd_connection *connection, struct packet_i

err = recv_dless_read(peer_device, req, sector, pi->size);
if (!err)
- req_mod(req, DATA_RECEIVED);
+ req_mod(req, DATA_RECEIVED, peer_device);
/* else: nothing. handled from drbd_disconnect...
* I don't think we may complete this just yet
* in case we are "on-disconnect: freeze" */
@@ -2196,7 +2196,7 @@ static void restart_conflicting_writes(struct drbd_device *device,
continue;
/* as it is RQ_POSTPONED, this will cause it to
* be queued on the retry workqueue. */
- __req_mod(req, CONFLICT_RESOLVED, NULL);
+ __req_mod(req, CONFLICT_RESOLVED, NULL, NULL);
}
}

@@ -2420,6 +2420,7 @@ static blk_opf_t wire_flags_to_bio(struct drbd_connection *connection, u32 dpf)
static void fail_postponed_requests(struct drbd_device *device, sector_t sector,
unsigned int size)
{
+ struct drbd_peer_device *peer_device = first_peer_device(device);
struct drbd_interval *i;

repeat:
@@ -2433,7 +2434,7 @@ static void fail_postponed_requests(struct drbd_device *device, sector_t sector,
if (!(req->rq_state & RQ_POSTPONED))
continue;
req->rq_state &= ~RQ_POSTPONED;
- __req_mod(req, NEG_ACKED, &m);
+ __req_mod(req, NEG_ACKED, peer_device, &m);
spin_unlock_irq(&device->resource->req_lock);
if (m.bio)
complete_master_bio(device, &m);
@@ -5661,10 +5662,11 @@ static int got_IsInSync(struct drbd_connection *connection, struct packet_info *
}

static int
-validate_req_change_req_state(struct drbd_device *device, u64 id, sector_t sector,
+validate_req_change_req_state(struct drbd_peer_device *peer_device, u64 id, sector_t sector,
struct rb_root *root, const char *func,
enum drbd_req_event what, bool missing_ok)
{
+ struct drbd_device *device = peer_device->device;
struct drbd_request *req;
struct bio_and_error m;

@@ -5674,7 +5676,7 @@ validate_req_change_req_state(struct drbd_device *device, u64 id, sector_t secto
spin_unlock_irq(&device->resource->req_lock);
return -EIO;
}
- __req_mod(req, what, &m);
+ __req_mod(req, what, peer_device, &m);
spin_unlock_irq(&device->resource->req_lock);

if (m.bio)
@@ -5723,7 +5725,7 @@ static int got_BlockAck(struct drbd_connection *connection, struct packet_info *
BUG();
}

- return validate_req_change_req_state(device, p->block_id, sector,
+ return validate_req_change_req_state(peer_device, p->block_id, sector,
&device->write_requests, __func__,
what, false);
}
@@ -5750,7 +5752,7 @@ static int got_NegAck(struct drbd_connection *connection, struct packet_info *pi
return 0;
}

- err = validate_req_change_req_state(device, p->block_id, sector,
+ err = validate_req_change_req_state(peer_device, p->block_id, sector,
&device->write_requests, __func__,
NEG_ACKED, true);
if (err) {
@@ -5781,7 +5783,7 @@ static int got_NegDReply(struct drbd_connection *connection, struct packet_info
drbd_err(device, "Got NegDReply; Sector %llus, len %u.\n",
(unsigned long long)sector, be32_to_cpu(p->blksize));

- return validate_req_change_req_state(device, p->block_id, sector,
+ return validate_req_change_req_state(peer_device, p->block_id, sector,
&device->read_requests, __func__,
NEG_ACKED, false);
}
diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
index e36216d50753..528f29ebf369 100644
--- a/drivers/block/drbd/drbd_req.c
+++ b/drivers/block/drbd/drbd_req.c
@@ -552,12 +552,15 @@ static inline bool is_pending_write_protocol_A(struct drbd_request *req)
* happen "atomically" within the req_lock,
* and it enforces that we have to think in a very structured manner
* about the "events" that may happen to a request during its life time ...
+ *
+ *
+ * peer_device == NULL means local disk
*/
int __req_mod(struct drbd_request *req, enum drbd_req_event what,
+ struct drbd_peer_device *peer_device,
struct bio_and_error *m)
{
struct drbd_device *const device = req->device;
- struct drbd_peer_device *const peer_device = first_peer_device(device);
struct drbd_connection *const connection = peer_device ? peer_device->connection : NULL;
struct net_conf *nc;
int p, rv = 0;
@@ -1100,6 +1103,7 @@ static bool drbd_should_send_out_of_sync(union drbd_dev_state s)
static int drbd_process_write_request(struct drbd_request *req)
{
struct drbd_device *device = req->device;
+ struct drbd_peer_device *peer_device = first_peer_device(device);
int remote, send_oos;

remote = drbd_should_do_remote(device->state);
@@ -1115,7 +1119,7 @@ static int drbd_process_write_request(struct drbd_request *req)
/* The only size==0 bios we expect are empty flushes. */
D_ASSERT(device, req->master_bio->bi_opf & REQ_PREFLUSH);
if (remote)
- _req_mod(req, QUEUE_AS_DRBD_BARRIER);
+ _req_mod(req, QUEUE_AS_DRBD_BARRIER, peer_device);
return remote;
}

@@ -1125,10 +1129,10 @@ static int drbd_process_write_request(struct drbd_request *req)
D_ASSERT(device, !(remote && send_oos));

if (remote) {
- _req_mod(req, TO_BE_SENT);
- _req_mod(req, QUEUE_FOR_NET_WRITE);
+ _req_mod(req, TO_BE_SENT, peer_device);
+ _req_mod(req, QUEUE_FOR_NET_WRITE, peer_device);
} else if (drbd_set_out_of_sync(device, req->i.sector, req->i.size))
- _req_mod(req, QUEUE_FOR_SEND_OOS);
+ _req_mod(req, QUEUE_FOR_SEND_OOS, peer_device);

return remote;
}
@@ -1312,6 +1316,7 @@ static void drbd_update_plug(struct drbd_plug_cb *plug, struct drbd_request *req
static void drbd_send_and_submit(struct drbd_device *device, struct drbd_request *req)
{
struct drbd_resource *resource = device->resource;
+ struct drbd_peer_device *peer_device = first_peer_device(device);
const int rw = bio_data_dir(req->master_bio);
struct bio_and_error m = { NULL, };
bool no_remote = false;
@@ -1375,8 +1380,8 @@ static void drbd_send_and_submit(struct drbd_device *device, struct drbd_request
/* We either have a private_bio, or we can read from remote.
* Otherwise we had done the goto nodata above. */
if (req->private_bio == NULL) {
- _req_mod(req, TO_BE_SENT);
- _req_mod(req, QUEUE_FOR_NET_READ);
+ _req_mod(req, TO_BE_SENT, peer_device);
+ _req_mod(req, QUEUE_FOR_NET_READ, peer_device);
} else
no_remote = true;
}
@@ -1397,7 +1402,7 @@ static void drbd_send_and_submit(struct drbd_device *device, struct drbd_request
req->pre_submit_jif = jiffies;
list_add_tail(&req->req_pending_local,
&device->pending_completion[rw == WRITE]);
- _req_mod(req, TO_BE_SUBMITTED);
+ _req_mod(req, TO_BE_SUBMITTED, NULL);
/* but we need to give up the spinlock to submit */
submit_private_bio = true;
} else if (no_remote) {
diff --git a/drivers/block/drbd/drbd_req.h b/drivers/block/drbd/drbd_req.h
index b4017b5c3fbc..9ae860e7591b 100644
--- a/drivers/block/drbd/drbd_req.h
+++ b/drivers/block/drbd/drbd_req.h
@@ -267,6 +267,7 @@ struct bio_and_error {
extern void start_new_tl_epoch(struct drbd_connection *connection);
extern void drbd_req_destroy(struct kref *kref);
extern int __req_mod(struct drbd_request *req, enum drbd_req_event what,
+ struct drbd_peer_device *peer_device,
struct bio_and_error *m);
extern void complete_master_bio(struct drbd_device *device,
struct bio_and_error *m);
@@ -280,14 +281,15 @@ extern void drbd_restart_request(struct drbd_request *req);

/* use this if you don't want to deal with calling complete_master_bio()
* outside the spinlock, e.g. when walking some list on cleanup. */
-static inline int _req_mod(struct drbd_request *req, enum drbd_req_event what)
+static inline int _req_mod(struct drbd_request *req, enum drbd_req_event what,
+ struct drbd_peer_device *peer_device)
{
struct drbd_device *device = req->device;
struct bio_and_error m;
int rv;

/* __req_mod possibly frees req, do not touch req after that! */
- rv = __req_mod(req, what, &m);
+ rv = __req_mod(req, what, peer_device, &m);
if (m.bio)
complete_master_bio(device, &m);

@@ -299,7 +301,8 @@ static inline int _req_mod(struct drbd_request *req, enum drbd_req_event what)
* of the lower level driver completion callback, so we need to
* spin_lock_irqsave here. */
static inline int req_mod(struct drbd_request *req,
- enum drbd_req_event what)
+ enum drbd_req_event what,
+ struct drbd_peer_device *peer_device)
{
unsigned long flags;
struct drbd_device *device = req->device;
@@ -307,7 +310,7 @@ static inline int req_mod(struct drbd_request *req,
int rv;

spin_lock_irqsave(&device->resource->req_lock, flags);
- rv = __req_mod(req, what, &m);
+ rv = __req_mod(req, what, peer_device, &m);
spin_unlock_irqrestore(&device->resource->req_lock, flags);

if (m.bio)
diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c
index 68d5ba4af17d..6455edca7aa9 100644
--- a/drivers/block/drbd/drbd_worker.c
+++ b/drivers/block/drbd/drbd_worker.c
@@ -276,7 +276,7 @@ void drbd_request_endio(struct bio *bio)

/* not req_mod(), we need irqsave here! */
spin_lock_irqsave(&device->resource->req_lock, flags);
- __req_mod(req, what, &m);
+ __req_mod(req, what, NULL, &m);
spin_unlock_irqrestore(&device->resource->req_lock, flags);
put_ldev(device);

@@ -1425,7 +1425,7 @@ int w_send_out_of_sync(struct drbd_work *w, int cancel)
int err;

if (unlikely(cancel)) {
- req_mod(req, SEND_CANCELED);
+ req_mod(req, SEND_CANCELED, peer_device);
return 0;
}
req->pre_send_jif = jiffies;
@@ -1437,7 +1437,7 @@ int w_send_out_of_sync(struct drbd_work *w, int cancel)
maybe_send_barrier(connection, req->epoch);

err = drbd_send_out_of_sync(peer_device, req);
- req_mod(req, OOS_HANDED_TO_NETWORK);
+ req_mod(req, OOS_HANDED_TO_NETWORK, peer_device);

return err;
}
@@ -1457,7 +1457,7 @@ int w_send_dblock(struct drbd_work *w, int cancel)
int err;

if (unlikely(cancel)) {
- req_mod(req, SEND_CANCELED);
+ req_mod(req, SEND_CANCELED, peer_device);
return 0;
}
req->pre_send_jif = jiffies;
@@ -1467,7 +1467,7 @@ int w_send_dblock(struct drbd_work *w, int cancel)
connection->send.current_epoch_writes++;

err = drbd_send_dblock(peer_device, req);
- req_mod(req, err ? SEND_FAILED : HANDED_OVER_TO_NETWORK);
+ req_mod(req, err ? SEND_FAILED : HANDED_OVER_TO_NETWORK, peer_device);

if (do_send_unplug && !err)
pd_send_unplug_remote(peer_device);
@@ -1490,7 +1490,7 @@ int w_send_read_req(struct drbd_work *w, int cancel)
int err;

if (unlikely(cancel)) {
- req_mod(req, SEND_CANCELED);
+ req_mod(req, SEND_CANCELED, peer_device);
return 0;
}
req->pre_send_jif = jiffies;
@@ -1502,7 +1502,7 @@ int w_send_read_req(struct drbd_work *w, int cancel)
err = drbd_send_drequest(peer_device, P_DATA_REQUEST, req->i.sector, req->i.size,
(unsigned long)req);

- req_mod(req, err ? SEND_FAILED : HANDED_OVER_TO_NETWORK);
+ req_mod(req, err ? SEND_FAILED : HANDED_OVER_TO_NETWORK, peer_device);

if (do_send_unplug && !err)
pd_send_unplug_remote(peer_device);
--
2.39.1


2023-02-15 16:33:12

by Christoph Böhmwalder

[permalink] [raw]
Subject: [PATCH 7/7] drbd: Pass a peer device to the resync and online verify functions

Originally-from: Andreas Grünbacher <[email protected]>
Signed-off-by: Christoph Böhmwalder <[email protected]>
---
drivers/block/drbd/drbd_actlog.c | 13 ++--
drivers/block/drbd/drbd_int.h | 46 +++++++-------
drivers/block/drbd/drbd_receiver.c | 59 +++++++++---------
drivers/block/drbd/drbd_req.c | 9 +--
drivers/block/drbd/drbd_state.c | 10 +--
drivers/block/drbd/drbd_worker.c | 97 ++++++++++++++++--------------
6 files changed, 126 insertions(+), 108 deletions(-)

diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c
index 429255876800..64b3a1c76f03 100644
--- a/drivers/block/drbd/drbd_actlog.c
+++ b/drivers/block/drbd/drbd_actlog.c
@@ -735,8 +735,9 @@ static bool update_rs_extent(struct drbd_device *device,
return false;
}

-void drbd_advance_rs_marks(struct drbd_device *device, unsigned long still_to_go)
+void drbd_advance_rs_marks(struct drbd_peer_device *peer_device, unsigned long still_to_go)
{
+ struct drbd_device *device = peer_device->device;
unsigned long now = jiffies;
unsigned long last = device->rs_mark_time[device->rs_last_mark];
int next = (device->rs_last_mark + 1) % DRBD_SYNC_MARKS;
@@ -819,7 +820,7 @@ static int update_sync_bits(struct drbd_device *device,
if (mode == SET_IN_SYNC) {
unsigned long still_to_go = drbd_bm_total_weight(device);
bool rs_is_done = (still_to_go <= device->rs_failed);
- drbd_advance_rs_marks(device, still_to_go);
+ drbd_advance_rs_marks(first_peer_device(device), still_to_go);
if (cleared || rs_is_done)
maybe_schedule_on_disk_bitmap_update(device, rs_is_done);
} else if (mode == RECORD_RS_FAILED)
@@ -843,10 +844,11 @@ static bool plausible_request_size(int size)
* called by worker on C_SYNC_TARGET and receiver on SyncSource.
*
*/
-int __drbd_change_sync(struct drbd_device *device, sector_t sector, int size,
+int __drbd_change_sync(struct drbd_peer_device *peer_device, sector_t sector, int size,
enum update_sync_bits_mode mode)
{
/* Is called from worker and receiver context _only_ */
+ struct drbd_device *device = peer_device->device;
unsigned long sbnr, ebnr, lbnr;
unsigned long count = 0;
sector_t esector, nr_sectors;
@@ -1009,14 +1011,15 @@ int drbd_rs_begin_io(struct drbd_device *device, sector_t sector)
* tries to set it to BME_LOCKED. Returns 0 upon success, and -EAGAIN
* if there is still application IO going on in this area.
*/
-int drbd_try_rs_begin_io(struct drbd_device *device, sector_t sector)
+int drbd_try_rs_begin_io(struct drbd_peer_device *peer_device, sector_t sector)
{
+ struct drbd_device *device = peer_device->device;
unsigned int enr = BM_SECT_TO_EXT(sector);
const unsigned int al_enr = enr*AL_EXT_PER_BM_SECT;
struct lc_element *e;
struct bm_extent *bm_ext;
int i;
- bool throttle = drbd_rs_should_slow_down(device, sector, true);
+ bool throttle = drbd_rs_should_slow_down(peer_device, sector, true);

/* If we need to throttle, a half-locked (only marked BME_NO_WRITES,
* not yet BME_LOCKED) extent needs to be kicked out explicitly if we
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 345e96ceb47c..8bd9f49c472a 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -1432,21 +1432,24 @@ void drbd_resync_after_changed(struct drbd_device *device);
extern void drbd_start_resync(struct drbd_device *device, enum drbd_conns side);
extern void resume_next_sg(struct drbd_device *device);
extern void suspend_other_sg(struct drbd_device *device);
-extern int drbd_resync_finished(struct drbd_device *device);
+extern int drbd_resync_finished(struct drbd_peer_device *peer_device);
/* maybe rather drbd_main.c ? */
extern void *drbd_md_get_buffer(struct drbd_device *device, const char *intent);
extern void drbd_md_put_buffer(struct drbd_device *device);
extern int drbd_md_sync_page_io(struct drbd_device *device,
struct drbd_backing_dev *bdev, sector_t sector, enum req_op op);
-extern void drbd_ov_out_of_sync_found(struct drbd_device *, sector_t, int);
+extern void drbd_ov_out_of_sync_found(struct drbd_peer_device *peer_device,
+ sector_t sector, int size);
extern void wait_until_done_or_force_detached(struct drbd_device *device,
struct drbd_backing_dev *bdev, unsigned int *done);
-extern void drbd_rs_controller_reset(struct drbd_device *device);
+extern void drbd_rs_controller_reset(struct drbd_peer_device *peer_device);

-static inline void ov_out_of_sync_print(struct drbd_device *device)
+static inline void ov_out_of_sync_print(struct drbd_peer_device *peer_device)
{
+ struct drbd_device *device = peer_device->device;
+
if (device->ov_last_oos_size) {
- drbd_err(device, "Out of sync: start=%llu, size=%lu (sectors)\n",
+ drbd_err(peer_device, "Out of sync: start=%llu, size=%lu (sectors)\n",
(unsigned long long)device->ov_last_oos_start,
(unsigned long)device->ov_last_oos_size);
}
@@ -1485,7 +1488,7 @@ extern int drbd_ack_receiver(struct drbd_thread *thi);
extern void drbd_send_ping_wf(struct work_struct *ws);
extern void drbd_send_acks_wf(struct work_struct *ws);
extern bool drbd_rs_c_min_rate_throttle(struct drbd_device *device);
-extern bool drbd_rs_should_slow_down(struct drbd_device *device, sector_t sector,
+extern bool drbd_rs_should_slow_down(struct drbd_peer_device *peer_device, sector_t sector,
bool throttle_if_app_is_waiting);
extern int drbd_submit_peer_request(struct drbd_peer_request *peer_req);
extern int drbd_free_peer_reqs(struct drbd_device *, struct list_head *);
@@ -1541,22 +1544,22 @@ extern void drbd_al_begin_io(struct drbd_device *device, struct drbd_interval *i
extern void drbd_al_complete_io(struct drbd_device *device, struct drbd_interval *i);
extern void drbd_rs_complete_io(struct drbd_device *device, sector_t sector);
extern int drbd_rs_begin_io(struct drbd_device *device, sector_t sector);
-extern int drbd_try_rs_begin_io(struct drbd_device *device, sector_t sector);
+extern int drbd_try_rs_begin_io(struct drbd_peer_device *peer_device, sector_t sector);
extern void drbd_rs_cancel_all(struct drbd_device *device);
extern int drbd_rs_del_all(struct drbd_device *device);
-extern void drbd_rs_failed_io(struct drbd_device *device,
+extern void drbd_rs_failed_io(struct drbd_peer_device *peer_device,
sector_t sector, int size);
-extern void drbd_advance_rs_marks(struct drbd_device *device, unsigned long still_to_go);
+extern void drbd_advance_rs_marks(struct drbd_peer_device *peer_device, unsigned long still_to_go);

enum update_sync_bits_mode { RECORD_RS_FAILED, SET_OUT_OF_SYNC, SET_IN_SYNC };
-extern int __drbd_change_sync(struct drbd_device *device, sector_t sector, int size,
+extern int __drbd_change_sync(struct drbd_peer_device *peer_device, sector_t sector, int size,
enum update_sync_bits_mode mode);
-#define drbd_set_in_sync(device, sector, size) \
- __drbd_change_sync(device, sector, size, SET_IN_SYNC)
-#define drbd_set_out_of_sync(device, sector, size) \
- __drbd_change_sync(device, sector, size, SET_OUT_OF_SYNC)
-#define drbd_rs_failed_io(device, sector, size) \
- __drbd_change_sync(device, sector, size, RECORD_RS_FAILED)
+#define drbd_set_in_sync(peer_device, sector, size) \
+ __drbd_change_sync(peer_device, sector, size, SET_IN_SYNC)
+#define drbd_set_out_of_sync(peer_device, sector, size) \
+ __drbd_change_sync(peer_device, sector, size, SET_OUT_OF_SYNC)
+#define drbd_rs_failed_io(peer_device, sector, size) \
+ __drbd_change_sync(peer_device, sector, size, RECORD_RS_FAILED)
extern void drbd_al_shrink(struct drbd_device *device);
extern int drbd_al_initialize(struct drbd_device *, void *);

@@ -1944,15 +1947,16 @@ static inline int __dec_ap_pending(struct drbd_device *device)
* C_SYNC_SOURCE sends P_RS_DATA_REPLY (and expects P_WRITE_ACK with ID_SYNCER)
* (or P_NEG_ACK with ID_SYNCER)
*/
-static inline void inc_rs_pending(struct drbd_device *device)
+static inline void inc_rs_pending(struct drbd_peer_device *peer_device)
{
- atomic_inc(&device->rs_pending_cnt);
+ atomic_inc(&peer_device->device->rs_pending_cnt);
}

-#define dec_rs_pending(device) ((void)expect((device), __dec_rs_pending(device) >= 0))
-static inline int __dec_rs_pending(struct drbd_device *device)
+#define dec_rs_pending(peer_device) \
+ ((void)expect((peer_device), __dec_rs_pending(peer_device) >= 0))
+static inline int __dec_rs_pending(struct drbd_peer_device *peer_device)
{
- return atomic_dec_return(&device->rs_pending_cnt);
+ return atomic_dec_return(&peer_device->device->rs_pending_cnt);
}

/* counts how many answers we still need to send to the peer.
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 856c0e3a6630..e54404c632e7 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -2044,11 +2044,11 @@ static int e_end_resync_block(struct drbd_work *w, int unused)
D_ASSERT(device, drbd_interval_empty(&peer_req->i));

if (likely((peer_req->flags & EE_WAS_ERROR) == 0)) {
- drbd_set_in_sync(device, sector, peer_req->i.size);
+ drbd_set_in_sync(peer_device, sector, peer_req->i.size);
err = drbd_send_ack(peer_device, P_RS_WRITE_ACK, peer_req);
} else {
/* Record failure to sync */
- drbd_rs_failed_io(device, sector, peer_req->i.size);
+ drbd_rs_failed_io(peer_device, sector, peer_req->i.size);

err = drbd_send_ack(peer_device, P_NEG_ACK, peer_req);
}
@@ -2067,7 +2067,7 @@ static int recv_resync_read(struct drbd_peer_device *peer_device, sector_t secto
if (!peer_req)
goto fail;

- dec_rs_pending(device);
+ dec_rs_pending(peer_device);

inc_unacked(device);
/* corresponding dec_unacked() in e_end_resync_block()
@@ -2220,7 +2220,7 @@ static int e_end_block(struct drbd_work *w, int cancel)
P_RS_WRITE_ACK : P_WRITE_ACK;
err = drbd_send_ack(peer_device, pcmd, peer_req);
if (pcmd == P_RS_WRITE_ACK)
- drbd_set_in_sync(device, sector, peer_req->i.size);
+ drbd_set_in_sync(peer_device, sector, peer_req->i.size);
} else {
err = drbd_send_ack(peer_device, P_NEG_ACK, peer_req);
/* we expect it to be marked out of sync anyways...
@@ -2691,7 +2691,7 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info *

if (device->state.pdsk < D_INCONSISTENT) {
/* In case we have the only disk of the cluster, */
- drbd_set_out_of_sync(device, peer_req->i.sector, peer_req->i.size);
+ drbd_set_out_of_sync(peer_device, peer_req->i.sector, peer_req->i.size);
peer_req->flags &= ~EE_MAY_SET_IN_SYNC;
drbd_al_begin_io(device, &peer_req->i);
peer_req->flags |= EE_CALL_AL_COMPLETE_IO;
@@ -2730,9 +2730,10 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info *
* The current sync rate used here uses only the most recent two step marks,
* to have a short time average so we can react faster.
*/
-bool drbd_rs_should_slow_down(struct drbd_device *device, sector_t sector,
+bool drbd_rs_should_slow_down(struct drbd_peer_device *peer_device, sector_t sector,
bool throttle_if_app_is_waiting)
{
+ struct drbd_device *device = peer_device->device;
struct lc_element *tmp;
bool throttle = drbd_rs_c_min_rate_throttle(device);

@@ -2844,7 +2845,7 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet
break;
case P_OV_REPLY:
verb = 0;
- dec_rs_pending(device);
+ dec_rs_pending(peer_device);
drbd_send_ack_ex(peer_device, P_OV_RESULT, sector, size, ID_IN_SYNC);
break;
default:
@@ -2915,7 +2916,7 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet
/* track progress, we may need to throttle */
atomic_add(size >> 9, &device->rs_sect_in);
peer_req->w.cb = w_e_end_ov_reply;
- dec_rs_pending(device);
+ dec_rs_pending(peer_device);
/* drbd_rs_begin_io done when we sent this request,
* but accounting still needs to be done. */
goto submit_for_resync;
@@ -2978,7 +2979,7 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet

update_receiver_timing_details(connection, drbd_rs_should_slow_down);
if (device->state.peer != R_PRIMARY
- && drbd_rs_should_slow_down(device, sector, false))
+ && drbd_rs_should_slow_down(peer_device, sector, false))
schedule_timeout_uninterruptible(HZ/10);
update_receiver_timing_details(connection, drbd_rs_begin_io);
if (drbd_rs_begin_io(device, sector))
@@ -4450,7 +4451,7 @@ static int receive_state(struct drbd_connection *connection, struct packet_info
else if (os.conn >= C_SYNC_SOURCE &&
peer_state.conn == C_CONNECTED) {
if (drbd_bm_total_weight(device) <= device->rs_failed)
- drbd_resync_finished(device);
+ drbd_resync_finished(peer_device);
return 0;
}
}
@@ -4458,8 +4459,8 @@ static int receive_state(struct drbd_connection *connection, struct packet_info
/* explicit verify finished notification, stop sector reached. */
if (os.conn == C_VERIFY_T && os.disk == D_UP_TO_DATE &&
peer_state.conn == C_CONNECTED && real_peer_disk == D_UP_TO_DATE) {
- ov_out_of_sync_print(device);
- drbd_resync_finished(device);
+ ov_out_of_sync_print(peer_device);
+ drbd_resync_finished(peer_device);
return 0;
}

@@ -4937,7 +4938,7 @@ static int receive_out_of_sync(struct drbd_connection *connection, struct packet
drbd_conn_str(device->state.conn));
}

- drbd_set_out_of_sync(device, be64_to_cpu(p->sector), be32_to_cpu(p->blksize));
+ drbd_set_out_of_sync(peer_device, be64_to_cpu(p->sector), be32_to_cpu(p->blksize));

return 0;
}
@@ -4958,7 +4959,7 @@ static int receive_rs_deallocated(struct drbd_connection *connection, struct pac
sector = be64_to_cpu(p->sector);
size = be32_to_cpu(p->blksize);

- dec_rs_pending(device);
+ dec_rs_pending(peer_device);

if (get_ldev(device)) {
struct drbd_peer_request *peer_req;
@@ -5650,12 +5651,12 @@ static int got_IsInSync(struct drbd_connection *connection, struct packet_info *

if (get_ldev(device)) {
drbd_rs_complete_io(device, sector);
- drbd_set_in_sync(device, sector, blksize);
+ drbd_set_in_sync(peer_device, sector, blksize);
/* rs_same_csums is supposed to count in units of BM_BLOCK_SIZE */
device->rs_same_csum += (blksize >> BM_BLOCK_SHIFT);
put_ldev(device);
}
- dec_rs_pending(device);
+ dec_rs_pending(peer_device);
atomic_add(blksize >> 9, &device->rs_sect_in);

return 0;
@@ -5701,8 +5702,8 @@ static int got_BlockAck(struct drbd_connection *connection, struct packet_info *
update_peer_seq(peer_device, be32_to_cpu(p->seq_num));

if (p->block_id == ID_SYNCER) {
- drbd_set_in_sync(device, sector, blksize);
- dec_rs_pending(device);
+ drbd_set_in_sync(peer_device, sector, blksize);
+ dec_rs_pending(peer_device);
return 0;
}
switch (pi->cmd) {
@@ -5747,8 +5748,8 @@ static int got_NegAck(struct drbd_connection *connection, struct packet_info *pi
update_peer_seq(peer_device, be32_to_cpu(p->seq_num));

if (p->block_id == ID_SYNCER) {
- dec_rs_pending(device);
- drbd_rs_failed_io(device, sector, size);
+ dec_rs_pending(peer_device);
+ drbd_rs_failed_io(peer_device, sector, size);
return 0;
}

@@ -5761,7 +5762,7 @@ static int got_NegAck(struct drbd_connection *connection, struct packet_info *pi
request is no longer in the collision hash. */
/* In Protocol B we might already have got a P_RECV_ACK
but then get a P_NEG_ACK afterwards. */
- drbd_set_out_of_sync(device, sector, size);
+ drbd_set_out_of_sync(peer_device, sector, size);
}
return 0;
}
@@ -5806,13 +5807,13 @@ static int got_NegRSDReply(struct drbd_connection *connection, struct packet_inf

update_peer_seq(peer_device, be32_to_cpu(p->seq_num));

- dec_rs_pending(device);
+ dec_rs_pending(peer_device);

if (get_ldev_if_state(device, D_FAILED)) {
drbd_rs_complete_io(device, sector);
switch (pi->cmd) {
case P_NEG_RS_DREPLY:
- drbd_rs_failed_io(device, sector, size);
+ drbd_rs_failed_io(peer_device, sector, size);
break;
case P_RS_CANCEL:
break;
@@ -5869,21 +5870,21 @@ static int got_OVResult(struct drbd_connection *connection, struct packet_info *
update_peer_seq(peer_device, be32_to_cpu(p->seq_num));

if (be64_to_cpu(p->block_id) == ID_OUT_OF_SYNC)
- drbd_ov_out_of_sync_found(device, sector, size);
+ drbd_ov_out_of_sync_found(peer_device, sector, size);
else
- ov_out_of_sync_print(device);
+ ov_out_of_sync_print(peer_device);

if (!get_ldev(device))
return 0;

drbd_rs_complete_io(device, sector);
- dec_rs_pending(device);
+ dec_rs_pending(peer_device);

--device->ov_left;

/* let's advance progress step marks only for every other megabyte */
if ((device->ov_left & 0x200) == 0x200)
- drbd_advance_rs_marks(device, device->ov_left);
+ drbd_advance_rs_marks(peer_device, device->ov_left);

if (device->ov_left == 0) {
dw = kmalloc(sizeof(*dw), GFP_NOIO);
@@ -5893,8 +5894,8 @@ static int got_OVResult(struct drbd_connection *connection, struct packet_info *
drbd_queue_work(&peer_device->connection->sender_work, &dw->w);
} else {
drbd_err(device, "kmalloc(dw) failed.");
- ov_out_of_sync_print(device);
- drbd_resync_finished(device);
+ ov_out_of_sync_print(peer_device);
+ drbd_resync_finished(peer_device);
}
}
put_ldev(device);
diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
index 528f29ebf369..380e6584a4ee 100644
--- a/drivers/block/drbd/drbd_req.c
+++ b/drivers/block/drbd/drbd_req.c
@@ -122,12 +122,13 @@ void drbd_req_destroy(struct kref *kref)
* before it even was submitted or sent.
* In that case we do not want to touch the bitmap at all.
*/
+ struct drbd_peer_device *peer_device = first_peer_device(device);
if ((s & (RQ_POSTPONED|RQ_LOCAL_MASK|RQ_NET_MASK)) != RQ_POSTPONED) {
if (!(s & RQ_NET_OK) || !(s & RQ_LOCAL_OK))
- drbd_set_out_of_sync(device, req->i.sector, req->i.size);
+ drbd_set_out_of_sync(peer_device, req->i.sector, req->i.size);

if ((s & RQ_NET_OK) && (s & RQ_LOCAL_OK) && (s & RQ_NET_SIS))
- drbd_set_in_sync(device, req->i.sector, req->i.size);
+ drbd_set_in_sync(peer_device, req->i.sector, req->i.size);
}

/* one might be tempted to move the drbd_al_complete_io
@@ -620,7 +621,7 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what,
break;

case READ_COMPLETED_WITH_ERROR:
- drbd_set_out_of_sync(device, req->i.sector, req->i.size);
+ drbd_set_out_of_sync(peer_device, req->i.sector, req->i.size);
drbd_report_io_error(device, req);
__drbd_chk_io_error(device, DRBD_READ_ERROR);
fallthrough;
@@ -1131,7 +1132,7 @@ static int drbd_process_write_request(struct drbd_request *req)
if (remote) {
_req_mod(req, TO_BE_SENT, peer_device);
_req_mod(req, QUEUE_FOR_NET_WRITE, peer_device);
- } else if (drbd_set_out_of_sync(device, req->i.sector, req->i.size))
+ } else if (drbd_set_out_of_sync(peer_device, req->i.sector, req->i.size))
_req_mod(req, QUEUE_FOR_SEND_OOS, peer_device);

return remote;
diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c
index c92dc6093b0a..563e67f1ead9 100644
--- a/drivers/block/drbd/drbd_state.c
+++ b/drivers/block/drbd/drbd_state.c
@@ -1222,9 +1222,11 @@ void drbd_resume_al(struct drbd_device *device)
}

/* helper for _drbd_set_state */
-static void set_ov_position(struct drbd_device *device, enum drbd_conns cs)
+static void set_ov_position(struct drbd_peer_device *peer_device, enum drbd_conns cs)
{
- if (first_peer_device(device)->connection->agreed_pro_version < 90)
+ struct drbd_device *device = peer_device->device;
+
+ if (peer_device->connection->agreed_pro_version < 90)
device->ov_start_sector = 0;
device->rs_total = drbd_bm_bits(device);
device->ov_position = 0;
@@ -1387,7 +1389,7 @@ _drbd_set_state(struct drbd_device *device, union drbd_state ns,
unsigned long now = jiffies;
int i;

- set_ov_position(device, ns.conn);
+ set_ov_position(peer_device, ns.conn);
device->rs_start = now;
device->rs_last_sect_ev = 0;
device->ov_last_oos_size = 0;
@@ -1398,7 +1400,7 @@ _drbd_set_state(struct drbd_device *device, union drbd_state ns,
device->rs_mark_time[i] = now;
}

- drbd_rs_controller_reset(device);
+ drbd_rs_controller_reset(peer_device);

if (ns.conn == C_VERIFY_S) {
drbd_info(device, "Starting Online Verify from sector %llu\n",
diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c
index 6455edca7aa9..4352a50fbb3f 100644
--- a/drivers/block/drbd/drbd_worker.c
+++ b/drivers/block/drbd/drbd_worker.c
@@ -28,8 +28,8 @@
#include "drbd_protocol.h"
#include "drbd_req.h"

-static int make_ov_request(struct drbd_device *, int);
-static int make_resync_request(struct drbd_device *, int);
+static int make_ov_request(struct drbd_peer_device *, int);
+static int make_resync_request(struct drbd_peer_device *, int);

/* endio handlers:
* drbd_md_endio (defined here)
@@ -124,7 +124,7 @@ void drbd_endio_write_sec_final(struct drbd_peer_request *peer_req) __releases(l
* In case of a write error, send the neg ack anyways. */
if (!__test_and_set_bit(__EE_SEND_WRITE_ACK, &peer_req->flags))
inc_unacked(device);
- drbd_set_out_of_sync(device, peer_req->i.sector, peer_req->i.size);
+ drbd_set_out_of_sync(peer_device, peer_req->i.sector, peer_req->i.size);
}

spin_lock_irqsave(&device->resource->req_lock, flags);
@@ -363,7 +363,7 @@ static int w_e_send_csum(struct drbd_work *w, int cancel)
* drbd_alloc_pages due to pp_in_use > max_buffers. */
drbd_free_peer_req(device, peer_req);
peer_req = NULL;
- inc_rs_pending(device);
+ inc_rs_pending(peer_device);
err = drbd_send_drequest_csum(peer_device, sector, size,
digest, digest_size,
P_CSUM_RS_REQUEST);
@@ -430,10 +430,10 @@ int w_resync_timer(struct drbd_work *w, int cancel)

switch (device->state.conn) {
case C_VERIFY_S:
- make_ov_request(device, cancel);
+ make_ov_request(first_peer_device(device), cancel);
break;
case C_SYNC_TARGET:
- make_resync_request(device, cancel);
+ make_resync_request(first_peer_device(device), cancel);
break;
}

@@ -493,8 +493,9 @@ struct fifo_buffer *fifo_alloc(unsigned int fifo_size)
return fb;
}

-static int drbd_rs_controller(struct drbd_device *device, unsigned int sect_in)
+static int drbd_rs_controller(struct drbd_peer_device *peer_device, unsigned int sect_in)
{
+ struct drbd_device *device = peer_device->device;
struct disk_conf *dc;
unsigned int want; /* The number of sectors we want in-flight */
int req_sect; /* Number of sectors to request in this turn */
@@ -545,8 +546,9 @@ static int drbd_rs_controller(struct drbd_device *device, unsigned int sect_in)
return req_sect;
}

-static int drbd_rs_number_requests(struct drbd_device *device)
+static int drbd_rs_number_requests(struct drbd_peer_device *peer_device)
{
+ struct drbd_device *device = peer_device->device;
unsigned int sect_in; /* Number of sectors that came in since the last turn */
int number, mxb;

@@ -556,7 +558,7 @@ static int drbd_rs_number_requests(struct drbd_device *device)
rcu_read_lock();
mxb = drbd_get_max_buffers(device) / 2;
if (rcu_dereference(device->rs_plan_s)->size) {
- number = drbd_rs_controller(device, sect_in) >> (BM_BLOCK_SHIFT - 9);
+ number = drbd_rs_controller(peer_device, sect_in) >> (BM_BLOCK_SHIFT - 9);
device->c_sync_rate = number * HZ * (BM_BLOCK_SIZE / 1024) / SLEEP_TIME;
} else {
device->c_sync_rate = rcu_dereference(device->ldev->disk_conf)->resync_rate;
@@ -580,9 +582,9 @@ static int drbd_rs_number_requests(struct drbd_device *device)
return number;
}

-static int make_resync_request(struct drbd_device *const device, int cancel)
+static int make_resync_request(struct drbd_peer_device *const peer_device, int cancel)
{
- struct drbd_peer_device *const peer_device = first_peer_device(device);
+ struct drbd_device *const device = peer_device->device;
struct drbd_connection *const connection = peer_device ? peer_device->connection : NULL;
unsigned long bit;
sector_t sector;
@@ -598,7 +600,7 @@ static int make_resync_request(struct drbd_device *const device, int cancel)

if (device->rs_total == 0) {
/* empty resync? */
- drbd_resync_finished(device);
+ drbd_resync_finished(peer_device);
return 0;
}

@@ -618,7 +620,7 @@ static int make_resync_request(struct drbd_device *const device, int cancel)
}

max_bio_size = queue_max_hw_sectors(device->rq_queue) << 9;
- number = drbd_rs_number_requests(device);
+ number = drbd_rs_number_requests(peer_device);
if (number <= 0)
goto requeue;

@@ -653,7 +655,7 @@ static int make_resync_request(struct drbd_device *const device, int cancel)

sector = BM_BIT_TO_SECT(bit);

- if (drbd_try_rs_begin_io(device, sector)) {
+ if (drbd_try_rs_begin_io(peer_device, sector)) {
device->bm_resync_fo = bit;
goto requeue;
}
@@ -729,13 +731,13 @@ static int make_resync_request(struct drbd_device *const device, int cancel)
} else {
int err;

- inc_rs_pending(device);
+ inc_rs_pending(peer_device);
err = drbd_send_drequest(peer_device,
size == discard_granularity ? P_RS_THIN_REQ : P_RS_DATA_REQUEST,
sector, size, ID_SYNCER);
if (err) {
drbd_err(device, "drbd_send_drequest() failed, aborting...\n");
- dec_rs_pending(device);
+ dec_rs_pending(peer_device);
put_ldev(device);
return err;
}
@@ -760,8 +762,9 @@ static int make_resync_request(struct drbd_device *const device, int cancel)
return 0;
}

-static int make_ov_request(struct drbd_device *device, int cancel)
+static int make_ov_request(struct drbd_peer_device *peer_device, int cancel)
{
+ struct drbd_device *device = peer_device->device;
int number, i, size;
sector_t sector;
const sector_t capacity = get_capacity(device->vdisk);
@@ -770,7 +773,7 @@ static int make_ov_request(struct drbd_device *device, int cancel)
if (unlikely(cancel))
return 1;

- number = drbd_rs_number_requests(device);
+ number = drbd_rs_number_requests(peer_device);

sector = device->ov_position;
for (i = 0; i < number; i++) {
@@ -788,7 +791,7 @@ static int make_ov_request(struct drbd_device *device, int cancel)

size = BM_BLOCK_SIZE;

- if (drbd_try_rs_begin_io(device, sector)) {
+ if (drbd_try_rs_begin_io(peer_device, sector)) {
device->ov_position = sector;
goto requeue;
}
@@ -796,9 +799,9 @@ static int make_ov_request(struct drbd_device *device, int cancel)
if (sector + (size>>9) > capacity)
size = (capacity-sector)<<9;

- inc_rs_pending(device);
+ inc_rs_pending(peer_device);
if (drbd_send_ov_request(first_peer_device(device), sector, size)) {
- dec_rs_pending(device);
+ dec_rs_pending(peer_device);
return 0;
}
sector += BM_SECT_PER_BIT;
@@ -818,8 +821,8 @@ int w_ov_finished(struct drbd_work *w, int cancel)
container_of(w, struct drbd_device_work, w);
struct drbd_device *device = dw->device;
kfree(dw);
- ov_out_of_sync_print(device);
- drbd_resync_finished(device);
+ ov_out_of_sync_print(first_peer_device(device));
+ drbd_resync_finished(first_peer_device(device));

return 0;
}
@@ -831,7 +834,7 @@ static int w_resync_finished(struct drbd_work *w, int cancel)
struct drbd_device *device = dw->device;
kfree(dw);

- drbd_resync_finished(device);
+ drbd_resync_finished(first_peer_device(device));

return 0;
}
@@ -846,9 +849,10 @@ static void ping_peer(struct drbd_device *device)
test_bit(GOT_PING_ACK, &connection->flags) || device->state.conn < C_CONNECTED);
}

-int drbd_resync_finished(struct drbd_device *device)
+int drbd_resync_finished(struct drbd_peer_device *peer_device)
{
- struct drbd_connection *connection = first_peer_device(device)->connection;
+ struct drbd_device *device = peer_device->device;
+ struct drbd_connection *connection = peer_device->connection;
unsigned long db, dt, dbdt;
unsigned long n_oos;
union drbd_state os, ns;
@@ -1129,7 +1133,7 @@ int w_e_end_rsdata_req(struct drbd_work *w, int cancel)
err = drbd_send_ack(peer_device, P_RS_CANCEL, peer_req);
} else if (likely((peer_req->flags & EE_WAS_ERROR) == 0)) {
if (likely(device->state.pdsk >= D_INCONSISTENT)) {
- inc_rs_pending(device);
+ inc_rs_pending(peer_device);
if (peer_req->flags & EE_RS_THIN_REQ && all_zero(peer_req))
err = drbd_send_rs_deallocated(peer_device, peer_req);
else
@@ -1148,7 +1152,7 @@ int w_e_end_rsdata_req(struct drbd_work *w, int cancel)
err = drbd_send_ack(peer_device, P_NEG_RS_DREPLY, peer_req);

/* update resync data with failure */
- drbd_rs_failed_io(device, peer_req->i.sector, peer_req->i.size);
+ drbd_rs_failed_io(peer_device, peer_req->i.sector, peer_req->i.size);
}

dec_unacked(device);
@@ -1199,12 +1203,12 @@ int w_e_end_csum_rs_req(struct drbd_work *w, int cancel)
}

if (eq) {
- drbd_set_in_sync(device, peer_req->i.sector, peer_req->i.size);
+ drbd_set_in_sync(peer_device, peer_req->i.sector, peer_req->i.size);
/* rs_same_csums unit is BM_BLOCK_SIZE */
device->rs_same_csum += peer_req->i.size >> BM_BLOCK_SHIFT;
err = drbd_send_ack(peer_device, P_RS_IS_IN_SYNC, peer_req);
} else {
- inc_rs_pending(device);
+ inc_rs_pending(peer_device);
peer_req->block_id = ID_SYNCER; /* By setting block_id, digest pointer becomes invalid! */
peer_req->flags &= ~EE_HAS_DIGEST; /* This peer request no longer has a digest pointer */
kfree(di);
@@ -1257,10 +1261,10 @@ int w_e_end_ov_req(struct drbd_work *w, int cancel)
* drbd_alloc_pages due to pp_in_use > max_buffers. */
drbd_free_peer_req(device, peer_req);
peer_req = NULL;
- inc_rs_pending(device);
+ inc_rs_pending(peer_device);
err = drbd_send_drequest_csum(peer_device, sector, size, digest, digest_size, P_OV_REPLY);
if (err)
- dec_rs_pending(device);
+ dec_rs_pending(peer_device);
kfree(digest);

out:
@@ -1270,15 +1274,16 @@ int w_e_end_ov_req(struct drbd_work *w, int cancel)
return err;
}

-void drbd_ov_out_of_sync_found(struct drbd_device *device, sector_t sector, int size)
+void drbd_ov_out_of_sync_found(struct drbd_peer_device *peer_device, sector_t sector, int size)
{
+ struct drbd_device *device = peer_device->device;
if (device->ov_last_oos_start + device->ov_last_oos_size == sector) {
device->ov_last_oos_size += size>>9;
} else {
device->ov_last_oos_start = sector;
device->ov_last_oos_size = size>>9;
}
- drbd_set_out_of_sync(device, sector, size);
+ drbd_set_out_of_sync(peer_device, sector, size);
}

int w_e_end_ov_reply(struct drbd_work *w, int cancel)
@@ -1328,9 +1333,9 @@ int w_e_end_ov_reply(struct drbd_work *w, int cancel)
* drbd_alloc_pages due to pp_in_use > max_buffers. */
drbd_free_peer_req(device, peer_req);
if (!eq)
- drbd_ov_out_of_sync_found(device, sector, size);
+ drbd_ov_out_of_sync_found(peer_device, sector, size);
else
- ov_out_of_sync_print(device);
+ ov_out_of_sync_print(peer_device);

err = drbd_send_ack_ex(peer_device, P_OV_RESULT, sector, size,
eq ? ID_IN_SYNC : ID_OUT_OF_SYNC);
@@ -1341,14 +1346,14 @@ int w_e_end_ov_reply(struct drbd_work *w, int cancel)

/* let's advance progress step marks only for every other megabyte */
if ((device->ov_left & 0x200) == 0x200)
- drbd_advance_rs_marks(device, device->ov_left);
+ drbd_advance_rs_marks(peer_device, device->ov_left);

stop_sector_reached = verify_can_do_stop_sector(device) &&
(sector + (size>>9)) >= device->ov_stop_sector;

if (device->ov_left == 0 || stop_sector_reached) {
- ov_out_of_sync_print(device);
- drbd_resync_finished(device);
+ ov_out_of_sync_print(peer_device);
+ drbd_resync_finished(peer_device);
}

return err;
@@ -1668,8 +1673,9 @@ void drbd_resync_after_changed(struct drbd_device *device)
} while (changed);
}

-void drbd_rs_controller_reset(struct drbd_device *device)
+void drbd_rs_controller_reset(struct drbd_peer_device *peer_device)
{
+ struct drbd_device *device = peer_device->device;
struct gendisk *disk = device->ldev->backing_bdev->bd_disk;
struct fifo_buffer *plan;

@@ -1891,10 +1897,10 @@ void drbd_start_resync(struct drbd_device *device, enum drbd_conns side)
rcu_read_unlock();
schedule_timeout_interruptible(timeo);
}
- drbd_resync_finished(device);
+ drbd_resync_finished(peer_device);
}

- drbd_rs_controller_reset(device);
+ drbd_rs_controller_reset(peer_device);
/* ns.conn may already be != device->state.conn,
* we may have been paused in between, or become paused until
* the timer triggers.
@@ -1909,8 +1915,9 @@ void drbd_start_resync(struct drbd_device *device, enum drbd_conns side)
mutex_unlock(device->state_mutex);
}

-static void update_on_disk_bitmap(struct drbd_device *device, bool resync_done)
+static void update_on_disk_bitmap(struct drbd_peer_device *peer_device, bool resync_done)
{
+ struct drbd_device *device = peer_device->device;
struct sib_info sib = { .sib_reason = SIB_SYNC_PROGRESS, };
device->rs_last_bcast = jiffies;

@@ -1919,7 +1926,7 @@ static void update_on_disk_bitmap(struct drbd_device *device, bool resync_done)

drbd_bm_write_lazy(device, 0);
if (resync_done && is_sync_state(device->state.conn))
- drbd_resync_finished(device);
+ drbd_resync_finished(peer_device);

drbd_bcast_event(device, &sib);
/* update timestamp, in case it took a while to write out stuff */
@@ -2018,7 +2025,7 @@ static void do_device_work(struct drbd_device *device, const unsigned long todo)
do_md_sync(device);
if (test_bit(RS_DONE, &todo) ||
test_bit(RS_PROGRESS, &todo))
- update_on_disk_bitmap(device, test_bit(RS_DONE, &todo));
+ update_on_disk_bitmap(first_peer_device(device), test_bit(RS_DONE, &todo));
if (test_bit(GO_DISKLESS, &todo))
go_diskless(device);
if (test_bit(DESTROY_DISK, &todo))
--
2.39.1


2023-02-15 18:47:54

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/7] drbd: Add peer device parameter to whole-bitmap I/O handlers

Hi Christoph,

I love your patch! Perhaps something to improve:

[auto build test WARNING on a06377c5d01eeeaa52ad979b62c3c72efcc3eff0]

url: https://github.com/intel-lab-lkp/linux/commits/Christoph-B-hmwalder/drbd-Rip-out-the-ERR_IF_CNT_IS_NEGATIVE-macro/20230216-003454
base: a06377c5d01eeeaa52ad979b62c3c72efcc3eff0
patch link: https://lore.kernel.org/r/20230215163204.2856631-3-christoph.boehmwalder%40linbit.com
patch subject: [PATCH 2/7] drbd: Add peer device parameter to whole-bitmap I/O handlers
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230216/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/e55221e8a69f80303803dab7e079bff7b698ea02
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Christoph-B-hmwalder/drbd-Rip-out-the-ERR_IF_CNT_IS_NEGATIVE-macro/20230216-003454
git checkout e55221e8a69f80303803dab7e079bff7b698ea02
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/block/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

In file included from include/linux/drbd_genl_api.h:54,
from drivers/block/drbd/drbd_int.h:35,
from drivers/block/drbd/drbd_nl.c:24:
include/linux/drbd_genl_api.h:51:33: warning: no previous prototype for 'drbd_genl_cmd_to_str' [-Wmissing-prototypes]
51 | #define GENL_MAGIC_FAMILY drbd
| ^~~~
include/linux/genl_magic_struct.h:20:25: note: in definition of macro 'CONCAT__'
20 | #define CONCAT__(a,b) a ## b
| ^
include/linux/genl_magic_func.h:212:13: note: in expansion of macro 'CONCAT_'
212 | const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
| ^~~~~~~
include/linux/genl_magic_func.h:212:21: note: in expansion of macro 'GENL_MAGIC_FAMILY'
212 | const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
| ^~~~~~~~~~~~~~~~~
drivers/block/drbd/drbd_nl.c: In function 'drbd_determine_dev_size':
>> drivers/block/drbd/drbd_nl.c:1055:70: warning: pointer type mismatch in conditional expression
1055 | drbd_bitmap_io(device, md_moved ? &drbd_bm_write_all : &drbd_bm_write,
| ^
drivers/block/drbd/drbd_nl.c:1055:17: error: too many arguments to function 'drbd_bitmap_io'
1055 | drbd_bitmap_io(device, md_moved ? &drbd_bm_write_all : &drbd_bm_write,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1072:12: note: declared here
1072 | extern int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_nl.c: In function 'drbd_adm_attach':
drivers/block/drbd/drbd_nl.c:2029:21: error: too many arguments to function 'drbd_bitmap_io'
2029 | if (drbd_bitmap_io(device, &drbd_bmio_set_n_write,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1072:12: note: declared here
1072 | extern int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_nl.c:2036:21: error: too many arguments to function 'drbd_bitmap_io'
2036 | if (drbd_bitmap_io(device, &drbd_bm_read,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1072:12: note: declared here
1072 | extern int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_nl.c: In function 'drbd_adm_invalidate':
drivers/block/drbd/drbd_nl.c:2976:29: error: too many arguments to function 'drbd_bitmap_io'
2976 | if (drbd_bitmap_io(device, &drbd_bmio_set_n_write,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1072:12: note: declared here
1072 | extern int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_nl.c: In function 'drbd_bmio_set_susp_al':
drivers/block/drbd/drbd_nl.c:3014:14: error: too few arguments to function 'drbd_bmio_set_n_write'
3014 | rv = drbd_bmio_set_n_write(device);
| ^~~~~~~~~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1078:12: note: declared here
1078 | extern int drbd_bmio_set_n_write(struct drbd_device *device,
| ^~~~~~~~~~~~~~~~~~~~~
drivers/block/drbd/drbd_nl.c: In function 'drbd_adm_invalidate_peer':
drivers/block/drbd/drbd_nl.c:3055:52: error: passing argument 2 of 'drbd_bitmap_io' from incompatible pointer type [-Werror=incompatible-pointer-types]
3055 | if (drbd_bitmap_io(device, &drbd_bmio_set_susp_al,
| ^~~~~~~~~~~~~~~~~~~~~~
| |
| int (*)(struct drbd_device *)
drivers/block/drbd/drbd_int.h:1073:23: note: expected 'int (*)(struct drbd_device *, struct drbd_peer_device *)' but argument is of type 'int (*)(struct drbd_device *)'
1073 | int (*io_fn)(struct drbd_device *, struct drbd_peer_device *),
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/drbd/drbd_nl.c:3055:29: error: too many arguments to function 'drbd_bitmap_io'
3055 | if (drbd_bitmap_io(device, &drbd_bmio_set_susp_al,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1072:12: note: declared here
1072 | extern int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_nl.c: In function 'drbd_adm_new_c_uuid':
drivers/block/drbd/drbd_nl.c:4152:23: error: too many arguments to function 'drbd_bitmap_io'
4152 | err = drbd_bitmap_io(device, &drbd_bmio_clear_n_write,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1072:12: note: declared here
1072 | extern int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
cc1: some warnings being treated as errors


vim +1055 drivers/block/drbd/drbd_nl.c

b411b3637fa71f Philipp Reisner 2009-09-25 921
a425711c6c9c85 Lee Jones 2021-03-12 922 /*
b411b3637fa71f Philipp Reisner 2009-09-25 923 * drbd_determine_dev_size() - Sets the right device size obeying all constraints
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 924 * @device: DRBD device.
b411b3637fa71f Philipp Reisner 2009-09-25 925 *
b411b3637fa71f Philipp Reisner 2009-09-25 926 * Returns 0 on success, negative return values indicate errors.
b411b3637fa71f Philipp Reisner 2009-09-25 927 * You should call drbd_md_sync() after calling this function.
b411b3637fa71f Philipp Reisner 2009-09-25 928 */
d752b2696072ed Philipp Reisner 2013-06-25 929 enum determine_dev_size
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 930 drbd_determine_dev_size(struct drbd_device *device, enum dds_flags flags, struct resize_parms *rs) __must_hold(local)
b411b3637fa71f Philipp Reisner 2009-09-25 931 {
8011e2490907c2 Lars Ellenberg 2015-06-08 932 struct md_offsets_and_sizes {
8011e2490907c2 Lars Ellenberg 2015-06-08 933 u64 last_agreed_sect;
8011e2490907c2 Lars Ellenberg 2015-06-08 934 u64 md_offset;
8011e2490907c2 Lars Ellenberg 2015-06-08 935 s32 al_offset;
8011e2490907c2 Lars Ellenberg 2015-06-08 936 s32 bm_offset;
8011e2490907c2 Lars Ellenberg 2015-06-08 937 u32 md_size_sect;
8011e2490907c2 Lars Ellenberg 2015-06-08 938
8011e2490907c2 Lars Ellenberg 2015-06-08 939 u32 al_stripes;
8011e2490907c2 Lars Ellenberg 2015-06-08 940 u32 al_stripe_size_4k;
8011e2490907c2 Lars Ellenberg 2015-06-08 941 } prev;
8011e2490907c2 Lars Ellenberg 2015-06-08 942 sector_t u_size, size;
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 943 struct drbd_md *md = &device->ldev->md;
d752b2696072ed Philipp Reisner 2013-06-25 944 void *buffer;
b411b3637fa71f Philipp Reisner 2009-09-25 945
b411b3637fa71f Philipp Reisner 2009-09-25 946 int md_moved, la_size_changed;
e96c96333fe5a4 Philipp Reisner 2013-06-25 947 enum determine_dev_size rv = DS_UNCHANGED;
b411b3637fa71f Philipp Reisner 2009-09-25 948
5f7c01249bea67 Lars Ellenberg 2015-06-08 949 /* We may change the on-disk offsets of our meta data below. Lock out
5f7c01249bea67 Lars Ellenberg 2015-06-08 950 * anything that may cause meta data IO, to avoid acting on incomplete
5f7c01249bea67 Lars Ellenberg 2015-06-08 951 * layout changes or scribbling over meta data that is in the process
5f7c01249bea67 Lars Ellenberg 2015-06-08 952 * of being moved.
b411b3637fa71f Philipp Reisner 2009-09-25 953 *
5f7c01249bea67 Lars Ellenberg 2015-06-08 954 * Move is not exactly correct, btw, currently we have all our meta
5f7c01249bea67 Lars Ellenberg 2015-06-08 955 * data in core memory, to "move" it we just write it all out, there
5f7c01249bea67 Lars Ellenberg 2015-06-08 956 * are no reads. */
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 957 drbd_suspend_io(device);
e37d2438d8e5e4 Lars Ellenberg 2014-04-01 958 buffer = drbd_md_get_buffer(device, __func__); /* Lock meta-data IO */
d752b2696072ed Philipp Reisner 2013-06-25 959 if (!buffer) {
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 960 drbd_resume_io(device);
d752b2696072ed Philipp Reisner 2013-06-25 961 return DS_ERROR;
d752b2696072ed Philipp Reisner 2013-06-25 962 }
b411b3637fa71f Philipp Reisner 2009-09-25 963
8011e2490907c2 Lars Ellenberg 2015-06-08 964 /* remember current offset and sizes */
8011e2490907c2 Lars Ellenberg 2015-06-08 965 prev.last_agreed_sect = md->la_size_sect;
8011e2490907c2 Lars Ellenberg 2015-06-08 966 prev.md_offset = md->md_offset;
8011e2490907c2 Lars Ellenberg 2015-06-08 967 prev.al_offset = md->al_offset;
8011e2490907c2 Lars Ellenberg 2015-06-08 968 prev.bm_offset = md->bm_offset;
8011e2490907c2 Lars Ellenberg 2015-06-08 969 prev.md_size_sect = md->md_size_sect;
8011e2490907c2 Lars Ellenberg 2015-06-08 970 prev.al_stripes = md->al_stripes;
8011e2490907c2 Lars Ellenberg 2015-06-08 971 prev.al_stripe_size_4k = md->al_stripe_size_4k;
b411b3637fa71f Philipp Reisner 2009-09-25 972
d752b2696072ed Philipp Reisner 2013-06-25 973 if (rs) {
d752b2696072ed Philipp Reisner 2013-06-25 974 /* rs is non NULL if we should change the AL layout only */
d752b2696072ed Philipp Reisner 2013-06-25 975 md->al_stripes = rs->al_stripes;
d752b2696072ed Philipp Reisner 2013-06-25 976 md->al_stripe_size_4k = rs->al_stripe_size / 4;
d752b2696072ed Philipp Reisner 2013-06-25 977 md->al_size_4k = (u64)rs->al_stripes * rs->al_stripe_size / 4;
d752b2696072ed Philipp Reisner 2013-06-25 978 }
d752b2696072ed Philipp Reisner 2013-06-25 979
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 980 drbd_md_set_sector_offsets(device, device->ldev);
b411b3637fa71f Philipp Reisner 2009-09-25 981
daeda1cca91d58 Philipp Reisner 2011-05-03 982 rcu_read_lock();
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 983 u_size = rcu_dereference(device->ldev->disk_conf)->disk_size;
daeda1cca91d58 Philipp Reisner 2011-05-03 984 rcu_read_unlock();
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 985 size = drbd_new_dev_size(device, device->ldev, u_size, flags & DDSF_FORCED);
b411b3637fa71f Philipp Reisner 2009-09-25 986
8011e2490907c2 Lars Ellenberg 2015-06-08 987 if (size < prev.last_agreed_sect) {
d752b2696072ed Philipp Reisner 2013-06-25 988 if (rs && u_size == 0) {
d752b2696072ed Philipp Reisner 2013-06-25 989 /* Remove "rs &&" later. This check should always be active, but
d752b2696072ed Philipp Reisner 2013-06-25 990 right now the receiver expects the permissive behavior */
d01801710265cf Andreas Gruenbacher 2011-07-03 991 drbd_warn(device, "Implicit shrink not allowed. "
d752b2696072ed Philipp Reisner 2013-06-25 992 "Use --size=%llus for explicit shrink.\n",
d752b2696072ed Philipp Reisner 2013-06-25 993 (unsigned long long)size);
d752b2696072ed Philipp Reisner 2013-06-25 994 rv = DS_ERROR_SHRINK;
d752b2696072ed Philipp Reisner 2013-06-25 995 }
d752b2696072ed Philipp Reisner 2013-06-25 996 if (u_size > size)
d752b2696072ed Philipp Reisner 2013-06-25 997 rv = DS_ERROR_SPACE_MD;
d752b2696072ed Philipp Reisner 2013-06-25 998 if (rv != DS_UNCHANGED)
d752b2696072ed Philipp Reisner 2013-06-25 999 goto err_out;
d752b2696072ed Philipp Reisner 2013-06-25 1000 }
d752b2696072ed Philipp Reisner 2013-06-25 1001
155bd9d1abd604 Christoph Hellwig 2020-09-25 1002 if (get_capacity(device->vdisk) != size ||
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 1003 drbd_bm_capacity(device) != size) {
b411b3637fa71f Philipp Reisner 2009-09-25 1004 int err;
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 1005 err = drbd_bm_resize(device, size, !(flags & DDSF_NO_RESYNC));
b411b3637fa71f Philipp Reisner 2009-09-25 1006 if (unlikely(err)) {
b411b3637fa71f Philipp Reisner 2009-09-25 1007 /* currently there is only one error: ENOMEM! */
8011e2490907c2 Lars Ellenberg 2015-06-08 1008 size = drbd_bm_capacity(device);
b411b3637fa71f Philipp Reisner 2009-09-25 1009 if (size == 0) {
d01801710265cf Andreas Gruenbacher 2011-07-03 1010 drbd_err(device, "OUT OF MEMORY! "
b411b3637fa71f Philipp Reisner 2009-09-25 1011 "Could not allocate bitmap!\n");
b411b3637fa71f Philipp Reisner 2009-09-25 1012 } else {
d01801710265cf Andreas Gruenbacher 2011-07-03 1013 drbd_err(device, "BM resizing failed. "
8011e2490907c2 Lars Ellenberg 2015-06-08 1014 "Leaving size unchanged\n");
b411b3637fa71f Philipp Reisner 2009-09-25 1015 }
e96c96333fe5a4 Philipp Reisner 2013-06-25 1016 rv = DS_ERROR;
b411b3637fa71f Philipp Reisner 2009-09-25 1017 }
b411b3637fa71f Philipp Reisner 2009-09-25 1018 /* racy, see comments above. */
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 1019 drbd_set_my_capacity(device, size);
8011e2490907c2 Lars Ellenberg 2015-06-08 1020 md->la_size_sect = size;
b411b3637fa71f Philipp Reisner 2009-09-25 1021 }
d752b2696072ed Philipp Reisner 2013-06-25 1022 if (rv <= DS_ERROR)
d752b2696072ed Philipp Reisner 2013-06-25 1023 goto err_out;
b411b3637fa71f Philipp Reisner 2009-09-25 1024
8011e2490907c2 Lars Ellenberg 2015-06-08 1025 la_size_changed = (prev.last_agreed_sect != md->la_size_sect);
b411b3637fa71f Philipp Reisner 2009-09-25 1026
8011e2490907c2 Lars Ellenberg 2015-06-08 1027 md_moved = prev.md_offset != md->md_offset
8011e2490907c2 Lars Ellenberg 2015-06-08 1028 || prev.md_size_sect != md->md_size_sect;
b411b3637fa71f Philipp Reisner 2009-09-25 1029
d752b2696072ed Philipp Reisner 2013-06-25 1030 if (la_size_changed || md_moved || rs) {
d752b2696072ed Philipp Reisner 2013-06-25 1031 u32 prev_flags;
24dccabb390412 Andreas Gruenbacher 2010-12-12 1032
fcb096740a13c8 Lars Ellenberg 2014-01-27 1033 /* We do some synchronous IO below, which may take some time.
fcb096740a13c8 Lars Ellenberg 2014-01-27 1034 * Clear the timer, to avoid scary "timer expired!" messages,
fcb096740a13c8 Lars Ellenberg 2014-01-27 1035 * "Superblock" is written out at least twice below, anyways. */
fcb096740a13c8 Lars Ellenberg 2014-01-27 1036 del_timer(&device->md_sync_timer);
d752b2696072ed Philipp Reisner 2013-06-25 1037
5f7c01249bea67 Lars Ellenberg 2015-06-08 1038 /* We won't change the "al-extents" setting, we just may need
5f7c01249bea67 Lars Ellenberg 2015-06-08 1039 * to move the on-disk location of the activity log ringbuffer.
5f7c01249bea67 Lars Ellenberg 2015-06-08 1040 * Lock for transaction is good enough, it may well be "dirty"
5f7c01249bea67 Lars Ellenberg 2015-06-08 1041 * or even "starving". */
5f7c01249bea67 Lars Ellenberg 2015-06-08 1042 wait_event(device->al_wait, lc_try_lock_for_transaction(device->act_log));
5f7c01249bea67 Lars Ellenberg 2015-06-08 1043
5f7c01249bea67 Lars Ellenberg 2015-06-08 1044 /* mark current on-disk bitmap and activity log as unreliable */
d752b2696072ed Philipp Reisner 2013-06-25 1045 prev_flags = md->flags;
5f7c01249bea67 Lars Ellenberg 2015-06-08 1046 md->flags |= MDF_FULL_SYNC | MDF_AL_DISABLED;
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 1047 drbd_md_write(device, buffer);
d752b2696072ed Philipp Reisner 2013-06-25 1048
5f7c01249bea67 Lars Ellenberg 2015-06-08 1049 drbd_al_initialize(device, buffer);
5f7c01249bea67 Lars Ellenberg 2015-06-08 1050
d01801710265cf Andreas Gruenbacher 2011-07-03 1051 drbd_info(device, "Writing the whole bitmap, %s\n",
b411b3637fa71f Philipp Reisner 2009-09-25 1052 la_size_changed && md_moved ? "size changed and md moved" :
b411b3637fa71f Philipp Reisner 2009-09-25 1053 la_size_changed ? "size changed" : "md moved");
20ceb2b22edaf5 Lars Ellenberg 2011-01-21 1054 /* next line implicitly does drbd_suspend_io()+drbd_resume_io() */
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 @1055 drbd_bitmap_io(device, md_moved ? &drbd_bm_write_all : &drbd_bm_write,
e55221e8a69f80 Andreas Gruenbacher 2023-02-15 1056 "size changed", BM_LOCKED_MASK, NULL);
d752b2696072ed Philipp Reisner 2013-06-25 1057
5f7c01249bea67 Lars Ellenberg 2015-06-08 1058 /* on-disk bitmap and activity log is authoritative again
5f7c01249bea67 Lars Ellenberg 2015-06-08 1059 * (unless there was an IO error meanwhile...) */
d752b2696072ed Philipp Reisner 2013-06-25 1060 md->flags = prev_flags;
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 1061 drbd_md_write(device, buffer);
d752b2696072ed Philipp Reisner 2013-06-25 1062
d752b2696072ed Philipp Reisner 2013-06-25 1063 if (rs)
d01801710265cf Andreas Gruenbacher 2011-07-03 1064 drbd_info(device, "Changed AL layout to al-stripes = %d, al-stripe-size-kB = %d\n",
d752b2696072ed Philipp Reisner 2013-06-25 1065 md->al_stripes, md->al_stripe_size_4k * 4);
b411b3637fa71f Philipp Reisner 2009-09-25 1066 }
b411b3637fa71f Philipp Reisner 2009-09-25 1067
8011e2490907c2 Lars Ellenberg 2015-06-08 1068 if (size > prev.last_agreed_sect)
8011e2490907c2 Lars Ellenberg 2015-06-08 1069 rv = prev.last_agreed_sect ? DS_GREW : DS_GREW_FROM_ZERO;
8011e2490907c2 Lars Ellenberg 2015-06-08 1070 if (size < prev.last_agreed_sect)
e96c96333fe5a4 Philipp Reisner 2013-06-25 1071 rv = DS_SHRUNK;
d752b2696072ed Philipp Reisner 2013-06-25 1072
d752b2696072ed Philipp Reisner 2013-06-25 1073 if (0) {
d752b2696072ed Philipp Reisner 2013-06-25 1074 err_out:
8011e2490907c2 Lars Ellenberg 2015-06-08 1075 /* restore previous offset and sizes */
8011e2490907c2 Lars Ellenberg 2015-06-08 1076 md->la_size_sect = prev.last_agreed_sect;
8011e2490907c2 Lars Ellenberg 2015-06-08 1077 md->md_offset = prev.md_offset;
8011e2490907c2 Lars Ellenberg 2015-06-08 1078 md->al_offset = prev.al_offset;
8011e2490907c2 Lars Ellenberg 2015-06-08 1079 md->bm_offset = prev.bm_offset;
8011e2490907c2 Lars Ellenberg 2015-06-08 1080 md->md_size_sect = prev.md_size_sect;
8011e2490907c2 Lars Ellenberg 2015-06-08 1081 md->al_stripes = prev.al_stripes;
8011e2490907c2 Lars Ellenberg 2015-06-08 1082 md->al_stripe_size_4k = prev.al_stripe_size_4k;
8011e2490907c2 Lars Ellenberg 2015-06-08 1083 md->al_size_4k = (u64)prev.al_stripes * prev.al_stripe_size_4k;
d752b2696072ed Philipp Reisner 2013-06-25 1084 }
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 1085 lc_unlock(device->act_log);
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 1086 wake_up(&device->al_wait);
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 1087 drbd_md_put_buffer(device);
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 1088 drbd_resume_io(device);
b411b3637fa71f Philipp Reisner 2009-09-25 1089
b411b3637fa71f Philipp Reisner 2009-09-25 1090 return rv;
b411b3637fa71f Philipp Reisner 2009-09-25 1091 }
b411b3637fa71f Philipp Reisner 2009-09-25 1092

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

2023-02-15 20:39:19

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/7] drbd: Add peer device parameter to whole-bitmap I/O handlers

Hi Christoph,

I love your patch! Yet something to improve:

[auto build test ERROR on a06377c5d01eeeaa52ad979b62c3c72efcc3eff0]

url: https://github.com/intel-lab-lkp/linux/commits/Christoph-B-hmwalder/drbd-Rip-out-the-ERR_IF_CNT_IS_NEGATIVE-macro/20230216-003454
base: a06377c5d01eeeaa52ad979b62c3c72efcc3eff0
patch link: https://lore.kernel.org/r/20230215163204.2856631-3-christoph.boehmwalder%40linbit.com
patch subject: [PATCH 2/7] drbd: Add peer device parameter to whole-bitmap I/O handlers
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230216/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/e55221e8a69f80303803dab7e079bff7b698ea02
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Christoph-B-hmwalder/drbd-Rip-out-the-ERR_IF_CNT_IS_NEGATIVE-macro/20230216-003454
git checkout e55221e8a69f80303803dab7e079bff7b698ea02
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/block/drbd/drbd_receiver.c: In function 'drbd_sync_handshake':
>> drivers/block/drbd/drbd_receiver.c:3593:21: error: too many arguments to function 'drbd_bitmap_io'
3593 | if (drbd_bitmap_io(device, &drbd_bmio_set_n_write, "set_n_write from sync_handshake",
| ^~~~~~~~~~~~~~
In file included from drivers/block/drbd/drbd_receiver.c:37:
drivers/block/drbd/drbd_int.h:1072:12: note: declared here
1072 | extern int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_receiver.c: In function 'receive_uuids':
drivers/block/drbd/drbd_receiver.c:4271:25: error: too many arguments to function 'drbd_bitmap_io'
4271 | drbd_bitmap_io(device, &drbd_bmio_clear_n_write,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1072:12: note: declared here
1072 | extern int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_receiver.c: In function 'receive_bitmap':
>> drivers/block/drbd/drbd_receiver.c:4880:23: error: too few arguments to function 'drbd_send_bitmap'
4880 | err = drbd_send_bitmap(device);
| ^~~~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1045:12: note: declared here
1045 | extern int drbd_send_bitmap(struct drbd_device *device, struct drbd_peer_device *peer_device);
| ^~~~~~~~~~~~~~~~
drivers/block/drbd/drbd_receiver.c: In function 'drbd_disconnected':
>> drivers/block/drbd/drbd_receiver.c:5216:40: error: passing argument 2 of 'drbd_bitmap_io' from incompatible pointer type [-Werror=incompatible-pointer-types]
5216 | drbd_bitmap_io(device, &drbd_bm_write_copy_pages,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| |
| int (*)(struct drbd_device *)
drivers/block/drbd/drbd_int.h:1073:23: note: expected 'int (*)(struct drbd_device *, struct drbd_peer_device *)' but argument is of type 'int (*)(struct drbd_device *)'
1073 | int (*io_fn)(struct drbd_device *, struct drbd_peer_device *),
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/drbd/drbd_receiver.c:5216:17: error: too many arguments to function 'drbd_bitmap_io'
5216 | drbd_bitmap_io(device, &drbd_bm_write_copy_pages,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1072:12: note: declared here
1072 | extern int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
drivers/block/drbd/drbd_main.c: In function 'send_bitmap_rle_or_plain':
>> drivers/block/drbd/drbd_main.c:1203:29: error: 'device' redeclared as different kind of symbol
1203 | struct drbd_device *device = peer_device->device;
| ^~~~~~
drivers/block/drbd/drbd_main.c:1201:51: note: previous definition of 'device' with type 'struct drbd_peer_device *'
1201 | send_bitmap_rle_or_plain(struct drbd_peer_device *device, struct bm_xfer_ctx *c)
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
>> drivers/block/drbd/drbd_main.c:1203:38: error: 'peer_device' undeclared (first use in this function); did you mean 'phy_device'?
1203 | struct drbd_device *device = peer_device->device;
| ^~~~~~~~~~~
| phy_device
drivers/block/drbd/drbd_main.c:1203:38: note: each undeclared identifier is reported only once for each function it appears in
drivers/block/drbd/drbd_main.c: In function '_drbd_send_bitmap':
>> drivers/block/drbd/drbd_main.c:1272:29: error: too few arguments to function 'drbd_bm_write'
1272 | if (drbd_bm_write(device)) {
| ^~~~~~~~~~~~~
In file included from drivers/block/drbd/drbd_main.c:46:
drivers/block/drbd/drbd_int.h:1293:13: note: declared here
1293 | extern int drbd_bm_write(struct drbd_device *device,
| ^~~~~~~~~~~~~
drivers/block/drbd/drbd_main.c: At top level:
>> drivers/block/drbd/drbd_main.c:3497:6: error: conflicting types for 'drbd_queue_bitmap_io'; have 'void(struct drbd_device *, int (*)(struct drbd_device *, struct drbd_peer_device *), void (*)(struct drbd_device *, int), char *, enum bm_flag, struct drbd_peer_device *)'
3497 | void drbd_queue_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1068:13: note: previous declaration of 'drbd_queue_bitmap_io' with type 'void(struct drbd_device *, int (*)(struct drbd_device *, struct drbd_peer_device *), void (*)(struct drbd_device *, int), char *, enum bm_flag)'
1068 | extern void drbd_queue_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~~~~~~~
>> drivers/block/drbd/drbd_main.c:3540:5: error: conflicting types for 'drbd_bitmap_io'; have 'int(struct drbd_device *, int (*)(struct drbd_device *, struct drbd_peer_device *), char *, enum bm_flag, struct drbd_peer_device *)'
3540 | int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1072:12: note: previous declaration of 'drbd_bitmap_io' with type 'int(struct drbd_device *, int (*)(struct drbd_device *, struct drbd_peer_device *), char *, enum bm_flag)'
1072 | extern int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
--
In file included from include/linux/drbd_genl_api.h:54,
from drivers/block/drbd/drbd_int.h:35,
from drivers/block/drbd/drbd_nl.c:24:
include/linux/drbd_genl_api.h:51:33: warning: no previous prototype for 'drbd_genl_cmd_to_str' [-Wmissing-prototypes]
51 | #define GENL_MAGIC_FAMILY drbd
| ^~~~
include/linux/genl_magic_struct.h:20:25: note: in definition of macro 'CONCAT__'
20 | #define CONCAT__(a,b) a ## b
| ^
include/linux/genl_magic_func.h:212:13: note: in expansion of macro 'CONCAT_'
212 | const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
| ^~~~~~~
include/linux/genl_magic_func.h:212:21: note: in expansion of macro 'GENL_MAGIC_FAMILY'
212 | const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
| ^~~~~~~~~~~~~~~~~
drivers/block/drbd/drbd_nl.c: In function 'drbd_determine_dev_size':
drivers/block/drbd/drbd_nl.c:1055:70: warning: pointer type mismatch in conditional expression
1055 | drbd_bitmap_io(device, md_moved ? &drbd_bm_write_all : &drbd_bm_write,
| ^
>> drivers/block/drbd/drbd_nl.c:1055:17: error: too many arguments to function 'drbd_bitmap_io'
1055 | drbd_bitmap_io(device, md_moved ? &drbd_bm_write_all : &drbd_bm_write,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1072:12: note: declared here
1072 | extern int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_nl.c: In function 'drbd_adm_attach':
drivers/block/drbd/drbd_nl.c:2029:21: error: too many arguments to function 'drbd_bitmap_io'
2029 | if (drbd_bitmap_io(device, &drbd_bmio_set_n_write,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1072:12: note: declared here
1072 | extern int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_nl.c:2036:21: error: too many arguments to function 'drbd_bitmap_io'
2036 | if (drbd_bitmap_io(device, &drbd_bm_read,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1072:12: note: declared here
1072 | extern int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_nl.c: In function 'drbd_adm_invalidate':
drivers/block/drbd/drbd_nl.c:2976:29: error: too many arguments to function 'drbd_bitmap_io'
2976 | if (drbd_bitmap_io(device, &drbd_bmio_set_n_write,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1072:12: note: declared here
1072 | extern int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_nl.c: In function 'drbd_bmio_set_susp_al':
>> drivers/block/drbd/drbd_nl.c:3014:14: error: too few arguments to function 'drbd_bmio_set_n_write'
3014 | rv = drbd_bmio_set_n_write(device);
| ^~~~~~~~~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1078:12: note: declared here
1078 | extern int drbd_bmio_set_n_write(struct drbd_device *device,
| ^~~~~~~~~~~~~~~~~~~~~
drivers/block/drbd/drbd_nl.c: In function 'drbd_adm_invalidate_peer':
>> drivers/block/drbd/drbd_nl.c:3055:52: error: passing argument 2 of 'drbd_bitmap_io' from incompatible pointer type [-Werror=incompatible-pointer-types]
3055 | if (drbd_bitmap_io(device, &drbd_bmio_set_susp_al,
| ^~~~~~~~~~~~~~~~~~~~~~
| |
| int (*)(struct drbd_device *)
drivers/block/drbd/drbd_int.h:1073:23: note: expected 'int (*)(struct drbd_device *, struct drbd_peer_device *)' but argument is of type 'int (*)(struct drbd_device *)'
1073 | int (*io_fn)(struct drbd_device *, struct drbd_peer_device *),
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/drbd/drbd_nl.c:3055:29: error: too many arguments to function 'drbd_bitmap_io'
3055 | if (drbd_bitmap_io(device, &drbd_bmio_set_susp_al,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1072:12: note: declared here
1072 | extern int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_nl.c: In function 'drbd_adm_new_c_uuid':
drivers/block/drbd/drbd_nl.c:4152:23: error: too many arguments to function 'drbd_bitmap_io'
4152 | err = drbd_bitmap_io(device, &drbd_bmio_clear_n_write,
| ^~~~~~~~~~~~~~
drivers/block/drbd/drbd_int.h:1072:12: note: declared here
1072 | extern int drbd_bitmap_io(struct drbd_device *device,
| ^~~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
>> drivers/block/drbd/drbd_state.c:1520:5: error: conflicting types for 'drbd_bitmap_io_from_worker'; have 'int(struct drbd_device *, int (*)(struct drbd_device *, struct drbd_peer_device *), char *, enum bm_flag, struct drbd_peer_device *)'
1520 | int drbd_bitmap_io_from_worker(struct drbd_device *device,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/block/drbd/drbd_state.c:17:
drivers/block/drbd/drbd_int.h:1075:12: note: previous declaration of 'drbd_bitmap_io_from_worker' with type 'int(struct drbd_device *, int (*)(struct drbd_device *, struct drbd_peer_device *), char *, enum bm_flag)'
1075 | extern int drbd_bitmap_io_from_worker(struct drbd_device *device,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/drbd/drbd_state.c: In function 'after_state_ch':
>> drivers/block/drbd/drbd_state.c:1842:25: error: too few arguments to function 'drbd_bitmap_io_from_worker'
1842 | drbd_bitmap_io_from_worker(device, &drbd_bm_write,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/drbd/drbd_state.c:1520:5: note: declared here
1520 | int drbd_bitmap_io_from_worker(struct drbd_device *device,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/drbd/drbd_state.c:1854:17: error: too few arguments to function 'drbd_bitmap_io_from_worker'
1854 | drbd_bitmap_io_from_worker(device, &drbd_bm_write,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/drbd/drbd_state.c:1520:5: note: declared here
1520 | int drbd_bitmap_io_from_worker(struct drbd_device *device,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/block/drbd/drbd_state.c:2014:46: error: passing argument 2 of 'drbd_queue_bitmap_io' from incompatible pointer type [-Werror=incompatible-pointer-types]
2014 | drbd_queue_bitmap_io(device, &drbd_bm_write_copy_pages, NULL,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| |
| int (*)(struct drbd_device *)
drivers/block/drbd/drbd_int.h:1069:40: note: expected 'int (*)(struct drbd_device *, struct drbd_peer_device *)' but argument is of type 'int (*)(struct drbd_device *)'
1069 | int (*io_fn)(struct drbd_device *, struct drbd_peer_device *),
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors


vim +/drbd_bitmap_io +3593 drivers/block/drbd/drbd_receiver.c

b411b3637fa71f Philipp Reisner 2009-09-25 3443
b411b3637fa71f Philipp Reisner 2009-09-25 3444 /* drbd_sync_handshake() returns the new conn state on success, or
b411b3637fa71f Philipp Reisner 2009-09-25 3445 CONN_MASK (-1) on failure.
b411b3637fa71f Philipp Reisner 2009-09-25 3446 */
69a227731a378f Andreas Gruenbacher 2011-08-09 3447 static enum drbd_conns drbd_sync_handshake(struct drbd_peer_device *peer_device,
69a227731a378f Andreas Gruenbacher 2011-08-09 3448 enum drbd_role peer_role,
b411b3637fa71f Philipp Reisner 2009-09-25 3449 enum drbd_disk_state peer_disk) __must_hold(local)
b411b3637fa71f Philipp Reisner 2009-09-25 3450 {
69a227731a378f Andreas Gruenbacher 2011-08-09 3451 struct drbd_device *device = peer_device->device;
b411b3637fa71f Philipp Reisner 2009-09-25 3452 enum drbd_conns rv = C_MASK;
b411b3637fa71f Philipp Reisner 2009-09-25 3453 enum drbd_disk_state mydisk;
44ed167da74825 Philipp Reisner 2011-04-19 3454 struct net_conf *nc;
d29e89e34952a9 Roland Kammerer 2018-12-20 3455 int hg, rule_nr, rr_conflict, tentative, always_asbp;
b411b3637fa71f Philipp Reisner 2009-09-25 3456
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 3457 mydisk = device->state.disk;
b411b3637fa71f Philipp Reisner 2009-09-25 3458 if (mydisk == D_NEGOTIATING)
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 3459 mydisk = device->new_state_tmp.disk;
b411b3637fa71f Philipp Reisner 2009-09-25 3460
d01801710265cf Andreas Gruenbacher 2011-07-03 3461 drbd_info(device, "drbd_sync_handshake:\n");
9f2247bb9b75b2 Philipp Reisner 2012-08-16 3462
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 3463 spin_lock_irq(&device->ldev->md.uuid_lock);
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 3464 drbd_uuid_dump(device, "self", device->ldev->md.uuid, device->comm_bm_set, 0);
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 3465 drbd_uuid_dump(device, "peer", device->p_uuid,
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 3466 device->p_uuid[UI_SIZE], device->p_uuid[UI_FLAGS]);
b411b3637fa71f Philipp Reisner 2009-09-25 3467
f2d3d75b66fc80 Lars Ellenberg 2016-06-14 3468 hg = drbd_uuid_compare(device, peer_role, &rule_nr);
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 3469 spin_unlock_irq(&device->ldev->md.uuid_lock);
b411b3637fa71f Philipp Reisner 2009-09-25 3470
d01801710265cf Andreas Gruenbacher 2011-07-03 3471 drbd_info(device, "uuid_compare()=%d by rule %d\n", hg, rule_nr);
b411b3637fa71f Philipp Reisner 2009-09-25 3472
b411b3637fa71f Philipp Reisner 2009-09-25 3473 if (hg == -1000) {
d01801710265cf Andreas Gruenbacher 2011-07-03 3474 drbd_alert(device, "Unrelated data, aborting!\n");
b411b3637fa71f Philipp Reisner 2009-09-25 3475 return C_MASK;
b411b3637fa71f Philipp Reisner 2009-09-25 3476 }
f2d3d75b66fc80 Lars Ellenberg 2016-06-14 3477 if (hg < -0x10000) {
f2d3d75b66fc80 Lars Ellenberg 2016-06-14 3478 int proto, fflags;
f2d3d75b66fc80 Lars Ellenberg 2016-06-14 3479 hg = -hg;
f2d3d75b66fc80 Lars Ellenberg 2016-06-14 3480 proto = hg & 0xff;
f2d3d75b66fc80 Lars Ellenberg 2016-06-14 3481 fflags = (hg >> 8) & 0xff;
f2d3d75b66fc80 Lars Ellenberg 2016-06-14 3482 drbd_alert(device, "To resolve this both sides have to support at least protocol %d and feature flags 0x%x\n",
f2d3d75b66fc80 Lars Ellenberg 2016-06-14 3483 proto, fflags);
f2d3d75b66fc80 Lars Ellenberg 2016-06-14 3484 return C_MASK;
f2d3d75b66fc80 Lars Ellenberg 2016-06-14 3485 }
4a23f264969827 Philipp Reisner 2011-01-11 3486 if (hg < -1000) {
d01801710265cf Andreas Gruenbacher 2011-07-03 3487 drbd_alert(device, "To resolve this both sides have to support at least protocol %d\n", -hg - 1000);
b411b3637fa71f Philipp Reisner 2009-09-25 3488 return C_MASK;
b411b3637fa71f Philipp Reisner 2009-09-25 3489 }
b411b3637fa71f Philipp Reisner 2009-09-25 3490
b411b3637fa71f Philipp Reisner 2009-09-25 3491 if ((mydisk == D_INCONSISTENT && peer_disk > D_INCONSISTENT) ||
b411b3637fa71f Philipp Reisner 2009-09-25 3492 (peer_disk == D_INCONSISTENT && mydisk > D_INCONSISTENT)) {
b411b3637fa71f Philipp Reisner 2009-09-25 3493 int f = (hg == -100) || abs(hg) == 2;
b411b3637fa71f Philipp Reisner 2009-09-25 3494 hg = mydisk > D_INCONSISTENT ? 1 : -1;
b411b3637fa71f Philipp Reisner 2009-09-25 3495 if (f)
b411b3637fa71f Philipp Reisner 2009-09-25 3496 hg = hg*2;
d01801710265cf Andreas Gruenbacher 2011-07-03 3497 drbd_info(device, "Becoming sync %s due to disk states.\n",
b411b3637fa71f Philipp Reisner 2009-09-25 3498 hg > 0 ? "source" : "target");
b411b3637fa71f Philipp Reisner 2009-09-25 3499 }
b411b3637fa71f Philipp Reisner 2009-09-25 3500
3a11a4878939e0 Adam Gandelman 2010-04-08 3501 if (abs(hg) == 100)
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 3502 drbd_khelper(device, "initial-split-brain");
3a11a4878939e0 Adam Gandelman 2010-04-08 3503
44ed167da74825 Philipp Reisner 2011-04-19 3504 rcu_read_lock();
69a227731a378f Andreas Gruenbacher 2011-08-09 3505 nc = rcu_dereference(peer_device->connection->net_conf);
d29e89e34952a9 Roland Kammerer 2018-12-20 3506 always_asbp = nc->always_asbp;
d29e89e34952a9 Roland Kammerer 2018-12-20 3507 rr_conflict = nc->rr_conflict;
d29e89e34952a9 Roland Kammerer 2018-12-20 3508 tentative = nc->tentative;
d29e89e34952a9 Roland Kammerer 2018-12-20 3509 rcu_read_unlock();
44ed167da74825 Philipp Reisner 2011-04-19 3510
d29e89e34952a9 Roland Kammerer 2018-12-20 3511 if (hg == 100 || (hg == -100 && always_asbp)) {
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 3512 int pcount = (device->state.role == R_PRIMARY)
b411b3637fa71f Philipp Reisner 2009-09-25 3513 + (peer_role == R_PRIMARY);
b411b3637fa71f Philipp Reisner 2009-09-25 3514 int forced = (hg == -100);
b411b3637fa71f Philipp Reisner 2009-09-25 3515
b411b3637fa71f Philipp Reisner 2009-09-25 3516 switch (pcount) {
b411b3637fa71f Philipp Reisner 2009-09-25 3517 case 0:
69a227731a378f Andreas Gruenbacher 2011-08-09 3518 hg = drbd_asb_recover_0p(peer_device);
b411b3637fa71f Philipp Reisner 2009-09-25 3519 break;
b411b3637fa71f Philipp Reisner 2009-09-25 3520 case 1:
69a227731a378f Andreas Gruenbacher 2011-08-09 3521 hg = drbd_asb_recover_1p(peer_device);
b411b3637fa71f Philipp Reisner 2009-09-25 3522 break;
b411b3637fa71f Philipp Reisner 2009-09-25 3523 case 2:
69a227731a378f Andreas Gruenbacher 2011-08-09 3524 hg = drbd_asb_recover_2p(peer_device);
b411b3637fa71f Philipp Reisner 2009-09-25 3525 break;
b411b3637fa71f Philipp Reisner 2009-09-25 3526 }
b411b3637fa71f Philipp Reisner 2009-09-25 3527 if (abs(hg) < 100) {
d01801710265cf Andreas Gruenbacher 2011-07-03 3528 drbd_warn(device, "Split-Brain detected, %d primaries, "
b411b3637fa71f Philipp Reisner 2009-09-25 3529 "automatically solved. Sync from %s node\n",
b411b3637fa71f Philipp Reisner 2009-09-25 3530 pcount, (hg < 0) ? "peer" : "this");
b411b3637fa71f Philipp Reisner 2009-09-25 3531 if (forced) {
d01801710265cf Andreas Gruenbacher 2011-07-03 3532 drbd_warn(device, "Doing a full sync, since"
b411b3637fa71f Philipp Reisner 2009-09-25 3533 " UUIDs where ambiguous.\n");
b411b3637fa71f Philipp Reisner 2009-09-25 3534 hg = hg*2;
b411b3637fa71f Philipp Reisner 2009-09-25 3535 }
b411b3637fa71f Philipp Reisner 2009-09-25 3536 }
b411b3637fa71f Philipp Reisner 2009-09-25 3537 }
b411b3637fa71f Philipp Reisner 2009-09-25 3538
b411b3637fa71f Philipp Reisner 2009-09-25 3539 if (hg == -100) {
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 3540 if (test_bit(DISCARD_MY_DATA, &device->flags) && !(device->p_uuid[UI_FLAGS]&1))
b411b3637fa71f Philipp Reisner 2009-09-25 3541 hg = -1;
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 3542 if (!test_bit(DISCARD_MY_DATA, &device->flags) && (device->p_uuid[UI_FLAGS]&1))
b411b3637fa71f Philipp Reisner 2009-09-25 3543 hg = 1;
b411b3637fa71f Philipp Reisner 2009-09-25 3544
b411b3637fa71f Philipp Reisner 2009-09-25 3545 if (abs(hg) < 100)
d01801710265cf Andreas Gruenbacher 2011-07-03 3546 drbd_warn(device, "Split-Brain detected, manually solved. "
b411b3637fa71f Philipp Reisner 2009-09-25 3547 "Sync from %s node\n",
b411b3637fa71f Philipp Reisner 2009-09-25 3548 (hg < 0) ? "peer" : "this");
b411b3637fa71f Philipp Reisner 2009-09-25 3549 }
b411b3637fa71f Philipp Reisner 2009-09-25 3550
b411b3637fa71f Philipp Reisner 2009-09-25 3551 if (hg == -100) {
580b9767dbdf2c Lars Ellenberg 2010-02-26 3552 /* FIXME this log message is not correct if we end up here
580b9767dbdf2c Lars Ellenberg 2010-02-26 3553 * after an attempted attach on a diskless node.
580b9767dbdf2c Lars Ellenberg 2010-02-26 3554 * We just refuse to attach -- well, we drop the "connection"
580b9767dbdf2c Lars Ellenberg 2010-02-26 3555 * to that disk, in a way... */
d01801710265cf Andreas Gruenbacher 2011-07-03 3556 drbd_alert(device, "Split-Brain detected but unresolved, dropping connection!\n");
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 3557 drbd_khelper(device, "split-brain");
b411b3637fa71f Philipp Reisner 2009-09-25 3558 return C_MASK;
b411b3637fa71f Philipp Reisner 2009-09-25 3559 }
b411b3637fa71f Philipp Reisner 2009-09-25 3560
b411b3637fa71f Philipp Reisner 2009-09-25 3561 if (hg > 0 && mydisk <= D_INCONSISTENT) {
d01801710265cf Andreas Gruenbacher 2011-07-03 3562 drbd_err(device, "I shall become SyncSource, but I am inconsistent!\n");
b411b3637fa71f Philipp Reisner 2009-09-25 3563 return C_MASK;
b411b3637fa71f Philipp Reisner 2009-09-25 3564 }
b411b3637fa71f Philipp Reisner 2009-09-25 3565
b411b3637fa71f Philipp Reisner 2009-09-25 3566 if (hg < 0 && /* by intention we do not use mydisk here. */
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 3567 device->state.role == R_PRIMARY && device->state.disk >= D_CONSISTENT) {
44ed167da74825 Philipp Reisner 2011-04-19 3568 switch (rr_conflict) {
b411b3637fa71f Philipp Reisner 2009-09-25 3569 case ASB_CALL_HELPER:
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 3570 drbd_khelper(device, "pri-lost");
df561f6688fef7 Gustavo A. R. Silva 2020-08-23 3571 fallthrough;
b411b3637fa71f Philipp Reisner 2009-09-25 3572 case ASB_DISCONNECT:
d01801710265cf Andreas Gruenbacher 2011-07-03 3573 drbd_err(device, "I shall become SyncTarget, but I am primary!\n");
b411b3637fa71f Philipp Reisner 2009-09-25 3574 return C_MASK;
b411b3637fa71f Philipp Reisner 2009-09-25 3575 case ASB_VIOLENTLY:
d01801710265cf Andreas Gruenbacher 2011-07-03 3576 drbd_warn(device, "Becoming SyncTarget, violating the stable-data"
b411b3637fa71f Philipp Reisner 2009-09-25 3577 "assumption\n");
b411b3637fa71f Philipp Reisner 2009-09-25 3578 }
b411b3637fa71f Philipp Reisner 2009-09-25 3579 }
b411b3637fa71f Philipp Reisner 2009-09-25 3580
69a227731a378f Andreas Gruenbacher 2011-08-09 3581 if (tentative || test_bit(CONN_DRY_RUN, &peer_device->connection->flags)) {
cf14c2e987ba0a Philipp Reisner 2010-02-02 3582 if (hg == 0)
d01801710265cf Andreas Gruenbacher 2011-07-03 3583 drbd_info(device, "dry-run connect: No resync, would become Connected immediately.\n");
cf14c2e987ba0a Philipp Reisner 2010-02-02 3584 else
d01801710265cf Andreas Gruenbacher 2011-07-03 3585 drbd_info(device, "dry-run connect: Would become %s, doing a %s resync.",
cf14c2e987ba0a Philipp Reisner 2010-02-02 3586 drbd_conn_str(hg > 0 ? C_SYNC_SOURCE : C_SYNC_TARGET),
cf14c2e987ba0a Philipp Reisner 2010-02-02 3587 abs(hg) >= 2 ? "full" : "bit-map based");
cf14c2e987ba0a Philipp Reisner 2010-02-02 3588 return C_MASK;
cf14c2e987ba0a Philipp Reisner 2010-02-02 3589 }
cf14c2e987ba0a Philipp Reisner 2010-02-02 3590
b411b3637fa71f Philipp Reisner 2009-09-25 3591 if (abs(hg) >= 2) {
d01801710265cf Andreas Gruenbacher 2011-07-03 3592 drbd_info(device, "Writing the whole bitmap, full sync required after drbd_sync_handshake.\n");
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 @3593 if (drbd_bitmap_io(device, &drbd_bmio_set_n_write, "set_n_write from sync_handshake",
e55221e8a69f80 Andreas Gruenbacher 2023-02-15 3594 BM_LOCKED_SET_ALLOWED, NULL))
b411b3637fa71f Philipp Reisner 2009-09-25 3595 return C_MASK;
b411b3637fa71f Philipp Reisner 2009-09-25 3596 }
b411b3637fa71f Philipp Reisner 2009-09-25 3597
b411b3637fa71f Philipp Reisner 2009-09-25 3598 if (hg > 0) { /* become sync source. */
b411b3637fa71f Philipp Reisner 2009-09-25 3599 rv = C_WF_BITMAP_S;
b411b3637fa71f Philipp Reisner 2009-09-25 3600 } else if (hg < 0) { /* become sync target */
b411b3637fa71f Philipp Reisner 2009-09-25 3601 rv = C_WF_BITMAP_T;
b411b3637fa71f Philipp Reisner 2009-09-25 3602 } else {
b411b3637fa71f Philipp Reisner 2009-09-25 3603 rv = C_CONNECTED;
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 3604 if (drbd_bm_total_weight(device)) {
d01801710265cf Andreas Gruenbacher 2011-07-03 3605 drbd_info(device, "No resync, but %lu bits in bitmap!\n",
b30ab7913b0a7b Andreas Gruenbacher 2011-07-03 3606 drbd_bm_total_weight(device));
b411b3637fa71f Philipp Reisner 2009-09-25 3607 }
b411b3637fa71f Philipp Reisner 2009-09-25 3608 }
b411b3637fa71f Philipp Reisner 2009-09-25 3609
b411b3637fa71f Philipp Reisner 2009-09-25 3610 return rv;
b411b3637fa71f Philipp Reisner 2009-09-25 3611 }
b411b3637fa71f Philipp Reisner 2009-09-25 3612

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests