aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bitmap.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2014-09-09 00:13:51 -0400
committerNeilBrown <neilb@suse.de>2014-10-08 19:07:04 -0400
commit4b5060ddae2b03c5387321fafc089d242225697a (patch)
treee7f8d80711b2c81dd8066304d5a4b453fdeb3791 /drivers/md/bitmap.c
parent8e0e99ba64c7ba46133a7c8a3e3f7de01f23bd93 (diff)
md/bitmap: always wait for writes on unplug.
If two threads call bitmap_unplug at the same time, then one might schedule all the writes, and the other might decide that it doesn't need to wait. But really it does. It rarely hurts to wait when it isn't absolutely necessary, and the current code doesn't really focus on 'absolutely necessary' anyway. So just wait always. This can potentially lead to data corruption if a crash happens at an awkward time and data was written before the bitmap was updated. It is very unlikely, but this should go to -stable just to be safe. Appropriate for any -stable. Signed-off-by: NeilBrown <neilb@suse.de> Cc: stable@vger.kernel.org (please delay until 3.18 is released)
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r--drivers/md/bitmap.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 67f8b31e2054..da3604e73e8a 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -879,7 +879,6 @@ void bitmap_unplug(struct bitmap *bitmap)
879{ 879{
880 unsigned long i; 880 unsigned long i;
881 int dirty, need_write; 881 int dirty, need_write;
882 int wait = 0;
883 882
884 if (!bitmap || !bitmap->storage.filemap || 883 if (!bitmap || !bitmap->storage.filemap ||
885 test_bit(BITMAP_STALE, &bitmap->flags)) 884 test_bit(BITMAP_STALE, &bitmap->flags))
@@ -897,16 +896,13 @@ void bitmap_unplug(struct bitmap *bitmap)
897 clear_page_attr(bitmap, i, BITMAP_PAGE_PENDING); 896 clear_page_attr(bitmap, i, BITMAP_PAGE_PENDING);
898 write_page(bitmap, bitmap->storage.filemap[i], 0); 897 write_page(bitmap, bitmap->storage.filemap[i], 0);
899 } 898 }
900 if (dirty)
901 wait = 1;
902 }
903 if (wait) { /* if any writes were performed, we need to wait on them */
904 if (bitmap->storage.file)
905 wait_event(bitmap->write_wait,
906 atomic_read(&bitmap->pending_writes)==0);
907 else
908 md_super_wait(bitmap->mddev);
909 } 899 }
900 if (bitmap->storage.file)
901 wait_event(bitmap->write_wait,
902 atomic_read(&bitmap->pending_writes)==0);
903 else
904 md_super_wait(bitmap->mddev);
905
910 if (test_bit(BITMAP_WRITE_ERROR, &bitmap->flags)) 906 if (test_bit(BITMAP_WRITE_ERROR, &bitmap->flags))
911 bitmap_file_kick(bitmap); 907 bitmap_file_kick(bitmap);
912} 908}