Merge tag 'for-6.10/block-20240511' of git://git.kernel.dk/linux
[linux-2.6-block.git] / block / blk-core.c
index b795ac177281ad7adec63528d53def2fff1139a5..01186333c88ec5bbcc5c1bb9cbe2bbe723f84a91 100644 (file)
@@ -591,8 +591,7 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q,
                return BLK_STS_NOTSUPP;
 
        /* The bio sector must point to the start of a sequential zone */
-       if (!bdev_is_zone_start(bio->bi_bdev, bio->bi_iter.bi_sector) ||
-           !bio_zone_is_seq(bio))
+       if (!bdev_is_zone_start(bio->bi_bdev, bio->bi_iter.bi_sector))
                return BLK_STS_IOERR;
 
        /*
@@ -604,7 +603,7 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q,
                return BLK_STS_IOERR;
 
        /* Make sure the BIO is small enough and will not get split */
-       if (nr_sectors > q->limits.max_zone_append_sectors)
+       if (nr_sectors > queue_max_zone_append_sectors(q))
                return BLK_STS_IOERR;
 
        bio->bi_opf |= REQ_NOMERGE;
@@ -649,11 +648,13 @@ static void __submit_bio(struct bio *bio)
 static void __submit_bio_noacct(struct bio *bio)
 {
        struct bio_list bio_list_on_stack[2];
+       struct blk_plug plug;
 
        BUG_ON(bio->bi_next);
 
        bio_list_init(&bio_list_on_stack[0]);
        current->bio_list = bio_list_on_stack;
+       blk_start_plug(&plug);
 
        do {
                struct request_queue *q = bdev_get_queue(bio->bi_bdev);
@@ -687,19 +688,23 @@ static void __submit_bio_noacct(struct bio *bio)
                bio_list_merge(&bio_list_on_stack[0], &bio_list_on_stack[1]);
        } while ((bio = bio_list_pop(&bio_list_on_stack[0])));
 
+       blk_finish_plug(&plug);
        current->bio_list = NULL;
 }
 
 static void __submit_bio_noacct_mq(struct bio *bio)
 {
        struct bio_list bio_list[2] = { };
+       struct blk_plug plug;
 
        current->bio_list = bio_list;
+       blk_start_plug(&plug);
 
        do {
                __submit_bio(bio);
        } while ((bio = bio_list_pop(&bio_list[0])));
 
+       blk_finish_plug(&plug);
        current->bio_list = NULL;
 }
 
@@ -910,12 +915,6 @@ int bio_poll(struct bio *bio, struct io_comp_batch *iob, unsigned int flags)
            !test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
                return 0;
 
-       /*
-        * As the requests that require a zone lock are not plugged in the
-        * first place, directly accessing the plug instead of using
-        * blk_mq_plug() should not have any consequences during flushing for
-        * zoned devices.
-        */
        blk_flush_plug(current->plug, false);
 
        /*
@@ -987,10 +986,11 @@ void update_io_ticks(struct block_device *part, unsigned long now, bool end)
        unsigned long stamp;
 again:
        stamp = READ_ONCE(part->bd_stamp);
-       if (unlikely(time_after(now, stamp))) {
-               if (likely(try_cmpxchg(&part->bd_stamp, &stamp, now)))
-                       __part_stat_add(part, io_ticks, end ? now - stamp : 1);
-       }
+       if (unlikely(time_after(now, stamp)) &&
+           likely(try_cmpxchg(&part->bd_stamp, &stamp, now)) &&
+           (end || part_in_flight(part)))
+               __part_stat_add(part, io_ticks, now - stamp);
+
        if (part->bd_partno) {
                part = bdev_whole(part);
                goto again;