Skip to content

Commit

Permalink
drbd: Call drbd_md_sync() explicitly after a state change on the conn…
Browse files Browse the repository at this point in the history
…ection

Without this, the meta-data gets updates after 5 seconds by the
md_sync_timer. Better to do it immeditaly after a state change.

If the asender detects a network failure, it may take a bit until
the worker processes the according after-conn-state-change work item.

  The worker might be blocked in sending something, i.e. it
  takes until it gets into its timeout. That is 6 seconds by
  default which is longer than the 5 seconds of the md_sync_timer.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
  • Loading branch information
Philipp Reisner committed Nov 9, 2012
1 parent d764401 commit 19fffd7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions drivers/block/drbd/drbd_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@ extern void drbd_free_bc(struct drbd_backing_dev *ldev);
extern void drbd_mdev_cleanup(struct drbd_conf *mdev);
void drbd_print_uuids(struct drbd_conf *mdev, const char *text);

extern void conn_md_sync(struct drbd_tconn *tconn);
extern void drbd_md_sync(struct drbd_conf *mdev);
extern int drbd_md_read(struct drbd_conf *mdev, struct drbd_backing_dev *bdev);
extern void drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local);
Expand Down
16 changes: 16 additions & 0 deletions drivers/block/drbd/drbd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2820,6 +2820,22 @@ void drbd_free_sock(struct drbd_tconn *tconn)

/* meta data management */

void conn_md_sync(struct drbd_tconn *tconn)
{
struct drbd_conf *mdev;
int vnr;

rcu_read_lock();
idr_for_each_entry(&tconn->volumes, mdev, vnr) {
kref_get(&mdev->kref);
rcu_read_unlock();
drbd_md_sync(mdev);
kref_put(&mdev->kref, &drbd_minor_destroy);
rcu_read_lock();
}
rcu_read_unlock();
}

struct meta_data_on_disk {
u64 la_size; /* last agreed size. */
u64 uuid[UI_SIZE]; /* UUIDs. */
Expand Down
16 changes: 0 additions & 16 deletions drivers/block/drbd/drbd_nl.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,22 +363,6 @@ int drbd_khelper(struct drbd_conf *mdev, char *cmd)
return ret;
}

static void conn_md_sync(struct drbd_tconn *tconn)
{
struct drbd_conf *mdev;
int vnr;

rcu_read_lock();
idr_for_each_entry(&tconn->volumes, mdev, vnr) {
kref_get(&mdev->kref);
rcu_read_unlock();
drbd_md_sync(mdev);
kref_put(&mdev->kref, &drbd_minor_destroy);
rcu_read_lock();
}
rcu_read_unlock();
}

int conn_khelper(struct drbd_tconn *tconn, char *cmd)
{
char *envp[] = { "HOME=/",
Expand Down
1 change: 1 addition & 0 deletions drivers/block/drbd/drbd_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -5390,6 +5390,7 @@ int drbd_asender(struct drbd_thread *thi)
if (0) {
reconnect:
conn_request_state(tconn, NS(conn, C_NETWORK_FAILURE), CS_HARD);
conn_md_sync(tconn);
}
if (0) {
disconnect:
Expand Down
3 changes: 3 additions & 0 deletions drivers/block/drbd/drbd_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,9 @@ static int w_after_conn_state_ch(struct drbd_work *w, int unused)
}
}
kref_put(&tconn->kref, &conn_destroy);

conn_md_sync(tconn);

return 0;
}

Expand Down

0 comments on commit 19fffd7

Please sign in to comment.