diff options
author | Lars Ellenberg <lars.ellenberg@linbit.com> | 2014-02-11 03:47:58 -0500 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2014-07-10 12:34:55 -0400 |
commit | ac0acb9e39ac41575cc6a344d04295436fd4eb4e (patch) | |
tree | b5eea64e0f5f8814e51915f4e39d79bbd19e1c27 /drivers/block/drbd | |
parent | e334f55095b908f12c8bad991433f5d609e919d1 (diff) |
drbd: use drbd_device_post_work() in more places
This replaces the md_sync_work member of struct drbd_device
by a new MD_SYNC "work bit" in device->flags.
This replaces the resync_start_work member of struct drbd_device
by a new RS_START "work bit" in device->flags.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd')
-rw-r--r-- | drivers/block/drbd/drbd_int.h | 16 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 25 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_worker.c | 27 |
3 files changed, 20 insertions, 48 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index 5768260feef6..3c701b0e2956 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h | |||
@@ -457,6 +457,8 @@ enum { | |||
457 | /* to be used in drbd_device_post_work() */ | 457 | /* to be used in drbd_device_post_work() */ |
458 | GO_DISKLESS, /* tell worker to schedule cleanup before detach */ | 458 | GO_DISKLESS, /* tell worker to schedule cleanup before detach */ |
459 | DESTROY_DISK, /* tell worker to close backing devices and destroy related structures. */ | 459 | DESTROY_DISK, /* tell worker to close backing devices and destroy related structures. */ |
460 | MD_SYNC, /* tell worker to call drbd_md_sync() */ | ||
461 | RS_START, /* tell worker to start resync/OV */ | ||
460 | RS_PROGRESS, /* tell worker that resync made significant progress */ | 462 | RS_PROGRESS, /* tell worker that resync made significant progress */ |
461 | RS_DONE, /* tell worker that resync is done */ | 463 | RS_DONE, /* tell worker that resync is done */ |
462 | }; | 464 | }; |
@@ -709,18 +711,10 @@ struct drbd_device { | |||
709 | unsigned long last_reattach_jif; | 711 | unsigned long last_reattach_jif; |
710 | struct drbd_work resync_work; | 712 | struct drbd_work resync_work; |
711 | struct drbd_work unplug_work; | 713 | struct drbd_work unplug_work; |
712 | struct drbd_work md_sync_work; | ||
713 | struct drbd_work start_resync_work; | ||
714 | struct timer_list resync_timer; | 714 | struct timer_list resync_timer; |
715 | struct timer_list md_sync_timer; | 715 | struct timer_list md_sync_timer; |
716 | struct timer_list start_resync_timer; | 716 | struct timer_list start_resync_timer; |
717 | struct timer_list request_timer; | 717 | struct timer_list request_timer; |
718 | #ifdef DRBD_DEBUG_MD_SYNC | ||
719 | struct { | ||
720 | unsigned int line; | ||
721 | const char* func; | ||
722 | } last_md_mark_dirty; | ||
723 | #endif | ||
724 | 718 | ||
725 | /* Used after attach while negotiating new disk state. */ | 719 | /* Used after attach while negotiating new disk state. */ |
726 | union drbd_state new_state_tmp; | 720 | union drbd_state new_state_tmp; |
@@ -977,13 +971,7 @@ extern void __drbd_uuid_set(struct drbd_device *device, int idx, u64 val) __must | |||
977 | extern void drbd_md_set_flag(struct drbd_device *device, int flags) __must_hold(local); | 971 | extern void drbd_md_set_flag(struct drbd_device *device, int flags) __must_hold(local); |
978 | extern void drbd_md_clear_flag(struct drbd_device *device, int flags)__must_hold(local); | 972 | extern void drbd_md_clear_flag(struct drbd_device *device, int flags)__must_hold(local); |
979 | extern int drbd_md_test_flag(struct drbd_backing_dev *, int); | 973 | extern int drbd_md_test_flag(struct drbd_backing_dev *, int); |
980 | #ifndef DRBD_DEBUG_MD_SYNC | ||
981 | extern void drbd_md_mark_dirty(struct drbd_device *device); | 974 | extern void drbd_md_mark_dirty(struct drbd_device *device); |
982 | #else | ||
983 | #define drbd_md_mark_dirty(m) drbd_md_mark_dirty_(m, __LINE__ , __func__ ) | ||
984 | extern void drbd_md_mark_dirty_(struct drbd_device *device, | ||
985 | unsigned int line, const char *func); | ||
986 | #endif | ||
987 | extern void drbd_queue_bitmap_io(struct drbd_device *device, | 975 | extern void drbd_queue_bitmap_io(struct drbd_device *device, |
988 | int (*io_fn)(struct drbd_device *), | 976 | int (*io_fn)(struct drbd_device *), |
989 | void (*done)(struct drbd_device *, int), | 977 | void (*done)(struct drbd_device *, int), |
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 0cf609464ecf..ed35d52b4763 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -60,7 +60,6 @@ | |||
60 | static DEFINE_MUTEX(drbd_main_mutex); | 60 | static DEFINE_MUTEX(drbd_main_mutex); |
61 | static int drbd_open(struct block_device *bdev, fmode_t mode); | 61 | static int drbd_open(struct block_device *bdev, fmode_t mode); |
62 | static void drbd_release(struct gendisk *gd, fmode_t mode); | 62 | static void drbd_release(struct gendisk *gd, fmode_t mode); |
63 | static int w_md_sync(struct drbd_work *w, int unused); | ||
64 | static void md_sync_timer_fn(unsigned long data); | 63 | static void md_sync_timer_fn(unsigned long data); |
65 | static int w_bitmap_io(struct drbd_work *w, int unused); | 64 | static int w_bitmap_io(struct drbd_work *w, int unused); |
66 | 65 | ||
@@ -1928,15 +1927,11 @@ void drbd_init_set_defaults(struct drbd_device *device) | |||
1928 | INIT_LIST_HEAD(&device->resync_reads); | 1927 | INIT_LIST_HEAD(&device->resync_reads); |
1929 | INIT_LIST_HEAD(&device->resync_work.list); | 1928 | INIT_LIST_HEAD(&device->resync_work.list); |
1930 | INIT_LIST_HEAD(&device->unplug_work.list); | 1929 | INIT_LIST_HEAD(&device->unplug_work.list); |
1931 | INIT_LIST_HEAD(&device->md_sync_work.list); | ||
1932 | INIT_LIST_HEAD(&device->start_resync_work.list); | ||
1933 | INIT_LIST_HEAD(&device->bm_io_work.w.list); | 1930 | INIT_LIST_HEAD(&device->bm_io_work.w.list); |
1934 | 1931 | ||
1935 | device->resync_work.cb = w_resync_timer; | 1932 | device->resync_work.cb = w_resync_timer; |
1936 | device->unplug_work.cb = w_send_write_hint; | 1933 | device->unplug_work.cb = w_send_write_hint; |
1937 | device->md_sync_work.cb = w_md_sync; | ||
1938 | device->bm_io_work.w.cb = w_bitmap_io; | 1934 | device->bm_io_work.w.cb = w_bitmap_io; |
1939 | device->start_resync_work.cb = w_start_resync; | ||
1940 | 1935 | ||
1941 | init_timer(&device->resync_timer); | 1936 | init_timer(&device->resync_timer); |
1942 | init_timer(&device->md_sync_timer); | 1937 | init_timer(&device->md_sync_timer); |
@@ -3623,25 +3618,7 @@ int drbd_md_test_flag(struct drbd_backing_dev *bdev, int flag) | |||
3623 | static void md_sync_timer_fn(unsigned long data) | 3618 | static void md_sync_timer_fn(unsigned long data) |
3624 | { | 3619 | { |
3625 | struct drbd_device *device = (struct drbd_device *) data; | 3620 | struct drbd_device *device = (struct drbd_device *) data; |
3626 | 3621 | drbd_device_post_work(device, MD_SYNC); | |
3627 | /* must not double-queue! */ | ||
3628 | if (list_empty(&device->md_sync_work.list)) | ||
3629 | drbd_queue_work_front(&first_peer_device(device)->connection->sender_work, | ||
3630 | &device->md_sync_work); | ||
3631 | } | ||
3632 | |||
3633 | static int w_md_sync(struct drbd_work *w, int unused) | ||
3634 | { | ||
3635 | struct drbd_device *device = | ||
3636 | container_of(w, struct drbd_device, md_sync_work); | ||
3637 | |||
3638 | drbd_warn(device, "md_sync_timer expired! Worker calls drbd_md_sync().\n"); | ||
3639 | #ifdef DEBUG | ||
3640 | drbd_warn(device, "last md_mark_dirty: %s:%u\n", | ||
3641 | device->last_md_mark_dirty.func, device->last_md_mark_dirty.line); | ||
3642 | #endif | ||
3643 | drbd_md_sync(device); | ||
3644 | return 0; | ||
3645 | } | 3622 | } |
3646 | 3623 | ||
3647 | const char *cmdname(enum drbd_packet cmd) | 3624 | const char *cmdname(enum drbd_packet cmd) |
diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c index 00bf4900a609..a4310fd99ffc 100644 --- a/drivers/block/drbd/drbd_worker.c +++ b/drivers/block/drbd/drbd_worker.c | |||
@@ -1606,26 +1606,20 @@ void drbd_rs_controller_reset(struct drbd_device *device) | |||
1606 | void start_resync_timer_fn(unsigned long data) | 1606 | void start_resync_timer_fn(unsigned long data) |
1607 | { | 1607 | { |
1608 | struct drbd_device *device = (struct drbd_device *) data; | 1608 | struct drbd_device *device = (struct drbd_device *) data; |
1609 | 1609 | drbd_device_post_work(device, RS_START); | |
1610 | drbd_queue_work(&first_peer_device(device)->connection->sender_work, | ||
1611 | &device->start_resync_work); | ||
1612 | } | 1610 | } |
1613 | 1611 | ||
1614 | int w_start_resync(struct drbd_work *w, int cancel) | 1612 | static void do_start_resync(struct drbd_device *device) |
1615 | { | 1613 | { |
1616 | struct drbd_device *device = | ||
1617 | container_of(w, struct drbd_device, start_resync_work); | ||
1618 | |||
1619 | if (atomic_read(&device->unacked_cnt) || atomic_read(&device->rs_pending_cnt)) { | 1614 | if (atomic_read(&device->unacked_cnt) || atomic_read(&device->rs_pending_cnt)) { |
1620 | drbd_warn(device, "w_start_resync later...\n"); | 1615 | drbd_warn(device, "postponing start_resync ...\n"); |
1621 | device->start_resync_timer.expires = jiffies + HZ/10; | 1616 | device->start_resync_timer.expires = jiffies + HZ/10; |
1622 | add_timer(&device->start_resync_timer); | 1617 | add_timer(&device->start_resync_timer); |
1623 | return 0; | 1618 | return; |
1624 | } | 1619 | } |
1625 | 1620 | ||
1626 | drbd_start_resync(device, C_SYNC_SOURCE); | 1621 | drbd_start_resync(device, C_SYNC_SOURCE); |
1627 | clear_bit(AHEAD_TO_SYNC_SOURCE, &device->flags); | 1622 | clear_bit(AHEAD_TO_SYNC_SOURCE, &device->flags); |
1628 | return 0; | ||
1629 | } | 1623 | } |
1630 | 1624 | ||
1631 | /** | 1625 | /** |
@@ -1882,9 +1876,18 @@ static void go_diskless(struct drbd_device *device) | |||
1882 | drbd_force_state(device, NS(disk, D_DISKLESS)); | 1876 | drbd_force_state(device, NS(disk, D_DISKLESS)); |
1883 | } | 1877 | } |
1884 | 1878 | ||
1879 | static int do_md_sync(struct drbd_device *device) | ||
1880 | { | ||
1881 | drbd_warn(device, "md_sync_timer expired! Worker calls drbd_md_sync().\n"); | ||
1882 | drbd_md_sync(device); | ||
1883 | return 0; | ||
1884 | } | ||
1885 | |||
1885 | #define WORK_PENDING(work_bit, todo) (todo & (1UL << work_bit)) | 1886 | #define WORK_PENDING(work_bit, todo) (todo & (1UL << work_bit)) |
1886 | static void do_device_work(struct drbd_device *device, const unsigned long todo) | 1887 | static void do_device_work(struct drbd_device *device, const unsigned long todo) |
1887 | { | 1888 | { |
1889 | if (WORK_PENDING(MD_SYNC, todo)) | ||
1890 | do_md_sync(device); | ||
1888 | if (WORK_PENDING(RS_DONE, todo) || | 1891 | if (WORK_PENDING(RS_DONE, todo) || |
1889 | WORK_PENDING(RS_PROGRESS, todo)) | 1892 | WORK_PENDING(RS_PROGRESS, todo)) |
1890 | update_on_disk_bitmap(device, WORK_PENDING(RS_DONE, todo)); | 1893 | update_on_disk_bitmap(device, WORK_PENDING(RS_DONE, todo)); |
@@ -1892,11 +1895,15 @@ static void do_device_work(struct drbd_device *device, const unsigned long todo) | |||
1892 | go_diskless(device); | 1895 | go_diskless(device); |
1893 | if (WORK_PENDING(DESTROY_DISK, todo)) | 1896 | if (WORK_PENDING(DESTROY_DISK, todo)) |
1894 | drbd_ldev_destroy(device); | 1897 | drbd_ldev_destroy(device); |
1898 | if (WORK_PENDING(RS_START, todo)) | ||
1899 | do_start_resync(device); | ||
1895 | } | 1900 | } |
1896 | 1901 | ||
1897 | #define DRBD_DEVICE_WORK_MASK \ | 1902 | #define DRBD_DEVICE_WORK_MASK \ |
1898 | ((1UL << GO_DISKLESS) \ | 1903 | ((1UL << GO_DISKLESS) \ |
1899 | |(1UL << DESTROY_DISK) \ | 1904 | |(1UL << DESTROY_DISK) \ |
1905 | |(1UL << MD_SYNC) \ | ||
1906 | |(1UL << RS_START) \ | ||
1900 | |(1UL << RS_PROGRESS) \ | 1907 | |(1UL << RS_PROGRESS) \ |
1901 | |(1UL << RS_DONE) \ | 1908 | |(1UL << RS_DONE) \ |
1902 | ) | 1909 | ) |