diff options
author | Philipp Reisner <philipp.reisner@linbit.com> | 2011-01-17 14:27:30 -0500 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2011-03-10 05:45:42 -0500 |
commit | 6a35c45f890dc18c5527ac501b308058118f20e7 (patch) | |
tree | 627c73d972af6905f2ab77131e4232c62d31a553 /drivers/block | |
parent | 2deb8336d04106f215c21ad1b029e78d12033d02 (diff) |
drbd: Ensure that an epoch contains only requests of one kind
The assert in drbd_req.c:755 forces us to have only requests of
one kind in an epoch. The two kinds we distinguish here are:
local-only or mirrored.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 7 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_req.c | 29 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_req.h | 18 |
3 files changed, 28 insertions, 26 deletions
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 1061b9fff2b0..34ee8e44a751 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -1261,9 +1261,14 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns, | |||
1261 | if (os.conn < C_CONNECTED && ns.conn >= C_CONNECTED) | 1261 | if (os.conn < C_CONNECTED && ns.conn >= C_CONNECTED) |
1262 | drbd_resume_al(mdev); | 1262 | drbd_resume_al(mdev); |
1263 | 1263 | ||
1264 | if (os.conn == C_AHEAD && ns.conn != C_AHEAD) | 1264 | /* Start a new epoch in case we start to mirror write requests */ |
1265 | if (!drbd_should_do_remote(os) && drbd_should_do_remote(ns)) | ||
1265 | tl_forget(mdev); | 1266 | tl_forget(mdev); |
1266 | 1267 | ||
1268 | /* Do not add local-only requests to an epoch with mirrored requests */ | ||
1269 | if (drbd_should_do_remote(os) && !drbd_should_do_remote(ns)) | ||
1270 | set_bit(CREATE_BARRIER, &mdev->flags); | ||
1271 | |||
1267 | ascw = kmalloc(sizeof(*ascw), GFP_ATOMIC); | 1272 | ascw = kmalloc(sizeof(*ascw), GFP_ATOMIC); |
1268 | if (ascw) { | 1273 | if (ascw) { |
1269 | ascw->os = os; | 1274 | ascw->os = os; |
diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index 6f9d1bfcca58..336937a14d3f 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c | |||
@@ -762,27 +762,6 @@ static int drbd_may_do_local_read(struct drbd_conf *mdev, sector_t sector, int s | |||
762 | return 0 == drbd_bm_count_bits(mdev, sbnr, ebnr); | 762 | return 0 == drbd_bm_count_bits(mdev, sbnr, ebnr); |
763 | } | 763 | } |
764 | 764 | ||
765 | static bool drbd_should_do_remote(struct drbd_conf *mdev) | ||
766 | { | ||
767 | union drbd_state s = mdev->state; | ||
768 | |||
769 | return s.pdsk == D_UP_TO_DATE || | ||
770 | (s.pdsk >= D_INCONSISTENT && | ||
771 | s.conn >= C_WF_BITMAP_T && | ||
772 | s.conn < C_AHEAD); | ||
773 | /* Before proto 96 that was >= CONNECTED instead of >= C_WF_BITMAP_T. | ||
774 | That is equivalent since before 96 IO was frozen in the C_WF_BITMAP* | ||
775 | states. */ | ||
776 | } | ||
777 | static bool drbd_should_send_oos(struct drbd_conf *mdev) | ||
778 | { | ||
779 | union drbd_state s = mdev->state; | ||
780 | |||
781 | return s.conn == C_AHEAD || s.conn == C_WF_BITMAP_S; | ||
782 | /* pdsk = D_INCONSISTENT as a consequence. Protocol 96 check not necessary | ||
783 | since we enter state C_AHEAD only if proto >= 96 */ | ||
784 | } | ||
785 | |||
786 | static int drbd_make_request_common(struct drbd_conf *mdev, struct bio *bio, unsigned long start_time) | 765 | static int drbd_make_request_common(struct drbd_conf *mdev, struct bio *bio, unsigned long start_time) |
787 | { | 766 | { |
788 | const int rw = bio_rw(bio); | 767 | const int rw = bio_rw(bio); |
@@ -854,8 +833,8 @@ static int drbd_make_request_common(struct drbd_conf *mdev, struct bio *bio, uns | |||
854 | drbd_al_begin_io(mdev, sector); | 833 | drbd_al_begin_io(mdev, sector); |
855 | } | 834 | } |
856 | 835 | ||
857 | remote = remote && drbd_should_do_remote(mdev); | 836 | remote = remote && drbd_should_do_remote(mdev->state); |
858 | send_oos = rw == WRITE && drbd_should_send_oos(mdev); | 837 | send_oos = rw == WRITE && drbd_should_send_oos(mdev->state); |
859 | D_ASSERT(!(remote && send_oos)); | 838 | D_ASSERT(!(remote && send_oos)); |
860 | 839 | ||
861 | if (!(local || remote) && !is_susp(mdev->state)) { | 840 | if (!(local || remote) && !is_susp(mdev->state)) { |
@@ -896,8 +875,8 @@ allocate_barrier: | |||
896 | } | 875 | } |
897 | 876 | ||
898 | if (remote || send_oos) { | 877 | if (remote || send_oos) { |
899 | remote = drbd_should_do_remote(mdev); | 878 | remote = drbd_should_do_remote(mdev->state); |
900 | send_oos = rw == WRITE && drbd_should_send_oos(mdev); | 879 | send_oos = rw == WRITE && drbd_should_send_oos(mdev->state); |
901 | D_ASSERT(!(remote && send_oos)); | 880 | D_ASSERT(!(remote && send_oos)); |
902 | 881 | ||
903 | if (!(remote || send_oos)) | 882 | if (!(remote || send_oos)) |
diff --git a/drivers/block/drbd/drbd_req.h b/drivers/block/drbd/drbd_req.h index 077c47b1e9d7..32c1f2a31266 100644 --- a/drivers/block/drbd/drbd_req.h +++ b/drivers/block/drbd/drbd_req.h | |||
@@ -360,4 +360,22 @@ static inline int req_mod(struct drbd_request *req, | |||
360 | 360 | ||
361 | return rv; | 361 | return rv; |
362 | } | 362 | } |
363 | |||
364 | static inline bool drbd_should_do_remote(union drbd_state s) | ||
365 | { | ||
366 | return s.pdsk == D_UP_TO_DATE || | ||
367 | (s.pdsk >= D_INCONSISTENT && | ||
368 | s.conn >= C_WF_BITMAP_T && | ||
369 | s.conn < C_AHEAD); | ||
370 | /* Before proto 96 that was >= CONNECTED instead of >= C_WF_BITMAP_T. | ||
371 | That is equivalent since before 96 IO was frozen in the C_WF_BITMAP* | ||
372 | states. */ | ||
373 | } | ||
374 | static inline bool drbd_should_send_oos(union drbd_state s) | ||
375 | { | ||
376 | return s.conn == C_AHEAD || s.conn == C_WF_BITMAP_S; | ||
377 | /* pdsk = D_INCONSISTENT as a consequence. Protocol 96 check not necessary | ||
378 | since we enter state C_AHEAD only if proto >= 96 */ | ||
379 | } | ||
380 | |||
363 | #endif | 381 | #endif |