enable plugging only for reads in zoned block devices
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): CGME20220925185349eucas1p1dc689bac64668ca038ba8646c44fd580@eucas1p1.samsung.com
cover enable plugging only for reads in zoned block devices
Hi Jens,
This patch series addresses the issue that was discussed in your plugging for passthrough patch series[1].
1st patch modifies blk_mq_plug() function to accept plugging only for reads in zoned block devices.
2nd patch uses the blk_mq_plug function in blk_execute_rq_nowait().
The patches are based on next-20220923.
[1] https://lore.kernel.org/linux-block/[email protected]/
Pankaj Raghav (2):
block: modify blk_mq_plug() to allow only reads for zoned block
devices
block: use blk_mq_plug() in blk_execute_rq_nowait()
block/blk-mq.c | 2 +- block/blk-mq.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 block: modify blk_mq_plug() to allow only reads for zoned block devices
Modify blk_mq_plug() to allow plugging only for read operations in zoned block devices as there are alternative IO paths in the linux block layer which can end up doing a write via driver private requests in sequential write zones.
--- block/blk-mq.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
block/blk-mq.h +4 -3
@@ -305,14 +305,15 @@ static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap)* change can cause write BIO failures with zoned block devices as these * require sequential write patterns to zones. Prevent this from happening by * ignoring the plug state of a BIO issuing context if it is for a zoned block -* device and the BIO to plug is a write operation. +* device and the BIO to plug is not a read operation. +* * * Return current->plug if the bio can be plugged and NULL otherwise */ static inline struct blk_plug *blk_mq_plug (struct bio *bio) { -/* Zoned block device write operation case: do not plug the BIO */ -if (bdev_is_zoned (bio->bi_bdev) &&op_is_write (bio_op (bio))) +/* Allow plugging only for read operations in zoned block devices */ +if (bdev_is_zoned (bio->bi_bdev) &&bio_op (bio) !=REQ_OP_READ )return NULL ;/*
Signature · 1 line
2.25.1
Re: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
Quoted 19 lines · Pankaj Raghav
Modify
blk_mq_plug()to allow plugging only for read operations in zoned block devices as there are alternative IO paths in the linux block layer which can end up doing a write via driver private requests in sequential write zones.Signed-off-by Pankaj Raghav <[email protected]>--- block/blk-mq.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)block/blk-mq.h +0
-1@@ -305,14 +305,15 @@ static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap)* change can cause write BIO failures with zoned block devices as these * require sequential write patterns to zones. Prevent this from happening by * ignoring the plug state of a BIO issuing context if it is for a zoned block -* device and the BIO to plug is a write operation.
block/blk-mq.h static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap) · line 315
Quoted 10 lines
block/blk-mq.h +3
-2+* device and the BIO to plug is not a read operation. +* * * Return current->plug if the bio can be plugged and NULL otherwise */ static inline struct blk_plug *blk_mq_plug (struct bio *bio) { -/* Zoned block device write operation case: do not plug the BIO */ -if (bdev_is_zoned (bio->bi_bdev) &&op_is_write (bio_op (bio))) +/* Allow plugging only for read operations in zoned block devices */
nit: s/in/with
block/blk-mq.h static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap) · line 319
Quoted 4 lines
block/blk-mq.h +1
-0+if (bdev_is_zoned (bio->bi_bdev) &&bio_op (bio) !=REQ_OP_READ )return NULL ;/*
Otherwise, looks good to me.
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
In reply to Pankaj RaghavQuoted 4 lines · Pankaj Raghav
Modify
blk_mq_plug()to allow plugging only for read operations in zoned block devices as there are alternative IO paths in the linux block layer which can end up doing a write via driver private requests in sequential write zones.
We should be able to plug for all operations that are not REQ_OP_ZONE_APPEND just fine.
I also really can't parse your commit log at all, what alternative paths are you talking about here?
Jens Axboe
maintainerRe: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
Quoted 8 lines · Christoph Hellwig
Quoted 4 lines · Pankaj Raghav
Modify
blk_mq_plug()to allow plugging only for read operations in zoned block devices as there are alternative IO paths in the linux block layer which can end up doing a write via driver private requests in sequential write zones.We should be able to plug for all operations that are not
REQ_OP_ZONE_APPENDjust fine.
Agree, I think we just want to make this about someone doing a series of appends. If you mix-and-match with passthrough you will have a bad time anyway.
Signature · 1 line
Jens Axboe
Re: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
Quoted 7 lines · Jens Axboe
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Pankaj Raghav
Modify
blk_mq_plug()to allow plugging only for read operations in zoned block devices as there are alternative IO paths in the linux block layer which can end up doing a write via driver private requests in sequential write zones.
Quoted 6 lines
Quoted 2 lines
We should be able to plug for all operations that are not
REQ_OP_ZONE_APPENDjust fine.Agree, I think we just want to make this about someone doing a series of appends. If you mix-and-match with passthrough you will have a bad time anyway.
Err, sorry - what I wrote about is compelte garbage. I initially wanted to say you can plug for REQ_OP_ZONE_APPEND just fine, and then realized that we also want various other ones that have the write bit set batched. So I suspect we really want to explicitly check for REQ_OP_WRITE here.
Jens Axboe
maintainerRe: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
Quoted 15 lines · Christoph Hellwig
Quoted 7 lines · Jens Axboe
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Pankaj Raghav
Modify
blk_mq_plug()to allow plugging only for read operations in zoned block devices as there are alternative IO paths in the linux block layer which can end up doing a write via driver private requests in sequential write zones.Quoted 6 lines
Quoted 2 lines
We should be able to plug for all operations that are not
REQ_OP_ZONE_APPENDjust fine.Agree, I think we just want to make this about someone doing a series of appends. If you mix-and-match with passthrough you will have a bad time anyway.
Quoted 5 lines
Err, sorry - what I wrote about is compelte garbage. I initially wanted to say you can plug for
REQ_OP_ZONE_APPENDjust fine, and then realized that we also want various other ones that have the write bit set batched. So I suspect we really want to explicitly check forREQ_OP_WRITEhere.
My memory was a bit hazy, since we have separate ops for the driver in/out, I think just checking for REQ_OP_WRITE is indeed the right choice. That's the single case we need to care about.
Signature · 1 line
Jens Axboe
Re: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
Quoted 22 lines · Jens Axboe
Quoted 15 lines · Christoph Hellwig
Quoted 7 lines · Jens Axboe
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Pankaj Raghav
Modify
blk_mq_plug()to allow plugging only for read operations in zoned block devices as there are alternative IO paths in the linux block layer which can end up doing a write via driver private requests in sequential write zones.Quoted 6 lines
Quoted 2 lines
We should be able to plug for all operations that are not
REQ_OP_ZONE_APPENDjust fine.Agree, I think we just want to make this about someone doing a series of appends. If you mix-and-match with passthrough you will have a bad time anyway.
Quoted 5 lines
Err, sorry - what I wrote about is compelte garbage. I initially wanted to say you can plug for
REQ_OP_ZONE_APPENDjust fine, and then realized that we also want various other ones that have the write bit set batched. So I suspect we really want to explicitly check forREQ_OP_WRITEhere.
Quoted 4 lines
My memory was a bit hazy, since we have separate ops for the driver in/out, I think just checking for
REQ_OP_WRITEis indeed the right choice. That's the single case we need to care about.
Ah. You are right. I missed it as well. There is even a comment from Christoph:
* - if the least significant bit is set transfers are TO the device
* - if the least significant bit is not set transfers are FROM the device
I guess the second patch should be enough to apply plugging when applicable for uring_cmd based nvme passthrough requests.
Jens Axboe
maintainerRe: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
Quoted 27 lines · Pankaj Raghav
Quoted 22 lines · Jens Axboe
Quoted 15 lines · Christoph Hellwig
Quoted 7 lines · Jens Axboe
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Pankaj Raghav
Modify
blk_mq_plug()to allow plugging only for read operations in zoned block devices as there are alternative IO paths in the linux block layer which can end up doing a write via driver private requests in sequential write zones.Quoted 6 lines
Quoted 2 lines
We should be able to plug for all operations that are not
REQ_OP_ZONE_APPENDjust fine.Agree, I think we just want to make this about someone doing a series of appends. If you mix-and-match with passthrough you will have a bad time anyway.
Quoted 5 lines
Err, sorry - what I wrote about is compelte garbage. I initially wanted to say you can plug for
REQ_OP_ZONE_APPENDjust fine, and then realized that we also want various other ones that have the write bit set batched. So I suspect we really want to explicitly check forREQ_OP_WRITEhere.Quoted 4 lines
My memory was a bit hazy, since we have separate ops for the driver in/out, I think just checking for
REQ_OP_WRITEis indeed the right choice. That's the single case we need to care about.
Quoted 8 lines
Ah. You are right. I missed it as well. There is even a comment from Christoph:
* - if the least significant bit is set transfers are TO the device
* - if the least significant bit is not set transfers are FROM the deviceI guess the second patch should be enough to apply plugging when applicable for
uring_cmdbased nvme passthrough requests.
Do we even need the 2nd patch? If we're just doing passthrough for the blk_execute_nowait() API, then the condition should never trigger? If so, then it would be a cleanup just to ensure we're using a consistent API for getting the plug, which may be worthwhile to do separately for sure.
Signature · 1 line
Jens Axboe
Re: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
Quoted 5 lines
Quoted 2 lines
I guess the second patch should be enough to apply plugging when applicable for
uring_cmdbased nvme passthrough requests.Do we even need the 2nd patch? If we're just doing passthrough for the
blk_execute_nowait()API, then the condition should never trigger?
I think this was the question I raised in your first version of the series.
If we do a NVMe write using the passthrough interface, then we will be using REQ_OP_DRV_OUT op, which is:
REQ_OP_DRV_OUT = (__force blk_opf_t)35, // write bit is set
The condition in blk_mq_plug() will trigger as we only check if it is a _write_ (op & (__force blk_opf_t)1) to the device. Am I missing something?
Quoted 4 lines
If so, then it would be a cleanup just to ensure we're using a consistent API for getting the plug, which may be worthwhile to do separately for sure.
--
Pankaj
Jens Axboe
maintainerRe: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
Quoted 8 lines · Pankaj Raghav
Quoted 5 lines
Quoted 2 lines
I guess the second patch should be enough to apply plugging when applicable for
uring_cmdbased nvme passthrough requests.Do we even need the 2nd patch? If we're just doing passthrough for the
blk_execute_nowait()API, then the condition should never trigger?I think this was the question I raised in your first version of the series.
Quoted 7 lines
If we do a NVMe write using the passthrough interface, then we will be using
REQ_OP_DRV_OUTop, which is:
REQ_OP_DRV_OUT= (__forceblk_opf_t)35, // write bit is setThe condition in
blk_mq_plug()will trigger as we only check if it is a _write_ (op & (__forceblk_opf_t)1) to the device. Am I missing something?
Ah yes, good point. We used to have this notion of 'fs' request, don't think we do anymore. Because it really should just be:
if (zoned && (op & REQ_OP_WRITE) && fs_request)
return NULL;
for that condition imho. I guess we could make it:
if (zoned && (op & REQ_OP_WRITE) && !(op & REQ_OP_DRV_OUT))
return NULL;
Signature · 1 line
Jens Axboe
Re: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
Quoted 2 lines · Jens Axboe
Ah yes, good point. We used to have this notion of 'fs' request, don't think we do anymore. Because it really should just be:
A fs request is a !passthrough request.
Quoted 7 lines
if (zoned && (op &
REQ_OP_WRITE) &&fs_request)return NULL;for that condition imho. I guess we could make it:
if (zoned && (op &
REQ_OP_WRITE) && !(op &REQ_OP_DRV_OUT))return NULL;
Well, the only opcodes we do zone locking for is REQ_OP_WRITE and REQ_OP_WRITE_ZEROES. So this should be:
if (zoned && (op == REQ_OP_WRITE || op == REQ_OP_WRITE_ZEROES)) return NULL;
Jens Axboe
maintainerRe: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Jens Axboe
Ah yes, good point. We used to have this notion of 'fs' request, don't think we do anymore. Because it really should just be:
A fs request is a !passthrough request.
Right, that's the condition I made below too.
Quoted 5 lines
Quoted 5 lines
if (zoned && (op &
REQ_OP_WRITE) &&fs_request)return NULL;for that condition imho. I guess we could make it:
Quoted 8 lines
Quoted 2 lines
if (zoned && (op &
REQ_OP_WRITE) && !(op &REQ_OP_DRV_OUT))return NULL;Well, the only opcodes we do zone locking for is
REQ_OP_WRITEandREQ_OP_WRITE_ZEROES. So this should be:if (zoned && (op == REQ_OP_WRITE || op == REQ_OP_WRITE_ZEROES)) return NULL;
I'd rather just make it explicit and use that. Pankaj, do you want to spin a v2 with that?
Signature · 1 line
Jens Axboe
Re: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
Quoted 17 lines · Jens Axboe
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Jens Axboe
Ah yes, good point. We used to have this notion of 'fs' request, don't think we do anymore. Because it really should just be:
A fs request is a !passthrough request.
Right, that's the condition I made below too.
Quoted 8 lines
Quoted 7 lines
if (zoned && (op &
REQ_OP_WRITE) &&fs_request)return NULL;for that condition imho. I guess we could make it:
if (zoned && (op &
REQ_OP_WRITE) && !(op &REQ_OP_DRV_OUT))return NULL;
Quoted 8 lines
Quoted 5 lines
Well, the only opcodes we do zone locking for is
REQ_OP_WRITEandREQ_OP_WRITE_ZEROES. So this should be:if (zoned && (op == REQ_OP_WRITE || op == REQ_OP_WRITE_ZEROES)) return NULL;I'd rather just make it explicit and use that. Pankaj, do you want to spin a v2 with that?
It would be nice to reuse the bio equivalent ofblk_req_needs_zone_write_lock().
The test would be:
if (bio_needs_zone_write_locking()) return NULL;
With something like:
static inline bool bio_needs_zone_write_locking()
{
if (!bdev_is_zoned(bio->bi_bdev))
return false;
switch (bio_op(bio)) {
case REQ_OP_WRITE_ZEROES:
case REQ_OP_WRITE:
return true;
default:
return false;
}
}Which also has the advantage that going forward, we could refine this to plug writes to conventional zones (as these can be plugged).
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
Quoted 27 lines · Damien Le Moal
Quoted 17 lines · Jens Axboe
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Jens Axboe
Ah yes, good point. We used to have this notion of 'fs' request, don't think we do anymore. Because it really should just be:
A fs request is a !passthrough request.
Right, that's the condition I made below too.
Quoted 8 lines
Quoted 7 lines
if (zoned && (op &
REQ_OP_WRITE) &&fs_request)return NULL;for that condition imho. I guess we could make it:
if (zoned && (op &
REQ_OP_WRITE) && !(op &REQ_OP_DRV_OUT))return NULL;Quoted 8 lines
Quoted 5 lines
Well, the only opcodes we do zone locking for is
REQ_OP_WRITEandREQ_OP_WRITE_ZEROES. So this should be:if (zoned && (op == REQ_OP_WRITE || op == REQ_OP_WRITE_ZEROES)) return NULL;I'd rather just make it explicit and use that. Pankaj, do you want to spin a v2 with that?
Quoted 7 lines
It would be nice to reuse the bio equivalent of
blk_req_needs_zone_write_lock().The test would be:
if (bio_needs_zone_write_locking()) return NULL;
Note that we could also add a "IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&" to the condition or stub the helper to have this hunk disappear for the !CONFIG_BLK_DEV_ZONED case.
Quoted 24 lines
With something like:
static inline bool
bio_needs_zone_write_locking(){ if (!bdev_is_zoned(bio->bi_bdev)) return false; switch (bio_op(bio)) { case REQ_OP_WRITE_ZEROES: case REQ_OP_WRITE: return true; default: return false; } }Which also has the advantage that going forward, we could refine this to plug writes to conventional zones (as these can be plugged).
Signature · 2 lines
Damien Le Moal Western Digital Research
Jens Axboe
maintainerRe: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
Quoted 31 lines · Damien Le Moal
Quoted 30 lines · Damien Le Moal
Quoted 17 lines · Jens Axboe
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Jens Axboe
Ah yes, good point. We used to have this notion of 'fs' request, don't think we do anymore. Because it really should just be:
A fs request is a !passthrough request.
Right, that's the condition I made below too.
Quoted 8 lines
Quoted 7 lines
if (zoned && (op &
REQ_OP_WRITE) &&fs_request)return NULL;for that condition imho. I guess we could make it:
if (zoned && (op &
REQ_OP_WRITE) && !(op &REQ_OP_DRV_OUT))return NULL;Quoted 8 lines
Quoted 5 lines
Well, the only opcodes we do zone locking for is
REQ_OP_WRITEandREQ_OP_WRITE_ZEROES. So this should be:if (zoned && (op == REQ_OP_WRITE || op == REQ_OP_WRITE_ZEROES)) return NULL;I'd rather just make it explicit and use that. Pankaj, do you want to spin a v2 with that?
It would be nice to reuse the bio equivalent of
blk_req_needs_zone_write_lock().
Quoted 8 lines
Quoted 4 lines
The test would be:
if (bio_needs_zone_write_locking()) return NULL;Note that we could also add a "
IS_ENABLED(CONFIG_BLK_DEV_ZONED)&&" to the condition or stub the helper to have this hunk disappear for the !CONFIG_BLK_DEV_ZONED case.
Indeed, that would be nice.
Signature · 1 line
Jens Axboe
Jens Axboe
maintainerRe: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
In reply to Damien Le MoalQuoted 38 lines · Damien Le Moal
Quoted 17 lines · Jens Axboe
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Jens Axboe
Ah yes, good point. We used to have this notion of 'fs' request, don't think we do anymore. Because it really should just be:
A fs request is a !passthrough request.
Right, that's the condition I made below too.
Quoted 8 lines
Quoted 7 lines
if (zoned && (op &
REQ_OP_WRITE) &&fs_request)return NULL;for that condition imho. I guess we could make it:
if (zoned && (op &
REQ_OP_WRITE) && !(op &REQ_OP_DRV_OUT))return NULL;Quoted 8 lines
Quoted 5 lines
Well, the only opcodes we do zone locking for is
REQ_OP_WRITEandREQ_OP_WRITE_ZEROES. So this should be:if (zoned && (op == REQ_OP_WRITE || op == REQ_OP_WRITE_ZEROES)) return NULL;I'd rather just make it explicit and use that. Pankaj, do you want to spin a v2 with that?
It would be nice to reuse the bio equivalent of
blk_req_needs_zone_write_lock().The test would be:
if (bio_needs_zone_write_locking()) return NULL;With something like:
static inline bool
bio_needs_zone_write_locking()
Quoted 16 lines
{
if (!bdev_is_zoned(bio->bi_bdev))
return false;
switch (bio_op(bio)) {
case REQ_OP_WRITE_ZEROES:
case REQ_OP_WRITE:
return true;
default:
return false;
}
}I'd be fine with that (using a shared helper), but let's please just make it:
static inline bool op_is_zoned_write(bdev, op)
{
if (!bdev_is_zoned(bio->bi_bdev))
return false;
return op == REQ_OP_WRITE_ZEROES || op == REQ_OP_WRITE;
}and avoid a switch for this basic case and name it a bit more logically too. Not married to the above name, but the helper should not imply anything about zone locking. That's for the caller.
Signature · 1 line
Jens Axboe
Re: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
Quoted 59 lines · Jens Axboe
Quoted 38 lines · Damien Le Moal
Quoted 17 lines · Jens Axboe
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Jens Axboe
Ah yes, good point. We used to have this notion of 'fs' request, don't think we do anymore. Because it really should just be:
A fs request is a !passthrough request.
Right, that's the condition I made below too.
Quoted 8 lines
Quoted 7 lines
if (zoned && (op &
REQ_OP_WRITE) &&fs_request)return NULL;for that condition imho. I guess we could make it:
if (zoned && (op &
REQ_OP_WRITE) && !(op &REQ_OP_DRV_OUT))return NULL;Quoted 8 lines
Quoted 5 lines
Well, the only opcodes we do zone locking for is
REQ_OP_WRITEandREQ_OP_WRITE_ZEROES. So this should be:if (zoned && (op == REQ_OP_WRITE || op == REQ_OP_WRITE_ZEROES)) return NULL;I'd rather just make it explicit and use that. Pankaj, do you want to spin a v2 with that?
It would be nice to reuse the bio equivalent of
blk_req_needs_zone_write_lock().The test would be:
if (bio_needs_zone_write_locking()) return NULL;With something like:
static inline bool
bio_needs_zone_write_locking()Quoted 16 lines
{ if (!bdev_is_zoned(bio->bi_bdev)) return false; switch (bio_op(bio)) { case REQ_OP_WRITE_ZEROES: case REQ_OP_WRITE: return true; default: return false; } }I'd be fine with that (using a shared helper), but let's please just make it:
Quoted 6 lines
static inline bool
op_is_zoned_write(bdev, op){ if (!bdev_is_zoned(bio->bi_bdev)) return false; return op == REQ_OP_WRITE_ZEROES || op == REQ_OP_WRITE;
Works for me. Nit: should have REQ_OP_WRITE first as that is the most common case.
Quoted 5 lines
}
and avoid a switch for this basic case and name it a bit more logically too. Not married to the above name, but the helper should not imply anything about zone locking. That's for the caller.
blk_req_needs_zone_write_lock() would become:
bool blk_req_needs_zone_write_lock(struct request *rq)
{
if (blk_rq_is_passthrough(rq))
return false;
if (!rq->q->disk->seq_zones_wlock)
return false;
return op_is_zoned_write(rq->q->disk->part0, req_op(rq));}
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
In reply to Jens AxboeQuoted 9 lines · Jens Axboe
Quoted 5 lines
Well, the only opcodes we do zone locking for is
REQ_OP_WRITEandREQ_OP_WRITE_ZEROES. So this should be:if (zoned && (op == REQ_OP_WRITE || op == REQ_OP_WRITE_ZEROES)) return NULL;I'd rather just make it explicit and use that. Pankaj, do you want to spin a v2 with that?
Based on all the suggestions:
block: adapt blk_mq_plug() to not plug for writes that require a zone lock
The current implementation of blk_mq_plug() disables plugging for all operations that involves a transfer to the device as we just check if the last bit in op_is_write() function.
Modify blk_mq_plug() to disable plugging only for REQ_OP_WRITE and REQ_OP_WRITE_ZEROS as they might require a zone lock.
block/blk-mq.h +2 -1
@@ -312,7 +312,8 @@ static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap)static inline struct blk_plug *blk_mq_plug (struct bio *bio) {/* Zoned block device write operation case: do not plug the BIO */ -if (bdev_is_zoned (bio->bi_bdev) &&op_is_write (bio_op (bio))) +if (IS_ENABLED (CONFIG_BLK_DEV_ZONED ) && +blk_op_is_zoned_write (bio->bi_bdev,bio_op (bio)))return NULL ;/*
block/blk-zoned.c +3 -6
@@ -63,13 +63,10 @@ bool blk_req_needs_zone_write_lock(struct request *rq)if (!rq->q->disk->seq_zones_wlock)return false; -switch (req_op (rq)) { -case REQ_OP_WRITE_ZEROES : -case REQ_OP_WRITE : +if (blk_op_is_zoned_write (rq->q->disk->part0,req_op (rq)))return blk_rq_zone_is_seq (rq); -default : -return false; - } + +return false; }EXPORT_SYMBOL_GPL (blk_req_needs_zone_write_lock);
include/linux/blkdev.h +9 -0
@@ -1300,6 +1300,15 @@ static inline bool bdev_is_zoned(struct block_device *bdev)return false; } +static inline bool blk_op_is_zoned_write (struct block_device *bdev, +blk_opf_t op) +{ +if (!bdev_is_zoned (bdev)) +return false; + +return op ==REQ_OP_WRITE || op ==REQ_OP_WRITE_ZEROES ; +} +static inline sector_t bdev_zone_sectors (struct block_device *bdev) {struct request_queue *q =bdev_get_queue (bdev);
Does this look fine?
Re: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
Quoted 66 lines · Pankaj Raghav
Quoted 9 lines · Jens Axboe
Quoted 5 lines
Well, the only opcodes we do zone locking for is
REQ_OP_WRITEandREQ_OP_WRITE_ZEROES. So this should be:if (zoned && (op == REQ_OP_WRITE || op == REQ_OP_WRITE_ZEROES)) return NULL;I'd rather just make it explicit and use that. Pankaj, do you want to spin a v2 with that?
Based on all the suggestions:
block: adapt
blk_mq_plug()to not plug for writes that require a zone lockThe current implementation of
blk_mq_plug()disables plugging for all operations that involves a transfer to the device as we just check if the last bit inop_is_write()function.Modify
blk_mq_plug()to disable plugging only forREQ_OP_WRITEandREQ_OP_WRITE_ZEROSas they might require a zone lock.Suggested-by Christoph Hellwig <[email protected]>Suggested-by Damien Le Moal <[email protected]>Signed-off-by Pankaj Raghav <[email protected]>block/blk-mq.h +2
-1@@ -312,7 +312,8 @@ static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap)static inline struct blk_plug *blk_mq_plug (struct bio *bio) {/* Zoned block device write operation case: do not plug the BIO */ -if (bdev_is_zoned (bio->bi_bdev) &&op_is_write (bio_op (bio))) +if (IS_ENABLED (CONFIG_BLK_DEV_ZONED ) && +blk_op_is_zoned_write (bio->bi_bdev,bio_op (bio)))return NULL ;/* block/blk-zoned.c +3
-6@@ -63,13 +63,10 @@ bool blk_req_needs_zone_write_lock(struct request *rq)if (!rq->q->disk->seq_zones_wlock)return false; -switch (req_op (rq)) { -case REQ_OP_WRITE_ZEROES : -case REQ_OP_WRITE : +if (blk_op_is_zoned_write (rq->q->disk->part0,req_op (rq)))return blk_rq_zone_is_seq (rq); -default : -return false; - } + +return false; }EXPORT_SYMBOL_GPL (blk_req_needs_zone_write_lock);include/linux/blkdev.h +0
-0
include/linux/blkdev.h static inline bool bdev_is_zoned(struct block_device *bdev) · line 1304
Quoted 5 lines
include/linux/blkdev.h +2
-0@@ -1300,6 +1300,15 @@ static inline bool bdev_is_zoned(struct block_device *bdev)return false; } +static inline bool blk_op_is_zoned_write (struct block_device *bdev, +blk_opf_t op)
To be consistent, I personally would prefer bdev_op_is_zoned_write() as the name here (the first argument is a bdev).
Quoted 13 lines
include/linux/blkdev.h +7
-0+{ +if (!bdev_is_zoned (bdev)) +return false; + +return op ==REQ_OP_WRITE || op ==REQ_OP_WRITE_ZEROES ; +} +static inline sector_t bdev_zone_sectors (struct block_device *bdev) {struct request_queue *q =bdev_get_queue (bdev);Does this look fine?
Signature · 2 lines
Damien Le Moal Western Digital Research
PATCH 2/2 block: use blk_mq_plug() in blk_execute_rq_nowait()
In reply to Pankaj Raghavblk_execute_rq_nowait() function mainly was used by low-level drivers such as NVMe to submit one-off passthrough requests. However, recently introduced uring-cmd based io-passthrough also uses the same function to submit io requests.
As the plugging support is coming to io-passthrough[1], use the blk_mq_plug() helper to ensure plugging is not used in all scenarios.
[1]
https://lore.kernel.org/linux-block/[email protected]/
--- block/blk-mq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-mq.c +1 -1
@@ -1213,7 +1213,7 @@ void blk_execute_rq_nowait(struct request *rq, bool at_head)WARN_ON (!blk_rq_is_passthrough (rq));blk_account_io_start (rq); -if (current->plug) +if (blk_mq_plug (rq->bio))blk_add_rq_to_plug (current->plug, rq);else blk_mq_sched_insert_request (rq, at_head, true, false);
Signature · 1 line
2.25.1
Re: [PATCH 2/2] block: use blk_mq_plug() in blk_execute_rq_nowait()
Quoted 21 lines · Pankaj Raghav
blk_execute_rq_nowait()function mainly was used by low-level drivers such as NVMe to submit one-off passthrough requests. However, recently introduced uring-cmd based io-passthrough also uses the same function to submit io requests.As the plugging support is coming to io-passthrough[1], use the
blk_mq_plug()helper to ensure plugging is not used in all scenarios.[1]
https://lore.kernel.org/linux-block/[email protected]/Signed-off-by Pankaj Raghav <[email protected]>--- block/blk-mq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/blk-mq.c +0
-0
block/blk-mq.c void blk_execute_rq_nowait(struct request *rq, bool at_head) · line 1219
Quoted 8 lines
block/blk-mq.c +1
-1@@ -1213,7 +1213,7 @@ void blk_execute_rq_nowait(struct request *rq, bool at_head)WARN_ON (!blk_rq_is_passthrough (rq));blk_account_io_start (rq); -if (current->plug) +if (blk_mq_plug (rq->bio))blk_add_rq_to_plug (current->plug, rq);else blk_mq_sched_insert_request (rq, at_head, true, false);
Looks good to me.
Signature · 2 lines
Damien Le Moal Western Digital Research