Skip to content

Commit 03e792e

Browse files
Li Nanliu-song-6
authored andcommitted
md: change the return value type of md_write_start to void
Commit cc27b0c ("md: fix deadlock between mddev_suspend() and md_write_start()") aborted md_write_start() with false when mddev is suspended, which fixed a deadlock if calling mddev_suspend() with holding reconfig_mutex(). Since mddev_suspend() now includes lockdep_assert_not_held(), it no longer holds the reconfig_mutex. This makes previous abort unnecessary. Now, remove unnecessary abort and change function return value to void. Signed-off-by: Li Nan <[email protected]> Reviewed-by: Yu Kuai <[email protected]> Signed-off-by: Song Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a8768a1 commit 03e792e

File tree

5 files changed

+8
-17
lines changed

5 files changed

+8
-17
lines changed

drivers/md/md.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8640,12 +8640,12 @@ EXPORT_SYMBOL(md_done_sync);
86408640
* A return value of 'false' means that the write wasn't recorded
86418641
* and cannot proceed as the array is being suspend.
86428642
*/
8643-
bool md_write_start(struct mddev *mddev, struct bio *bi)
8643+
void md_write_start(struct mddev *mddev, struct bio *bi)
86448644
{
86458645
int did_change = 0;
86468646

86478647
if (bio_data_dir(bi) != WRITE)
8648-
return true;
8648+
return;
86498649

86508650
BUG_ON(mddev->ro == MD_RDONLY);
86518651
if (mddev->ro == MD_AUTO_READ) {
@@ -8678,15 +8678,9 @@ bool md_write_start(struct mddev *mddev, struct bio *bi)
86788678
if (did_change)
86798679
sysfs_notify_dirent_safe(mddev->sysfs_state);
86808680
if (!mddev->has_superblocks)
8681-
return true;
8681+
return;
86828682
wait_event(mddev->sb_wait,
8683-
!test_bit(MD_SB_CHANGE_PENDING, &mddev->sb_flags) ||
8684-
is_md_suspended(mddev));
8685-
if (test_bit(MD_SB_CHANGE_PENDING, &mddev->sb_flags)) {
8686-
percpu_ref_put(&mddev->writes_pending);
8687-
return false;
8688-
}
8689-
return true;
8683+
!test_bit(MD_SB_CHANGE_PENDING, &mddev->sb_flags));
86908684
}
86918685
EXPORT_SYMBOL(md_write_start);
86928686

drivers/md/md.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ extern void md_unregister_thread(struct mddev *mddev, struct md_thread __rcu **t
785785
extern void md_wakeup_thread(struct md_thread __rcu *thread);
786786
extern void md_check_recovery(struct mddev *mddev);
787787
extern void md_reap_sync_thread(struct mddev *mddev);
788-
extern bool md_write_start(struct mddev *mddev, struct bio *bi);
788+
extern void md_write_start(struct mddev *mddev, struct bio *bi);
789789
extern void md_write_inc(struct mddev *mddev, struct bio *bi);
790790
extern void md_write_end(struct mddev *mddev);
791791
extern void md_done_sync(struct mddev *mddev, int blocks, int ok);

drivers/md/raid1.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,8 +1687,7 @@ static bool raid1_make_request(struct mddev *mddev, struct bio *bio)
16871687
if (bio_data_dir(bio) == READ)
16881688
raid1_read_request(mddev, bio, sectors, NULL);
16891689
else {
1690-
if (!md_write_start(mddev,bio))
1691-
return false;
1690+
md_write_start(mddev,bio);
16921691
raid1_write_request(mddev, bio, sectors);
16931692
}
16941693
return true;

drivers/md/raid10.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,8 +1836,7 @@ static bool raid10_make_request(struct mddev *mddev, struct bio *bio)
18361836
&& md_flush_request(mddev, bio))
18371837
return true;
18381838

1839-
if (!md_write_start(mddev, bio))
1840-
return false;
1839+
md_write_start(mddev, bio);
18411840

18421841
if (unlikely(bio_op(bio) == REQ_OP_DISCARD))
18431842
if (!raid10_handle_discard(mddev, bio))

drivers/md/raid5.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6078,8 +6078,7 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
60786078
ctx.do_flush = bi->bi_opf & REQ_PREFLUSH;
60796079
}
60806080

6081-
if (!md_write_start(mddev, bi))
6082-
return false;
6081+
md_write_start(mddev, bi);
60836082
/*
60846083
* If array is degraded, better not do chunk aligned read because
60856084
* later we might have to read it again in order to reconstruct

0 commit comments

Comments
 (0)