Skip to content

Commit 7ae6bc4

Browse files
bvanasschekawasaki
authored andcommitted
blk-zoned: Add an argument to blk_zone_plug_bio()
Software that submits zoned writes, e.g. a filesystem, may submit zoned writes from multiple CPUs as long as the zoned writes are serialized per zone. Submitting bios from different CPUs may cause bio reordering if e.g. different bios reach the storage device through different queues. Prepare for preserving the order of pipelined zoned writes per zone by adding the 'rq_cpu` argument to blk_zone_plug_bio(). This argument tells blk_zone_plug_bio() from which CPU a cached request has been allocated. The cached request will only be used if it matches the CPU from which zoned writes are being submitted for the zone associated with the bio. Cc: Damien Le Moal <[email protected]> Cc: Christoph Hellwig <[email protected]> Signed-off-by: Bart Van Assche <[email protected]>
1 parent 7fa15a3 commit 7ae6bc4

4 files changed

Lines changed: 12 additions & 10 deletions

File tree

block/blk-mq.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3211,10 +3211,9 @@ void blk_mq_submit_bio(struct bio *bio)
32113211
if (blk_mq_attempt_bio_merge(q, bio, nr_segs))
32123212
goto queue_exit;
32133213

3214-
if (bio_needs_zone_write_plugging(bio)) {
3215-
if (blk_zone_plug_bio(bio, nr_segs))
3216-
goto queue_exit;
3217-
}
3214+
if (bio_needs_zone_write_plugging(bio) &&
3215+
blk_zone_plug_bio(bio, nr_segs, rq ? rq->mq_ctx->cpu : -1))
3216+
goto queue_exit;
32183217

32193218
new_request:
32203219
if (rq) {

block/blk-zoned.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,9 @@ static void blk_zone_wplug_handle_native_zone_append(struct bio *bio)
11101110
* blk_zone_plug_bio - Handle a zone write BIO with zone write plugging
11111111
* @bio: The BIO being submitted
11121112
* @nr_segs: The number of physical segments of @bio
1113+
* @rq_cpu: software queue onto which a request will be queued. -1 if the caller
1114+
* has not yet decided onto which software queue to queue the request or if
1115+
* the bio won't be converted into a request.
11131116
*
11141117
* Handle write, write zeroes and zone append operations requiring emulation
11151118
* using zone write plugging.
@@ -1118,7 +1121,7 @@ static void blk_zone_wplug_handle_native_zone_append(struct bio *bio)
11181121
* write plug. Otherwise, return false to let the submission path process
11191122
* @bio normally.
11201123
*/
1121-
bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs)
1124+
bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs, int rq_cpu)
11221125
{
11231126
struct block_device *bdev = bio->bi_bdev;
11241127

drivers/md/dm.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,9 +1811,8 @@ static inline bool dm_zone_bio_needs_split(struct bio *bio)
18111811

18121812
static inline bool dm_zone_plug_bio(struct mapped_device *md, struct bio *bio)
18131813
{
1814-
if (!bio_needs_zone_write_plugging(bio))
1815-
return false;
1816-
return blk_zone_plug_bio(bio, 0);
1814+
return bio_needs_zone_write_plugging(bio) &&
1815+
blk_zone_plug_bio(bio, 0, -1);
18171816
}
18181817

18191818
static blk_status_t __send_zone_reset_all_emulated(struct clone_info *ci,

include/linux/blkdev.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ static inline bool bio_needs_zone_write_plugging(struct bio *bio)
901901
}
902902
}
903903

904-
bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs);
904+
bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs, int rq_cpu);
905905

906906
/**
907907
* disk_zone_capacity - returns the zone capacity of zone containing @sector
@@ -936,7 +936,8 @@ static inline bool bio_needs_zone_write_plugging(struct bio *bio)
936936
return false;
937937
}
938938

939-
static inline bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs)
939+
static inline bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs,
940+
int rq_cpu)
940941
{
941942
return false;
942943
}

0 commit comments

Comments
 (0)