aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPhilipp Reisner <philipp.reisner@linbit.com>2012-01-16 06:14:01 -0500
committerPhilipp Reisner <philipp.reisner@linbit.com>2012-05-09 09:16:34 -0400
commitfc28845bc005995b41ae8c83c7922d088f0ad228 (patch)
treecb5f28c4c0cfb06f46b9e1b0d7e7efcdfc132f90 /drivers
parent031a7c173ffda664ac5551bd13c313e513dd87a7 (diff)
drbd: Fix a potential race that could case data inconsistency
When we have a write request and a state change C_WF_BITMAP_S -> C_SYNC_SOURCE at the same time, and it happens that the line remote = remote && drbd_should_do_remote(s); stills sees C_WF_BITMAP_S, and send_oos = rw == WRITE && drbd_should_send_oos(s); already sees C_SYNC_SOURCE both are 0. This causes the write to not be mirrored, but marked as out-of-sync on the Sync_Source node. Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/drbd/drbd_req.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
index 810070146862..4fc7f98d9856 100644
--- a/drivers/block/drbd/drbd_req.c
+++ b/drivers/block/drbd/drbd_req.c
@@ -786,6 +786,7 @@ static int drbd_make_request_common(struct drbd_conf *mdev, struct bio *bio, uns
786 int local, remote, send_oos = 0; 786 int local, remote, send_oos = 0;
787 int err = -EIO; 787 int err = -EIO;
788 int ret = 0; 788 int ret = 0;
789 union drbd_state s;
789 790
790 /* allocate outside of all locks; */ 791 /* allocate outside of all locks; */
791 req = drbd_req_new(mdev, bio); 792 req = drbd_req_new(mdev, bio);
@@ -847,8 +848,9 @@ static int drbd_make_request_common(struct drbd_conf *mdev, struct bio *bio, uns
847 drbd_al_begin_io(mdev, sector); 848 drbd_al_begin_io(mdev, sector);
848 } 849 }
849 850
850 remote = remote && drbd_should_do_remote(mdev->state); 851 s = mdev->state;
851 send_oos = rw == WRITE && drbd_should_send_oos(mdev->state); 852 remote = remote && drbd_should_do_remote(s);
853 send_oos = rw == WRITE && drbd_should_send_oos(s);
852 D_ASSERT(!(remote && send_oos)); 854 D_ASSERT(!(remote && send_oos));
853 855
854 if (!(local || remote) && !is_susp(mdev->state)) { 856 if (!(local || remote) && !is_susp(mdev->state)) {