Skip to content

Commit 75f8b2f

Browse files
committed
Merge tag 'block-6.12-20241026' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - Pull request for MD via Song fixing a few issues - Fix a wrong check in blk_rq_map_user_bvec(), causing IO errors on passthrough IO (Xinyu) * tag 'block-6.12-20241026' of git://git.kernel.dk/linux: block: fix sanity checks in blk_rq_map_user_bvec md/raid10: fix null ptr dereference in raid10_size() md: ensure child flush IO does not affect origin bio->bi_status
2 parents a8b3be2 + 2ff9494 commit 75f8b2f

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

block/blk-map.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -600,9 +600,7 @@ static int blk_rq_map_user_bvec(struct request *rq, const struct iov_iter *iter)
600600
if (nsegs >= nr_segs || bytes > UINT_MAX - bv->bv_len)
601601
goto put_bio;
602602
if (bytes + bv->bv_len > nr_iter)
603-
goto put_bio;
604-
if (bv->bv_offset + bv->bv_len > PAGE_SIZE)
605-
goto put_bio;
603+
break;
606604

607605
nsegs++;
608606
bytes += bv->bv_len;

drivers/md/md.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,26 @@ static int mddev_set_closing_and_sync_blockdev(struct mddev *mddev, int opener_n
546546
return 0;
547547
}
548548

549+
/*
550+
* The only difference from bio_chain_endio() is that the current
551+
* bi_status of bio does not affect the bi_status of parent.
552+
*/
553+
static void md_end_flush(struct bio *bio)
554+
{
555+
struct bio *parent = bio->bi_private;
556+
557+
/*
558+
* If any flush io error before the power failure,
559+
* disk data may be lost.
560+
*/
561+
if (bio->bi_status)
562+
pr_err("md: %pg flush io error %d\n", bio->bi_bdev,
563+
blk_status_to_errno(bio->bi_status));
564+
565+
bio_put(bio);
566+
bio_endio(parent);
567+
}
568+
549569
bool md_flush_request(struct mddev *mddev, struct bio *bio)
550570
{
551571
struct md_rdev *rdev;
@@ -565,7 +585,9 @@ bool md_flush_request(struct mddev *mddev, struct bio *bio)
565585
new = bio_alloc_bioset(rdev->bdev, 0,
566586
REQ_OP_WRITE | REQ_PREFLUSH, GFP_NOIO,
567587
&mddev->bio_set);
568-
bio_chain(new, bio);
588+
new->bi_private = bio;
589+
new->bi_end_io = md_end_flush;
590+
bio_inc_remaining(bio);
569591
submit_bio(new);
570592
}
571593

drivers/md/raid10.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4061,9 +4061,12 @@ static int raid10_run(struct mddev *mddev)
40614061
}
40624062

40634063
if (!mddev_is_dm(conf->mddev)) {
4064-
ret = raid10_set_queue_limits(mddev);
4065-
if (ret)
4064+
int err = raid10_set_queue_limits(mddev);
4065+
4066+
if (err) {
4067+
ret = err;
40664068
goto out_free_conf;
4069+
}
40674070
}
40684071

40694072
/* need to check that every block has at least one working mirror */

0 commit comments

Comments
 (0)