diff options
author | Jianpeng Ma <majianpeng@gmail.com> | 2012-10-10 23:17:59 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-10-10 23:17:59 -0400 |
commit | 7f7583d420231b9d09897afd57a957011b606a5b (patch) | |
tree | aa45d88b926bfc8e22f841b9ea83d338afa4c3ae /drivers/md | |
parent | 1ed850f356a0a422013846b5291acff08815008b (diff) |
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>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/md.c | 7 | ||||
-rw-r--r-- | drivers/md/md.h | 2 | ||||
-rw-r--r-- | drivers/md/raid1.c | 2 | ||||
-rw-r--r-- | drivers/md/raid10.c | 2 | ||||
-rw-r--r-- | drivers/md/raid5.c | 4 |
5 files changed, 9 insertions, 8 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 85e6786653ea..7564c44b8045 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -4269,7 +4269,8 @@ static ssize_t | |||
4269 | mismatch_cnt_show(struct mddev *mddev, char *page) | 4269 | mismatch_cnt_show(struct mddev *mddev, char *page) |
4270 | { | 4270 | { |
4271 | return sprintf(page, "%llu\n", | 4271 | return sprintf(page, "%llu\n", |
4272 | (unsigned long long) mddev->resync_mismatches); | 4272 | (unsigned long long) |
4273 | atomic64_read(&mddev->resync_mismatches)); | ||
4273 | } | 4274 | } |
4274 | 4275 | ||
4275 | static struct md_sysfs_entry md_scan_mode = | 4276 | static struct md_sysfs_entry md_scan_mode = |
@@ -5235,7 +5236,7 @@ static void md_clean(struct mddev *mddev) | |||
5235 | mddev->new_layout = 0; | 5236 | mddev->new_layout = 0; |
5236 | mddev->new_chunk_sectors = 0; | 5237 | mddev->new_chunk_sectors = 0; |
5237 | mddev->curr_resync = 0; | 5238 | mddev->curr_resync = 0; |
5238 | mddev->resync_mismatches = 0; | 5239 | atomic64_set(&mddev->resync_mismatches, 0); |
5239 | mddev->suspend_lo = mddev->suspend_hi = 0; | 5240 | mddev->suspend_lo = mddev->suspend_hi = 0; |
5240 | mddev->sync_speed_min = mddev->sync_speed_max = 0; | 5241 | mddev->sync_speed_min = mddev->sync_speed_max = 0; |
5241 | mddev->recovery = 0; | 5242 | mddev->recovery = 0; |
@@ -7357,7 +7358,7 @@ void md_do_sync(struct md_thread *thread) | |||
7357 | * which defaults to physical size, but can be virtual size | 7358 | * which defaults to physical size, but can be virtual size |
7358 | */ | 7359 | */ |
7359 | max_sectors = mddev->resync_max_sectors; | 7360 | max_sectors = mddev->resync_max_sectors; |
7360 | mddev->resync_mismatches = 0; | 7361 | atomic64_set(&mddev->resync_mismatches, 0); |
7361 | /* we don't use the checkpoint if there's a bitmap */ | 7362 | /* we don't use the checkpoint if there's a bitmap */ |
7362 | if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) | 7363 | if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) |
7363 | j = mddev->resync_min; | 7364 | j = mddev->resync_min; |
diff --git a/drivers/md/md.h b/drivers/md/md.h index 93ada214b50e..af443ab868db 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h | |||
@@ -282,7 +282,7 @@ struct mddev { | |||
282 | 282 | ||
283 | sector_t resync_max_sectors; /* may be set by personality */ | 283 | sector_t resync_max_sectors; /* may be set by personality */ |
284 | 284 | ||
285 | sector_t resync_mismatches; /* count of sectors where | 285 | atomic64_t resync_mismatches; /* count of sectors where |
286 | * parity/replica mismatch found | 286 | * parity/replica mismatch found |
287 | */ | 287 | */ |
288 | 288 | ||
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index e913356b257e..8034fbd6190c 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -1876,7 +1876,7 @@ static int process_checks(struct r1bio *r1_bio) | |||
1876 | } else | 1876 | } else |
1877 | j = 0; | 1877 | j = 0; |
1878 | if (j >= 0) | 1878 | if (j >= 0) |
1879 | mddev->resync_mismatches += r1_bio->sectors; | 1879 | atomic64_add(r1_bio->sectors, &mddev->resync_mismatches); |
1880 | if (j < 0 || (test_bit(MD_RECOVERY_CHECK, &mddev->recovery) | 1880 | if (j < 0 || (test_bit(MD_RECOVERY_CHECK, &mddev->recovery) |
1881 | && test_bit(BIO_UPTODATE, &sbio->bi_flags))) { | 1881 | && test_bit(BIO_UPTODATE, &sbio->bi_flags))) { |
1882 | /* No need to write to this device. */ | 1882 | /* No need to write to this device. */ |
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index fb5bd607e15c..146749b277c6 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -2011,7 +2011,7 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio) | |||
2011 | break; | 2011 | break; |
2012 | if (j == vcnt) | 2012 | if (j == vcnt) |
2013 | continue; | 2013 | continue; |
2014 | mddev->resync_mismatches += r10_bio->sectors; | 2014 | atomic64_add(r10_bio->sectors, &mddev->resync_mismatches); |
2015 | if (test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) | 2015 | if (test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) |
2016 | /* Don't fix anything. */ | 2016 | /* Don't fix anything. */ |
2017 | continue; | 2017 | continue; |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index ab613efbbead..4cc6b0e398bc 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -2973,7 +2973,7 @@ static void handle_parity_checks5(struct r5conf *conf, struct stripe_head *sh, | |||
2973 | */ | 2973 | */ |
2974 | set_bit(STRIPE_INSYNC, &sh->state); | 2974 | set_bit(STRIPE_INSYNC, &sh->state); |
2975 | else { | 2975 | else { |
2976 | conf->mddev->resync_mismatches += STRIPE_SECTORS; | 2976 | atomic64_add(STRIPE_SECTORS, &conf->mddev->resync_mismatches); |
2977 | if (test_bit(MD_RECOVERY_CHECK, &conf->mddev->recovery)) | 2977 | if (test_bit(MD_RECOVERY_CHECK, &conf->mddev->recovery)) |
2978 | /* don't try to repair!! */ | 2978 | /* don't try to repair!! */ |
2979 | set_bit(STRIPE_INSYNC, &sh->state); | 2979 | set_bit(STRIPE_INSYNC, &sh->state); |
@@ -3125,7 +3125,7 @@ static void handle_parity_checks6(struct r5conf *conf, struct stripe_head *sh, | |||
3125 | */ | 3125 | */ |
3126 | } | 3126 | } |
3127 | } else { | 3127 | } else { |
3128 | conf->mddev->resync_mismatches += STRIPE_SECTORS; | 3128 | atomic64_add(STRIPE_SECTORS, &conf->mddev->resync_mismatches); |
3129 | if (test_bit(MD_RECOVERY_CHECK, &conf->mddev->recovery)) | 3129 | if (test_bit(MD_RECOVERY_CHECK, &conf->mddev->recovery)) |
3130 | /* don't try to repair!! */ | 3130 | /* don't try to repair!! */ |
3131 | set_bit(STRIPE_INSYNC, &sh->state); | 3131 | set_bit(STRIPE_INSYNC, &sh->state); |