Subject: [PATCH] md:change resync_mismatches to atomic64_t to avoid races
Now that multiple threads can handle stripes, it is safer to
use an atomic64_t for resync_mismatches, to avoid update races.
Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 85e6786..7564c44 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4269,7 +4269,8 @@
mismatch_cnt_show(struct mddev *mddev, char *page)
{
return sprintf(page, "%llu\n",
- (unsigned long long) mddev->resync_mismatches);
+ (unsigned long long)
+ atomic64_read(&mddev->resync_mismatches));
}
static struct md_sysfs_entry md_scan_mode =
@@ -5235,7 +5236,7 @@
mddev->new_layout = 0;
mddev->new_chunk_sectors = 0;
mddev->curr_resync = 0;
- mddev->resync_mismatches = 0;
+ atomic64_set(&mddev->resync_mismatches, 0);
mddev->suspend_lo = mddev->suspend_hi = 0;
mddev->sync_speed_min = mddev->sync_speed_max = 0;
mddev->recovery = 0;
@@ -7357,7 +7358,7 @@
* which defaults to physical size, but can be virtual size
*/
max_sectors = mddev->resync_max_sectors;
- mddev->resync_mismatches = 0;
+ atomic64_set(&mddev->resync_mismatches, 0);
/* we don't use the checkpoint if there's a bitmap */
if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery))
j = mddev->resync_min;