Skip to content

Commit 0e4aac7

Browse files
apaszkieliu-song-6
authored andcommitted
md/raid5: only add to wq if reshape is in progress
Now that actual overlaps are not handled on the wait_for_overlap wq anymore, the remaining cases when we wait on this wq are limited to reshape. If reshape is not in progress, don't add to the wq in raid5_make_request() because add_wait_queue() / remove_wait_queue() operations take a spinlock and cause noticeable contention when multiple threads are submitting requests to the mddev. Signed-off-by: Artur Paszkiewicz <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Song Liu <[email protected]>
1 parent e6a0320 commit 0e4aac7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/md/raid5.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6070,6 +6070,7 @@ static sector_t raid5_bio_lowest_chunk_sector(struct r5conf *conf,
60706070
static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
60716071
{
60726072
DEFINE_WAIT_FUNC(wait, woken_wake_function);
6073+
bool on_wq;
60736074
struct r5conf *conf = mddev->private;
60746075
sector_t logical_sector;
60756076
struct stripe_request_ctx ctx = {};
@@ -6143,11 +6144,15 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
61436144
* sequential IO pattern. We don't bother with the optimization when
61446145
* reshaping as the performance benefit is not worth the complexity.
61456146
*/
6146-
if (likely(conf->reshape_progress == MaxSector))
6147+
if (likely(conf->reshape_progress == MaxSector)) {
61476148
logical_sector = raid5_bio_lowest_chunk_sector(conf, bi);
6149+
on_wq = false;
6150+
} else {
6151+
add_wait_queue(&conf->wait_for_overlap, &wait);
6152+
on_wq = true;
6153+
}
61486154
s = (logical_sector - ctx.first_sector) >> RAID5_STRIPE_SHIFT(conf);
61496155

6150-
add_wait_queue(&conf->wait_for_overlap, &wait);
61516156
while (1) {
61526157
res = make_stripe_request(mddev, conf, &ctx, logical_sector,
61536158
bi);
@@ -6158,6 +6163,7 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
61586163
continue;
61596164

61606165
if (res == STRIPE_SCHEDULE_AND_RETRY) {
6166+
WARN_ON_ONCE(!on_wq);
61616167
/*
61626168
* Must release the reference to batch_last before
61636169
* scheduling and waiting for work to be done,
@@ -6182,7 +6188,8 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
61826188
logical_sector = ctx.first_sector +
61836189
(s << RAID5_STRIPE_SHIFT(conf));
61846190
}
6185-
remove_wait_queue(&conf->wait_for_overlap, &wait);
6191+
if (unlikely(on_wq))
6192+
remove_wait_queue(&conf->wait_for_overlap, &wait);
61866193

61876194
if (ctx.batch_last)
61886195
raid5_release_stripe(ctx.batch_last);

0 commit comments

Comments
 (0)