Skip to content

Commit 3b252c8

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: Christoph Hellwig <[email protected]> Cc: Damien Le Moal <[email protected]> Signed-off-by: Bart Van Assche <[email protected]>
1 parent 99288f7 commit 3b252c8

4 files changed

Lines changed: 15 additions & 10 deletions

File tree

block/blk-mq.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3133,11 +3133,14 @@ void blk_mq_submit_bio(struct bio *bio)
31333133
unsigned int nr_segs;
31343134
struct request *rq;
31353135
blk_status_t ret;
3136+
int rq_cpu = -1;
31363137

31373138
/*
31383139
* If the plug has a cached request for this queue, try to use it.
31393140
*/
31403141
rq = blk_mq_peek_cached_request(plug, q, bio->bi_opf);
3142+
if (rq)
3143+
rq_cpu = rq->mq_ctx->cpu;
31413144

31423145
/*
31433146
* A BIO that was released from a zone write plug has already been
@@ -3187,10 +3190,9 @@ void blk_mq_submit_bio(struct bio *bio)
31873190
if (blk_mq_attempt_bio_merge(q, bio, nr_segs))
31883191
goto queue_exit;
31893192

3190-
if (bio_needs_zone_write_plugging(bio)) {
3191-
if (blk_zone_plug_bio(bio, nr_segs))
3192-
goto queue_exit;
3193-
}
3193+
if (bio_needs_zone_write_plugging(bio) &&
3194+
blk_zone_plug_bio(bio, nr_segs, rq_cpu))
3195+
goto queue_exit;
31943196

31953197
new_request:
31963198
if (rq) {

block/blk-zoned.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,9 @@ static void blk_zone_wplug_handle_native_zone_append(struct bio *bio)
11041104
* blk_zone_plug_bio - Handle a zone write BIO with zone write plugging
11051105
* @bio: The BIO being submitted
11061106
* @nr_segs: The number of physical segments of @bio
1107+
* @rq_cpu: software queue onto which a request will be queued. -1 if the caller
1108+
* has not yet decided onto which software queue to queue the request or if
1109+
* the bio won't be converted into a request.
11071110
*
11081111
* Handle write, write zeroes and zone append operations requiring emulation
11091112
* using zone write plugging.
@@ -1112,7 +1115,7 @@ static void blk_zone_wplug_handle_native_zone_append(struct bio *bio)
11121115
* write plug. Otherwise, return false to let the submission path process
11131116
* @bio normally.
11141117
*/
1115-
bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs)
1118+
bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs, int rq_cpu)
11161119
{
11171120
struct block_device *bdev = bio->bi_bdev;
11181121

drivers/md/dm.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,9 +1814,8 @@ static inline bool dm_zone_bio_needs_split(struct mapped_device *md,
18141814

18151815
static inline bool dm_zone_plug_bio(struct mapped_device *md, struct bio *bio)
18161816
{
1817-
if (!bio_needs_zone_write_plugging(bio))
1818-
return false;
1819-
return blk_zone_plug_bio(bio, 0);
1817+
return bio_needs_zone_write_plugging(bio) &&
1818+
blk_zone_plug_bio(bio, 0, -1);
18201819
}
18211820

18221821
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
@@ -896,7 +896,7 @@ static inline bool bio_needs_zone_write_plugging(struct bio *bio)
896896
}
897897
}
898898

899-
bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs);
899+
bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs, int rq_cpu);
900900

901901
/**
902902
* disk_zone_capacity - returns the zone capacity of zone containing @sector
@@ -931,7 +931,8 @@ static inline bool bio_needs_zone_write_plugging(struct bio *bio)
931931
return false;
932932
}
933933

934-
static inline bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs)
934+
static inline bool blk_zone_plug_bio(struct bio *bio, unsigned int nr_segs,
935+
int rq_cpu)
935936
{
936937
return false;
937938
}

0 commit comments

Comments
 (0)