block/blk-ioprio: Skip zoned writes that are not append operations
PATCH 1/1 block/blk-ioprio: Skip zoned writes that are not append operations
If REQ_OP_WRITE or REQ_OP_WRITE_ZEROES operations for the same zone originate from different cgroups that could result in different priorities being assigned to these operations. Do not modify the I/O priority of these write operations to prevent that these would be executed in the wrong order when using the mq-deadline I/O scheduler.
--- block/blk-ioprio.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
block/blk-ioprio.c +11 -0
@@ -192,6 +192,17 @@ void blkcg_set_ioprio(struct bio *bio)if (!blkcg || blkcg->prio_policy ==POLICY_NO_CHANGE )return ; +/* +* If REQ_OP_WRITE or REQ_OP_WRITE_ZEROES operations for the same zone +* originate from different cgroups that could result in different +* priorities being assigned to these operations. Do not modify the I/O +* priority of these write operations to prevent that these would be +* executed in the wrong order when using the mq-deadline I/O +* scheduler. +*/ +if (bdev_op_is_zoned_write (bio->bi_bdev,bio_op (bio))) +return ; +if (blkcg->prio_policy ==POLICY_PROMOTE_TO_RT || blkcg->prio_policy ==POLICY_NONE_TO_RT ) {/*
Quoted 5 lines · Bart Van Assche
If
REQ_OP_WRITEorREQ_OP_WRITE_ZEROESoperations for the same zone originate from different cgroups that could result in different priorities being assigned to these operations. Do not modify the I/O priority of these write operations to prevent that these would be executed in the wrong order when using the mq-deadline I/O
...to prevent them from being executed in the wrong...
Quoted 16 lines
scheduler.
Cc Damien Le Moal <[email protected]>Cc Christoph Hellwig <[email protected]>Signed-off-by Bart Van Assche <[email protected]>--- block/blk-ioprio.c | 11 +++++++++++ 1 file changed, 11 insertions(+)block/blk-ioprio.c +0
-0@@ -192,6 +192,17 @@ void blkcg_set_ioprio(struct bio *bio)if (!blkcg || blkcg->prio_policy ==POLICY_NO_CHANGE )return ;
block/blk-ioprio.c void blkcg_set_ioprio(struct bio *bio) · line 203
Quoted 10 lines
block/blk-ioprio.c +9
-0+/* +* If REQ_OP_WRITE or REQ_OP_WRITE_ZEROES operations for the same zone +* originate from different cgroups that could result in different +* priorities being assigned to these operations. Do not modify the I/O +* priority of these write operations to prevent that these would be +* executed in the wrong order when using the mq-deadline I/O +* scheduler. +*/ +if (bdev_op_is_zoned_write (bio->bi_bdev,bio_op (bio)))
Ideally, we want the bio equivalent of blk_rq_is_seq_zoned_write() here so that writes to conventional zones are not affected (these can be reordered).
Quoted 5 lines
block/blk-ioprio.c +2
-0+return ; +if (blkcg->prio_policy ==POLICY_PROMOTE_TO_RT || blkcg->prio_policy ==POLICY_NONE_TO_RT ) {/*
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 13 lines · Damien Le Moal
Review
Quoted 9 lines · Bart Van Assche
(quoted diff) +9
-0+ /* + * If REQ_OP_WRITE or REQ_OP_WRITE_ZEROES operations for the same zone + * originate from different cgroups that could result in different + * priorities being assigned to these operations. Do not modify the I/O + * priority of these write operations to prevent that these would be + * executed in the wrong order when using the mq-deadline I/O + * scheduler. + */ + if (bdev_op_is_zoned_write(bio->bi_bdev, bio_op(bio)))Ideally, we want the bio equivalent of
blk_rq_is_seq_zoned_write()here so that writes to conventional zones are not affected (these can be reordered).
How about the patch below?
Thanks,
Bart.
[PATCH] block/blk-ioprio: Skip zoned writes that are not append operations
If REQ_OP_WRITE or REQ_OP_WRITE_ZEROES operations for the same zone originate from different cgroups that could result in different priorities being assigned to these operations. Do not modify the I/O priority of these write operations to prevent them from being executed in the wrong order when using the mq-deadline I/O scheduler.
--- block/blk-ioprio.c | 11 +++++++++++ include/linux/blk-mq.h | 17 +++++++++++++++++ 2 files changed, 28 insertions(+)
block/blk-ioprio.c +11 -0
@@ -192,6 +192,17 @@ void blkcg_set_ioprio(struct bio *bio)if (!blkcg || blkcg->prio_policy ==POLICY_NO_CHANGE )return ; +/* +* If REQ_OP_WRITE or REQ_OP_WRITE_ZEROES operations for the same zone +* originate from different cgroups that could result in different +* priorities being assigned to these operations. Do not modify the I/O +* priority of these write operations to prevent that these would be +* executed in the wrong order when using the mq-deadline I/O +* scheduler. +*/ +if (blk_bio_is_seq_zoned_write (bio)) +return ; +if (blkcg->prio_policy ==POLICY_PROMOTE_TO_RT || blkcg->prio_policy ==POLICY_NONE_TO_RT ) {/*
include/linux/blk-mq.h +17 -0
@@ -1149,6 +1149,18 @@ static inline unsigned int blk_rq_zone_no(struct request *rq)return disk_zone_no (rq->q->disk,blk_rq_pos (rq)); } +/** +* blk_bio_is_seq_zoned_write() - Check if @bio requires write serialization. +* @bio: Bio to examine. +* +* Note: REQ_OP_ZONE_APPEND bios do not require serialization. +*/ +static inline bool blk_bio_is_seq_zoned_write (struct bio *bio) +{ +return op_needs_zoned_write_locking (bio_op (bio)) && +disk_zone_is_seq (bio->bi_disk, bio.bi_iter.bi_sector); +} +static inline unsigned int blk_rq_zone_is_seq (struct request *rq) {return disk_zone_is_seq (rq->q->disk,blk_rq_pos (rq));
@@ -1196,6 +1208,11 @@ static inline bool blk_req_can_dispatch_to_zone(struct request *rq) return !blk_req_zone_is_write_locked(rq); }#else /* CONFIG_BLK_DEV_ZONED */ +static inline bool blk_bio_is_seq_zoned_write (struct bio *bio) +{ +return false; +} +static inline bool blk_rq_is_seq_zoned_write (struct request *rq) {return false;
Quoted 67 lines · Bart Van Assche
Quoted 13 lines · Damien Le Moal
block/blk-ioprio.c void blkcg_set_ioprio(struct bio *bio)
Quoted 9 lines · Bart Van Assche
block/blk-ioprio.c +9
-0+/* +* If REQ_OP_WRITE or REQ_OP_WRITE_ZEROES operations for the same zone +* originate from different cgroups that could result in different +* priorities being assigned to these operations. Do not modify the I/O +* priority of these write operations to prevent that these would be +* executed in the wrong order when using the mq-deadline I/O +* scheduler. +*/ +if (bdev_op_is_zoned_write (bio->bi_bdev,bio_op (bio)))Ideally, we want the bio equivalent of
blk_rq_is_seq_zoned_write()here so that writes to conventional zones are not affected (these can be reordered).How about the patch below?
Thanks,
Bart.
[PATCH]
block/blk-ioprio: Skip zoned writes that are not append operationsIf
REQ_OP_WRITEorREQ_OP_WRITE_ZEROESoperations for the same zone originate from different cgroups that could result in different priorities being assigned to these operations. Do not modify the I/O priority of these write operations to prevent them from being executed in the wrong order when using the mq-deadline I/O scheduler.Cc Damien Le Moal <[email protected]>Cc Christoph Hellwig <[email protected]>Signed-off-by Bart Van Assche <[email protected]>--- block/blk-ioprio.c | 11 +++++++++++ include/linux/blk-mq.h | 17 +++++++++++++++++ 2 files changed, 28 insertions(+)block/blk-ioprio.c +11
-0@@ -192,6 +192,17 @@ void blkcg_set_ioprio(struct bio *bio)if (!blkcg || blkcg->prio_policy ==POLICY_NO_CHANGE )return ; +/* +* If REQ_OP_WRITE or REQ_OP_WRITE_ZEROES operations for the same zone +* originate from different cgroups that could result in different +* priorities being assigned to these operations. Do not modify the I/O +* priority of these write operations to prevent that these would be +* executed in the wrong order when using the mq-deadline I/O +* scheduler. +*/ +if (blk_bio_is_seq_zoned_write (bio)) +return ; +if (blkcg->prio_policy ==POLICY_PROMOTE_TO_RT || blkcg->prio_policy ==POLICY_NONE_TO_RT ) {/* include/linux/blk-mq.h +0
-0@@ -1149,6 +1149,18 @@ static inline unsigned int blk_rq_zone_no(struct request *rq)return disk_zone_no (rq->q->disk,blk_rq_pos (rq)); }
include/linux/blk-mq.h static inline unsigned int blk_rq_zone_no(struct request *rq) · line 1161
Quoted 10 lines
include/linux/blk-mq.h +10
-0+/** +* blk_bio_is_seq_zoned_write() - Check if @bio requires write serialization. +* @bio: Bio to examine. +* +* Note: REQ_OP_ZONE_APPEND bios do not require serialization. +*/ +static inline bool blk_bio_is_seq_zoned_write (struct bio *bio) +{ +return op_needs_zoned_write_locking (bio_op (bio)) && +disk_zone_is_seq (bio->bi_disk, bio.bi_iter.bi_sector);
Given that disk_zone_is_seq() always return false for regular devices, I think reversing the test order is better:
return disk_zone_is_seq(bio->bi_disk, bio.bi_iter.bi_sector) && op_needs_zoned_write_locking(bio_op(bio));
Quoted 18 lines
include/linux/blk-mq.h +7
-0+} +static inline unsigned int blk_rq_zone_is_seq (struct request *rq) {return disk_zone_is_seq (rq->q->disk,blk_rq_pos (rq));@@ -1196,6 +1208,11 @@ static inline bool blk_req_can_dispatch_to_zone(struct request *rq) return !blk_req_zone_is_write_locked(rq); }#else /* CONFIG_BLK_DEV_ZONED */ +static inline bool blk_bio_is_seq_zoned_write (struct bio *bio) +{ +return false; +} +static inline bool blk_rq_is_seq_zoned_write (struct request *rq) {return false;
Signature · 2 lines
Damien Le Moal Western Digital Research
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Bart,
kernel test robot noticed the following build errors:
[auto build test ERROR on axboe-block/for-next]
[also build test ERROR on linus/master v6.7-rc5 next-20231212] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Bart-Van-Assche/Re-PATCH-block-blk-ioprio-Skip-zoned-writes-that-are-not-append-operations/20231212-081223 base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next patch link: https://lore.kernel.org/r/d660cc31-a5be-47f2-9fdf-ba4bf5106226%40acm.org patch subject: Re: [PATCH] block/blk-ioprio: Skip zoned writes that are not append operations config: x86_64-rhel-8.3-func (https://download.01.org/0day-ci/archive/20231213/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231213/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from include/linux/t10-pi.h:6,
from include/scsi/scsi_cmnd.h:7,
from drivers/scsi/scsi.c:61:
include/linux/blk-mq.h: In function 'blk_bio_is_seq_zoned_write':
>> include/linux/blk-mq.h:1161:37: error: 'struct bio' has no member named 'bi_disk'
1161 | disk_zone_is_seq(bio->bi_disk, bio.bi_iter.bi_sector);
| ^~
>> include/linux/blk-mq.h:1161:51: error: 'bio' is a pointer; did you mean to use '->'?
1161 | disk_zone_is_seq(bio->bi_disk, bio.bi_iter.bi_sector);
| ^
| ->vim +1161 include/linux/blk-mq.h
1151
1152 /**
1153 * blk_bio_is_seq_zoned_write() - Check if @bio requires write serialization.
1154 * @bio: Bio to examine.
1155 *
1156 * Note: REQ_OP_ZONE_APPEND bios do not require serialization.
1157 */
1158 static inline bool blk_bio_is_seq_zoned_write(struct bio *bio)
1159 {
1160 return op_needs_zoned_write_locking(bio_op(bio)) &&
> 1161 disk_zone_is_seq(bio->bi_disk, bio.bi_iter.bi_sector);
1162 }
1163
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki