Skip to content

Commit 4f0e7d0

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md/md-bitmap: remove the last parameter for bimtap_ops->endwrite()
For the case that IO failed for one rdev, the bit will be mark as NEEDED in following cases: 1) If badblocks is set and rdev is not faulty; 2) If rdev is faulty; Case 1) is useless because synchronize data to badblocks make no sense. Case 2) can be replaced with mddev->degraded. Also remove R1BIO_Degraded, R10BIO_Degraded and STRIPE_DEGRADED since case 2) no longer use them. Signed-off-by: Yu Kuai <yukuai3@huawei.com> Link: https://lore.kernel.org/r/20250109015145.158868-3-yukuai1@huaweicloud.com Signed-off-by: Song Liu <song@kernel.org>
1 parent 08c5014 commit 4f0e7d0

File tree

9 files changed

+21
-70
lines changed

9 files changed

+21
-70
lines changed

drivers/md/md-bitmap.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,7 @@ static int bitmap_startwrite(struct mddev *mddev, sector_t offset,
17261726
}
17271727

17281728
static void bitmap_endwrite(struct mddev *mddev, sector_t offset,
1729-
unsigned long sectors, bool success)
1729+
unsigned long sectors)
17301730
{
17311731
struct bitmap *bitmap = mddev->bitmap;
17321732

@@ -1745,15 +1745,16 @@ static void bitmap_endwrite(struct mddev *mddev, sector_t offset,
17451745
return;
17461746
}
17471747

1748-
if (success && !bitmap->mddev->degraded &&
1749-
bitmap->events_cleared < bitmap->mddev->events) {
1750-
bitmap->events_cleared = bitmap->mddev->events;
1751-
bitmap->need_sync = 1;
1752-
sysfs_notify_dirent_safe(bitmap->sysfs_can_clear);
1753-
}
1754-
1755-
if (!success && !NEEDED(*bmc))
1748+
if (!bitmap->mddev->degraded) {
1749+
if (bitmap->events_cleared < bitmap->mddev->events) {
1750+
bitmap->events_cleared = bitmap->mddev->events;
1751+
bitmap->need_sync = 1;
1752+
sysfs_notify_dirent_safe(
1753+
bitmap->sysfs_can_clear);
1754+
}
1755+
} else if (!NEEDED(*bmc)) {
17561756
*bmc |= NEEDED_MASK;
1757+
}
17571758

17581759
if (COUNTER(*bmc) == COUNTER_MAX)
17591760
wake_up(&bitmap->overflow_wait);

drivers/md/md-bitmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct bitmap_operations {
9292
int (*startwrite)(struct mddev *mddev, sector_t offset,
9393
unsigned long sectors);
9494
void (*endwrite)(struct mddev *mddev, sector_t offset,
95-
unsigned long sectors, bool success);
95+
unsigned long sectors);
9696
bool (*start_sync)(struct mddev *mddev, sector_t offset,
9797
sector_t *blocks, bool degraded);
9898
void (*end_sync)(struct mddev *mddev, sector_t offset, sector_t *blocks);

drivers/md/raid1.c

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,7 @@ static void close_write(struct r1bio *r1_bio)
423423
if (test_bit(R1BIO_BehindIO, &r1_bio->state))
424424
mddev->bitmap_ops->end_behind_write(mddev);
425425
/* clear the bitmap if all writes complete successfully */
426-
mddev->bitmap_ops->endwrite(mddev, r1_bio->sector, r1_bio->sectors,
427-
!test_bit(R1BIO_Degraded, &r1_bio->state));
426+
mddev->bitmap_ops->endwrite(mddev, r1_bio->sector, r1_bio->sectors);
428427
md_write_end(mddev);
429428
}
430429

@@ -481,8 +480,6 @@ static void raid1_end_write_request(struct bio *bio)
481480
if (!test_bit(Faulty, &rdev->flags))
482481
set_bit(R1BIO_WriteError, &r1_bio->state);
483482
else {
484-
/* Fail the request */
485-
set_bit(R1BIO_Degraded, &r1_bio->state);
486483
/* Finished with this branch */
487484
r1_bio->bios[mirror] = NULL;
488485
to_put = bio;
@@ -1536,11 +1533,8 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
15361533
write_behind = true;
15371534

15381535
r1_bio->bios[i] = NULL;
1539-
if (!rdev || test_bit(Faulty, &rdev->flags)) {
1540-
if (i < conf->raid_disks)
1541-
set_bit(R1BIO_Degraded, &r1_bio->state);
1536+
if (!rdev || test_bit(Faulty, &rdev->flags))
15421537
continue;
1543-
}
15441538

15451539
atomic_inc(&rdev->nr_pending);
15461540
if (test_bit(WriteErrorSeen, &rdev->flags)) {
@@ -1559,16 +1553,6 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
15591553
*/
15601554
max_sectors = bad_sectors;
15611555
rdev_dec_pending(rdev, mddev);
1562-
/* We don't set R1BIO_Degraded as that
1563-
* only applies if the disk is
1564-
* missing, so it might be re-added,
1565-
* and we want to know to recover this
1566-
* chunk.
1567-
* In this case the device is here,
1568-
* and the fact that this chunk is not
1569-
* in-sync is recorded in the bad
1570-
* block log
1571-
*/
15721556
continue;
15731557
}
15741558
if (is_bad) {
@@ -2616,12 +2600,10 @@ static void handle_write_finished(struct r1conf *conf, struct r1bio *r1_bio)
26162600
* errors.
26172601
*/
26182602
fail = true;
2619-
if (!narrow_write_error(r1_bio, m)) {
2603+
if (!narrow_write_error(r1_bio, m))
26202604
md_error(conf->mddev,
26212605
conf->mirrors[m].rdev);
26222606
/* an I/O failed, we can't clear the bitmap */
2623-
set_bit(R1BIO_Degraded, &r1_bio->state);
2624-
}
26252607
rdev_dec_pending(conf->mirrors[m].rdev,
26262608
conf->mddev);
26272609
}
@@ -2712,8 +2694,6 @@ static void raid1d(struct md_thread *thread)
27122694
list_del(&r1_bio->retry_list);
27132695
idx = sector_to_idx(r1_bio->sector);
27142696
atomic_dec(&conf->nr_queued[idx]);
2715-
if (mddev->degraded)
2716-
set_bit(R1BIO_Degraded, &r1_bio->state);
27172697
if (test_bit(R1BIO_WriteError, &r1_bio->state))
27182698
close_write(r1_bio);
27192699
raid_end_bio_io(r1_bio);

drivers/md/raid1.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ struct r1bio {
188188
enum r1bio_state {
189189
R1BIO_Uptodate,
190190
R1BIO_IsSync,
191-
R1BIO_Degraded,
192191
R1BIO_BehindIO,
193192
/* Set ReadError on bios that experience a readerror so that
194193
* raid1d knows what to do with them.

drivers/md/raid10.c

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,7 @@ static void close_write(struct r10bio *r10_bio)
429429
struct mddev *mddev = r10_bio->mddev;
430430

431431
/* clear the bitmap if all writes complete successfully */
432-
mddev->bitmap_ops->endwrite(mddev, r10_bio->sector, r10_bio->sectors,
433-
!test_bit(R10BIO_Degraded, &r10_bio->state));
432+
mddev->bitmap_ops->endwrite(mddev, r10_bio->sector, r10_bio->sectors);
434433
md_write_end(mddev);
435434
}
436435

@@ -500,7 +499,6 @@ static void raid10_end_write_request(struct bio *bio)
500499
set_bit(R10BIO_WriteError, &r10_bio->state);
501500
else {
502501
/* Fail the request */
503-
set_bit(R10BIO_Degraded, &r10_bio->state);
504502
r10_bio->devs[slot].bio = NULL;
505503
to_put = bio;
506504
dec_rdev = 1;
@@ -1437,10 +1435,8 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,
14371435
r10_bio->devs[i].bio = NULL;
14381436
r10_bio->devs[i].repl_bio = NULL;
14391437

1440-
if (!rdev && !rrdev) {
1441-
set_bit(R10BIO_Degraded, &r10_bio->state);
1438+
if (!rdev && !rrdev)
14421439
continue;
1443-
}
14441440
if (rdev && test_bit(WriteErrorSeen, &rdev->flags)) {
14451441
sector_t first_bad;
14461442
sector_t dev_sector = r10_bio->devs[i].addr;
@@ -1457,14 +1453,6 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,
14571453
* to other devices yet
14581454
*/
14591455
max_sectors = bad_sectors;
1460-
/* We don't set R10BIO_Degraded as that
1461-
* only applies if the disk is missing,
1462-
* so it might be re-added, and we want to
1463-
* know to recover this chunk.
1464-
* In this case the device is here, and the
1465-
* fact that this chunk is not in-sync is
1466-
* recorded in the bad block log.
1467-
*/
14681456
continue;
14691457
}
14701458
if (is_bad) {
@@ -2964,11 +2952,8 @@ static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)
29642952
rdev_dec_pending(rdev, conf->mddev);
29652953
} else if (bio != NULL && bio->bi_status) {
29662954
fail = true;
2967-
if (!narrow_write_error(r10_bio, m)) {
2955+
if (!narrow_write_error(r10_bio, m))
29682956
md_error(conf->mddev, rdev);
2969-
set_bit(R10BIO_Degraded,
2970-
&r10_bio->state);
2971-
}
29722957
rdev_dec_pending(rdev, conf->mddev);
29732958
}
29742959
bio = r10_bio->devs[m].repl_bio;
@@ -3027,8 +3012,6 @@ static void raid10d(struct md_thread *thread)
30273012
r10_bio = list_first_entry(&tmp, struct r10bio,
30283013
retry_list);
30293014
list_del(&r10_bio->retry_list);
3030-
if (mddev->degraded)
3031-
set_bit(R10BIO_Degraded, &r10_bio->state);
30323015

30333016
if (test_bit(R10BIO_WriteError,
30343017
&r10_bio->state))

drivers/md/raid10.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ enum r10bio_state {
161161
R10BIO_IsSync,
162162
R10BIO_IsRecover,
163163
R10BIO_IsReshape,
164-
R10BIO_Degraded,
165164
/* Set ReadError on bios that experience a read error
166165
* so that raid10d knows what to do with them.
167166
*/

drivers/md/raid5-cache.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,7 @@ void r5c_handle_cached_data_endio(struct r5conf *conf,
314314
set_bit(R5_UPTODATE, &sh->dev[i].flags);
315315
r5c_return_dev_pending_writes(conf, &sh->dev[i]);
316316
conf->mddev->bitmap_ops->endwrite(conf->mddev,
317-
sh->sector, RAID5_STRIPE_SECTORS(conf),
318-
!test_bit(STRIPE_DEGRADED, &sh->state));
317+
sh->sector, RAID5_STRIPE_SECTORS(conf));
319318
}
320319
}
321320
}

drivers/md/raid5.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,8 +1345,6 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s)
13451345
submit_bio_noacct(rbi);
13461346
}
13471347
if (!rdev && !rrdev) {
1348-
if (op_is_write(op))
1349-
set_bit(STRIPE_DEGRADED, &sh->state);
13501348
pr_debug("skip op %d on disc %d for sector %llu\n",
13511349
bi->bi_opf, i, (unsigned long long)sh->sector);
13521350
clear_bit(R5_LOCKED, &sh->dev[i].flags);
@@ -2884,7 +2882,6 @@ static void raid5_end_write_request(struct bio *bi)
28842882
set_bit(R5_MadeGoodRepl, &sh->dev[i].flags);
28852883
} else {
28862884
if (bi->bi_status) {
2887-
set_bit(STRIPE_DEGRADED, &sh->state);
28882885
set_bit(WriteErrorSeen, &rdev->flags);
28892886
set_bit(R5_WriteError, &sh->dev[i].flags);
28902887
if (!test_and_set_bit(WantReplacement, &rdev->flags))
@@ -3664,8 +3661,7 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
36643661
}
36653662
if (bitmap_end)
36663663
conf->mddev->bitmap_ops->endwrite(conf->mddev,
3667-
sh->sector, RAID5_STRIPE_SECTORS(conf),
3668-
false);
3664+
sh->sector, RAID5_STRIPE_SECTORS(conf));
36693665
bitmap_end = 0;
36703666
/* and fail all 'written' */
36713667
bi = sh->dev[i].written;
@@ -3711,8 +3707,7 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
37113707
}
37123708
if (bitmap_end)
37133709
conf->mddev->bitmap_ops->endwrite(conf->mddev,
3714-
sh->sector, RAID5_STRIPE_SECTORS(conf),
3715-
false);
3710+
sh->sector, RAID5_STRIPE_SECTORS(conf));
37163711
/* If we were in the middle of a write the parity block might
37173712
* still be locked - so just clear all R5_LOCKED flags
37183713
*/
@@ -4062,8 +4057,7 @@ static void handle_stripe_clean_event(struct r5conf *conf,
40624057
wbi = wbi2;
40634058
}
40644059
conf->mddev->bitmap_ops->endwrite(conf->mddev,
4065-
sh->sector, RAID5_STRIPE_SECTORS(conf),
4066-
!test_bit(STRIPE_DEGRADED, &sh->state));
4060+
sh->sector, RAID5_STRIPE_SECTORS(conf));
40674061
if (head_sh->batch_head) {
40684062
sh = list_first_entry(&sh->batch_list,
40694063
struct stripe_head,
@@ -4340,7 +4334,6 @@ static void handle_parity_checks5(struct r5conf *conf, struct stripe_head *sh,
43404334
s->locked++;
43414335
set_bit(R5_Wantwrite, &dev->flags);
43424336

4343-
clear_bit(STRIPE_DEGRADED, &sh->state);
43444337
set_bit(STRIPE_INSYNC, &sh->state);
43454338
break;
43464339
case check_state_run:
@@ -4497,7 +4490,6 @@ static void handle_parity_checks6(struct r5conf *conf, struct stripe_head *sh,
44974490
clear_bit(R5_Wantwrite, &dev->flags);
44984491
s->locked--;
44994492
}
4500-
clear_bit(STRIPE_DEGRADED, &sh->state);
45014493

45024494
set_bit(STRIPE_INSYNC, &sh->state);
45034495
break;
@@ -4899,7 +4891,6 @@ static void break_stripe_batch_list(struct stripe_head *head_sh,
48994891

49004892
set_mask_bits(&sh->state, ~(STRIPE_EXPAND_SYNC_FLAGS |
49014893
(1 << STRIPE_PREREAD_ACTIVE) |
4902-
(1 << STRIPE_DEGRADED) |
49034894
(1 << STRIPE_ON_UNPLUG_LIST)),
49044895
head_sh->state & (1 << STRIPE_INSYNC));
49054896

drivers/md/raid5.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ enum {
358358
STRIPE_REPLACED,
359359
STRIPE_PREREAD_ACTIVE,
360360
STRIPE_DELAYED,
361-
STRIPE_DEGRADED,
362361
STRIPE_BIT_DELAY,
363362
STRIPE_EXPANDING,
364363
STRIPE_EXPAND_SOURCE,

0 commit comments

Comments
 (0)