Skip to content

Commit 48edd76

Browse files
morbidrsakawasaki
authored andcommitted
block: split blk_zone_update_request_bio into two functions
blk_zone_update_request_bio() does two things. First it checks if the request to be completed was written via ZONE APPEND and if yes it then updates the sector to the one that the data was written to. This is small enough to be an inline function. But upcoming changes adding a tracepoint don't work if the function is inlined. Split the function into two, the first is blk_req_bio_is_zone_append() checking if the sector needs to be updated. This can still be an inline function. The second is blk_zone_append_update_request_bio() doing the sector update. Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Johannes Thumshirn <[email protected]>
1 parent a636ed1 commit 48edd76

3 files changed

Lines changed: 31 additions & 19 deletions

File tree

block/blk-mq.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,8 @@ static void blk_complete_request(struct request *req)
883883
/* Completion has already been traced */
884884
bio_clear_flag(bio, BIO_TRACE_COMPLETION);
885885

886-
blk_zone_update_request_bio(req, bio);
886+
if (blk_req_bio_is_zone_append(req, bio))
887+
blk_zone_append_update_request_bio(req, bio);
887888

888889
if (!is_flush)
889890
bio_endio(bio);
@@ -982,7 +983,8 @@ bool blk_update_request(struct request *req, blk_status_t error,
982983

983984
/* Don't actually finish bio if it's part of flush sequence */
984985
if (!bio->bi_iter.bi_size) {
985-
blk_zone_update_request_bio(req, bio);
986+
if (blk_req_bio_is_zone_append(req, bio))
987+
blk_zone_append_update_request_bio(req, bio);
986988
if (!is_flush)
987989
bio_endio(bio);
988990
}

block/blk-zoned.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,19 @@ static void disk_zone_wplug_unplug_bio(struct gendisk *disk,
12051205
spin_unlock_irqrestore(&zwplug->lock, flags);
12061206
}
12071207

1208+
void blk_zone_append_update_request_bio(struct request *rq, struct bio *bio)
1209+
{
1210+
/*
1211+
* For zone append requests, the request sector indicates the location
1212+
* at which the BIO data was written. Return this value to the BIO
1213+
* issuer through the BIO iter sector.
1214+
* For plugged zone writes, which include emulated zone append, we need
1215+
* the original BIO sector so that blk_zone_write_plug_bio_endio() can
1216+
* lookup the zone write plug.
1217+
*/
1218+
bio->bi_iter.bi_sector = rq->__sector;
1219+
}
1220+
12081221
void blk_zone_write_plug_bio_endio(struct bio *bio)
12091222
{
12101223
struct gendisk *disk = bio->bi_bdev->bd_disk;

block/blk.h

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -467,23 +467,15 @@ static inline bool bio_zone_write_plugging(struct bio *bio)
467467
{
468468
return bio_flagged(bio, BIO_ZONE_WRITE_PLUGGING);
469469
}
470-
void blk_zone_write_plug_bio_merged(struct bio *bio);
471-
void blk_zone_write_plug_init_request(struct request *rq);
472-
static inline void blk_zone_update_request_bio(struct request *rq,
473-
struct bio *bio)
470+
static inline bool blk_req_bio_is_zone_append(struct request *rq,
471+
struct bio *bio)
474472
{
475-
/*
476-
* For zone append requests, the request sector indicates the location
477-
* at which the BIO data was written. Return this value to the BIO
478-
* issuer through the BIO iter sector.
479-
* For plugged zone writes, which include emulated zone append, we need
480-
* the original BIO sector so that blk_zone_write_plug_bio_endio() can
481-
* lookup the zone write plug.
482-
*/
483-
if (req_op(rq) == REQ_OP_ZONE_APPEND ||
484-
bio_flagged(bio, BIO_EMULATES_ZONE_APPEND))
485-
bio->bi_iter.bi_sector = rq->__sector;
473+
return req_op(rq) == REQ_OP_ZONE_APPEND ||
474+
bio_flagged(bio, BIO_EMULATES_ZONE_APPEND);
486475
}
476+
void blk_zone_write_plug_bio_merged(struct bio *bio);
477+
void blk_zone_write_plug_init_request(struct request *rq);
478+
void blk_zone_append_update_request_bio(struct request *rq, struct bio *bio);
487479
void blk_zone_write_plug_bio_endio(struct bio *bio);
488480
static inline void blk_zone_bio_endio(struct bio *bio)
489481
{
@@ -516,14 +508,19 @@ static inline bool bio_zone_write_plugging(struct bio *bio)
516508
{
517509
return false;
518510
}
511+
static inline bool blk_req_bio_is_zone_append(struct request *req,
512+
struct bio *bio)
513+
{
514+
return false;
515+
}
519516
static inline void blk_zone_write_plug_bio_merged(struct bio *bio)
520517
{
521518
}
522519
static inline void blk_zone_write_plug_init_request(struct request *rq)
523520
{
524521
}
525-
static inline void blk_zone_update_request_bio(struct request *rq,
526-
struct bio *bio)
522+
static inline void blk_zone_append_update_request_bio(struct request *rq,
523+
struct bio *bio)
527524
{
528525
}
529526
static inline void blk_zone_bio_endio(struct bio *bio)

0 commit comments

Comments
 (0)