}
 
 static void
-r5c_return_dev_pending_writes(struct r5conf *conf, struct r5dev *dev,
-                             struct bio_list *return_bi)
+r5c_return_dev_pending_writes(struct r5conf *conf, struct r5dev *dev)
 {
        struct bio *wbi, *wbi2;
 
               dev->sector + STRIPE_SECTORS) {
                wbi2 = r5_next_bio(wbi, dev->sector);
                md_write_end(conf->mddev);
-               if (!raid5_dec_bi_active_stripes(wbi)) {
-                       bio_list_add(return_bi, wbi);
-               }
+               if (!raid5_dec_bi_active_stripes(wbi))
+                       bio_endio(wbi);
                wbi = wbi2;
        }
 }
 
 void r5c_handle_cached_data_endio(struct r5conf *conf,
-         struct stripe_head *sh, int disks, struct bio_list *return_bi)
+                                 struct stripe_head *sh, int disks)
 {
        int i;
 
        for (i = sh->disks; i--; ) {
                if (sh->dev[i].written) {
                        set_bit(R5_UPTODATE, &sh->dev[i].flags);
-                       r5c_return_dev_pending_writes(conf, &sh->dev[i],
-                                                     return_bi);
+                       r5c_return_dev_pending_writes(conf, &sh->dev[i]);
                        bitmap_endwrite(conf->mddev->bitmap, sh->sector,
                                        STRIPE_SECTORS,
                                        !test_bit(STRIPE_DEGRADED, &sh->state),
 
        return slot;
 }
 
-static void return_io(struct bio_list *return_bi)
-{
-       struct bio *bi;
-       while ((bi = bio_list_pop(return_bi)) != NULL) {
-               bi->bi_iter.bi_size = 0;
-               trace_block_bio_complete(bdev_get_queue(bi->bi_bdev),
-                                        bi, 0);
-               bio_endio(bi);
-       }
-}
-
 static void print_raid5_conf (struct r5conf *conf);
 
 static int stripe_operations_active(struct stripe_head *sh)
 static void ops_complete_biofill(void *stripe_head_ref)
 {
        struct stripe_head *sh = stripe_head_ref;
-       struct bio_list return_bi = BIO_EMPTY_LIST;
        int i;
 
        pr_debug("%s: stripe %llu\n", __func__,
                                dev->sector + STRIPE_SECTORS) {
                                rbi2 = r5_next_bio(rbi, dev->sector);
                                if (!raid5_dec_bi_active_stripes(rbi))
-                                       bio_list_add(&return_bi, rbi);
+                                       bio_endio(rbi);
                                rbi = rbi2;
                        }
                }
        }
        clear_bit(STRIPE_BIOFILL_RUN, &sh->state);
 
-       return_io(&return_bi);
-
        set_bit(STRIPE_HANDLE, &sh->state);
        raid5_release_stripe(sh);
 }
 
 static void
 handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
-                               struct stripe_head_state *s, int disks,
-                               struct bio_list *return_bi)
+                    struct stripe_head_state *s, int disks)
 {
        int i;
        BUG_ON(sh->batch_head);
                        bi->bi_error = -EIO;
                        md_write_end(conf->mddev);
                        if (!raid5_dec_bi_active_stripes(bi))
-                               bio_list_add(return_bi, bi);
+                               bio_endio(bi);
                        bi = nextbi;
                }
                if (bitmap_end)
                        bi->bi_error = -EIO;
                        md_write_end(conf->mddev);
                        if (!raid5_dec_bi_active_stripes(bi))
-                               bio_list_add(return_bi, bi);
+                               bio_endio(bi);
                        bi = bi2;
                }
 
 
                                bi->bi_error = -EIO;
                                if (!raid5_dec_bi_active_stripes(bi))
-                                       bio_list_add(return_bi, bi);
+                                       bio_endio(bi);
                                bi = nextbi;
                        }
                }
  * never LOCKED, so we don't need to test 'failed' directly.
  */
 static void handle_stripe_clean_event(struct r5conf *conf,
-       struct stripe_head *sh, int disks, struct bio_list *return_bi)
+       struct stripe_head *sh, int disks)
 {
        int i;
        struct r5dev *dev;
                                        wbi2 = r5_next_bio(wbi, dev->sector);
                                        md_write_end(conf->mddev);
                                        if (!raid5_dec_bi_active_stripes(wbi))
-                                               bio_list_add(return_bi, wbi);
+                                               bio_endio(wbi);
                                        wbi = wbi2;
                                }
                                bitmap_endwrite(conf->mddev->bitmap, sh->sector,
                sh->reconstruct_state = 0;
                break_stripe_batch_list(sh, 0);
                if (s.to_read+s.to_write+s.written)
-                       handle_failed_stripe(conf, sh, &s, disks, &s.return_bi);
+                       handle_failed_stripe(conf, sh, &s, disks);
                if (s.syncing + s.replacing)
                        handle_failed_sync(conf, sh, &s);
        }
                             && !test_bit(R5_LOCKED, &qdev->flags)
                             && (test_bit(R5_UPTODATE, &qdev->flags) ||
                                 test_bit(R5_Discard, &qdev->flags))))))
-               handle_stripe_clean_event(conf, sh, disks, &s.return_bi);
+               handle_stripe_clean_event(conf, sh, disks);
 
        if (s.just_cached)
-               r5c_handle_cached_data_endio(conf, sh, disks, &s.return_bi);
+               r5c_handle_cached_data_endio(conf, sh, disks);
        log_stripe_write_finished(sh);
 
        /* Now we might consider reading some blocks, either to check/generate
                        md_wakeup_thread(conf->mddev->thread);
        }
 
-       if (!bio_list_empty(&s.return_bi))
-               return_io(&s.return_bi);
-
        clear_bit_unlock(STRIPE_ACTIVE, &sh->state);
 }