@@ -223,18 +223,14 @@ static int raid6_idx_to_slot(int idx, struct stripe_head *sh,
223
223
return slot ;
224
224
}
225
225
226
- static void return_io (struct bio * return_bi )
226
+ static void return_io (struct bio_list * return_bi )
227
227
{
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 ) {
233
230
bi -> bi_iter .bi_size = 0 ;
234
231
trace_block_bio_complete (bdev_get_queue (bi -> bi_bdev ),
235
232
bi , 0 );
236
233
bio_endio (bi , 0 );
237
- bi = return_bi ;
238
234
}
239
235
}
240
236
@@ -1177,7 +1173,7 @@ async_copy_data(int frombio, struct bio *bio, struct page **page,
1177
1173
static void ops_complete_biofill (void * stripe_head_ref )
1178
1174
{
1179
1175
struct stripe_head * sh = stripe_head_ref ;
1180
- struct bio * return_bi = NULL ;
1176
+ struct bio_list return_bi = BIO_EMPTY_LIST ;
1181
1177
int i ;
1182
1178
1183
1179
pr_debug ("%s: stripe %llu\n" , __func__ ,
@@ -1201,17 +1197,15 @@ static void ops_complete_biofill(void *stripe_head_ref)
1201
1197
while (rbi && rbi -> bi_iter .bi_sector <
1202
1198
dev -> sector + STRIPE_SECTORS ) {
1203
1199
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 );
1208
1202
rbi = rbi2 ;
1209
1203
}
1210
1204
}
1211
1205
}
1212
1206
clear_bit (STRIPE_BIOFILL_RUN , & sh -> state );
1213
1207
1214
- return_io (return_bi );
1208
+ return_io (& return_bi );
1215
1209
1216
1210
set_bit (STRIPE_HANDLE , & sh -> state );
1217
1211
release_stripe (sh );
@@ -3071,7 +3065,7 @@ static void stripe_set_idx(sector_t stripe, struct r5conf *conf, int previous,
3071
3065
static void
3072
3066
handle_failed_stripe (struct r5conf * conf , struct stripe_head * sh ,
3073
3067
struct stripe_head_state * s , int disks ,
3074
- struct bio * * return_bi )
3068
+ struct bio_list * return_bi )
3075
3069
{
3076
3070
int i ;
3077
3071
BUG_ON (sh -> batch_head );
@@ -3115,8 +3109,7 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
3115
3109
clear_bit (BIO_UPTODATE , & bi -> bi_flags );
3116
3110
if (!raid5_dec_bi_active_stripes (bi )) {
3117
3111
md_write_end (conf -> mddev );
3118
- bi -> bi_next = * return_bi ;
3119
- * return_bi = bi ;
3112
+ bio_list_add (return_bi , bi );
3120
3113
}
3121
3114
bi = nextbi ;
3122
3115
}
@@ -3139,8 +3132,7 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
3139
3132
clear_bit (BIO_UPTODATE , & bi -> bi_flags );
3140
3133
if (!raid5_dec_bi_active_stripes (bi )) {
3141
3134
md_write_end (conf -> mddev );
3142
- bi -> bi_next = * return_bi ;
3143
- * return_bi = bi ;
3135
+ bio_list_add (return_bi , bi );
3144
3136
}
3145
3137
bi = bi2 ;
3146
3138
}
@@ -3162,10 +3154,8 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
3162
3154
struct bio * nextbi =
3163
3155
r5_next_bio (bi , sh -> dev [i ].sector );
3164
3156
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 );
3169
3159
bi = nextbi ;
3170
3160
}
3171
3161
}
@@ -3444,7 +3434,7 @@ static void break_stripe_batch_list(struct stripe_head *head_sh,
3444
3434
* never LOCKED, so we don't need to test 'failed' directly.
3445
3435
*/
3446
3436
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 )
3448
3438
{
3449
3439
int i ;
3450
3440
struct r5dev * dev ;
@@ -3478,8 +3468,7 @@ static void handle_stripe_clean_event(struct r5conf *conf,
3478
3468
wbi2 = r5_next_bio (wbi , dev -> sector );
3479
3469
if (!raid5_dec_bi_active_stripes (wbi )) {
3480
3470
md_write_end (conf -> mddev );
3481
- wbi -> bi_next = * return_bi ;
3482
- * return_bi = wbi ;
3471
+ bio_list_add (return_bi , wbi );
3483
3472
}
3484
3473
wbi = wbi2 ;
3485
3474
}
@@ -4612,7 +4601,7 @@ static void handle_stripe(struct stripe_head *sh)
4612
4601
md_wakeup_thread (conf -> mddev -> thread );
4613
4602
}
4614
4603
4615
- return_io (s .return_bi );
4604
+ return_io (& s .return_bi );
4616
4605
4617
4606
clear_bit_unlock (STRIPE_ACTIVE , & sh -> state );
4618
4607
}
0 commit comments