Skip to content

Commit 34a6f80

Browse files
author
NeilBrown
committed
md/raid5: use bio_list for the list of bios to return.
This will make it easier to splice two lists together which will be needed in future patch. Signed-off-by: NeilBrown <neilb@suse.com>
1 parent 95af587 commit 34a6f80

File tree

2 files changed

+16
-27
lines changed

2 files changed

+16
-27
lines changed

drivers/md/raid5.c

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,14 @@ static int raid6_idx_to_slot(int idx, struct stripe_head *sh,
223223
return slot;
224224
}
225225

226-
static void return_io(struct bio *return_bi)
226+
static void return_io(struct bio_list *return_bi)
227227
{
228-
struct bio *bi = return_bi;
229-
while (bi) {
230-
231-
return_bi = bi->bi_next;
232-
bi->bi_next = NULL;
228+
struct bio *bi;
229+
while ((bi = bio_list_pop(return_bi)) != NULL) {
233230
bi->bi_iter.bi_size = 0;
234231
trace_block_bio_complete(bdev_get_queue(bi->bi_bdev),
235232
bi, 0);
236233
bio_endio(bi, 0);
237-
bi = return_bi;
238234
}
239235
}
240236

@@ -1177,7 +1173,7 @@ async_copy_data(int frombio, struct bio *bio, struct page **page,
11771173
static void ops_complete_biofill(void *stripe_head_ref)
11781174
{
11791175
struct stripe_head *sh = stripe_head_ref;
1180-
struct bio *return_bi = NULL;
1176+
struct bio_list return_bi = BIO_EMPTY_LIST;
11811177
int i;
11821178

11831179
pr_debug("%s: stripe %llu\n", __func__,
@@ -1201,17 +1197,15 @@ static void ops_complete_biofill(void *stripe_head_ref)
12011197
while (rbi && rbi->bi_iter.bi_sector <
12021198
dev->sector + STRIPE_SECTORS) {
12031199
rbi2 = r5_next_bio(rbi, dev->sector);
1204-
if (!raid5_dec_bi_active_stripes(rbi)) {
1205-
rbi->bi_next = return_bi;
1206-
return_bi = rbi;
1207-
}
1200+
if (!raid5_dec_bi_active_stripes(rbi))
1201+
bio_list_add(&return_bi, rbi);
12081202
rbi = rbi2;
12091203
}
12101204
}
12111205
}
12121206
clear_bit(STRIPE_BIOFILL_RUN, &sh->state);
12131207

1214-
return_io(return_bi);
1208+
return_io(&return_bi);
12151209

12161210
set_bit(STRIPE_HANDLE, &sh->state);
12171211
release_stripe(sh);
@@ -3071,7 +3065,7 @@ static void stripe_set_idx(sector_t stripe, struct r5conf *conf, int previous,
30713065
static void
30723066
handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
30733067
struct stripe_head_state *s, int disks,
3074-
struct bio **return_bi)
3068+
struct bio_list *return_bi)
30753069
{
30763070
int i;
30773071
BUG_ON(sh->batch_head);
@@ -3115,8 +3109,7 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
31153109
clear_bit(BIO_UPTODATE, &bi->bi_flags);
31163110
if (!raid5_dec_bi_active_stripes(bi)) {
31173111
md_write_end(conf->mddev);
3118-
bi->bi_next = *return_bi;
3119-
*return_bi = bi;
3112+
bio_list_add(return_bi, bi);
31203113
}
31213114
bi = nextbi;
31223115
}
@@ -3139,8 +3132,7 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
31393132
clear_bit(BIO_UPTODATE, &bi->bi_flags);
31403133
if (!raid5_dec_bi_active_stripes(bi)) {
31413134
md_write_end(conf->mddev);
3142-
bi->bi_next = *return_bi;
3143-
*return_bi = bi;
3135+
bio_list_add(return_bi, bi);
31443136
}
31453137
bi = bi2;
31463138
}
@@ -3162,10 +3154,8 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
31623154
struct bio *nextbi =
31633155
r5_next_bio(bi, sh->dev[i].sector);
31643156
clear_bit(BIO_UPTODATE, &bi->bi_flags);
3165-
if (!raid5_dec_bi_active_stripes(bi)) {
3166-
bi->bi_next = *return_bi;
3167-
*return_bi = bi;
3168-
}
3157+
if (!raid5_dec_bi_active_stripes(bi))
3158+
bio_list_add(return_bi, bi);
31693159
bi = nextbi;
31703160
}
31713161
}
@@ -3444,7 +3434,7 @@ static void break_stripe_batch_list(struct stripe_head *head_sh,
34443434
* never LOCKED, so we don't need to test 'failed' directly.
34453435
*/
34463436
static void handle_stripe_clean_event(struct r5conf *conf,
3447-
struct stripe_head *sh, int disks, struct bio **return_bi)
3437+
struct stripe_head *sh, int disks, struct bio_list *return_bi)
34483438
{
34493439
int i;
34503440
struct r5dev *dev;
@@ -3478,8 +3468,7 @@ static void handle_stripe_clean_event(struct r5conf *conf,
34783468
wbi2 = r5_next_bio(wbi, dev->sector);
34793469
if (!raid5_dec_bi_active_stripes(wbi)) {
34803470
md_write_end(conf->mddev);
3481-
wbi->bi_next = *return_bi;
3482-
*return_bi = wbi;
3471+
bio_list_add(return_bi, wbi);
34833472
}
34843473
wbi = wbi2;
34853474
}
@@ -4612,7 +4601,7 @@ static void handle_stripe(struct stripe_head *sh)
46124601
md_wakeup_thread(conf->mddev->thread);
46134602
}
46144603

4615-
return_io(s.return_bi);
4604+
return_io(&s.return_bi);
46164605

46174606
clear_bit_unlock(STRIPE_ACTIVE, &sh->state);
46184607
}

drivers/md/raid5.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ struct stripe_head_state {
265265
int dec_preread_active;
266266
unsigned long ops_request;
267267

268-
struct bio *return_bi;
268+
struct bio_list return_bi;
269269
struct md_rdev *blocked_rdev;
270270
int handle_bad_blocks;
271271
};

0 commit comments

Comments
 (0)