Message ID | 20240328004409.594888-1-dlemoal@kernel.org |
---|---|
Headers | show |
Series | Zone write plugging | expand |
On 3/27/24 5:43 PM, Damien Le Moal wrote: > + /* > + * Remember the capacity of the first sequential zone and check > + * if it is constant for all zones. > + */ > + if (!args->zone_capacity) > + args->zone_capacity = zone->capacity; > + if (zone->capacity != args->zone_capacity) { > + pr_warn("%s: Invalid variable zone capacity\n", > + disk->disk_name); > + return -ENODEV; > + } SMR disks may have a smaller last zone. Does the above code handle such SMR disks correctly? Thanks, Bart.
On 3/27/24 9:30 PM, Christoph Hellwig wrote: > Please verify my idea carefully, but I think we can do without the > RCU grace period and thus the rcu_head in struct blk_zone_wplug: > > When the zwplug is removed from the hash, we set the > BLK_ZONE_WPLUG_UNHASHED flag under disk->zone_wplugs_lock. Once > caller see that flag any lookup that modifies the structure > will fail/wait. If we then just clear BLK_ZONE_WPLUG_UNHASHED after > the final put in disk_put_zone_wplug when we know the bio list is > empty and no other state is kept (if there might be flags left > we should clear them before), it is perfectly fine for the > zwplug to get reused for another zone at this point. Hi Christoph, I don't think this is allowed without grace period between kfree() and reusing a zwplug because another thread might be iterating over the hlist while only holding an RCU reader lock. Thanks, Bart.
On 3/29/24 07:29, Bart Van Assche wrote: > On 3/27/24 5:43 PM, Damien Le Moal wrote: >> Allocating zone write plugs using kmalloc() does not guarantee that >> enough write plugs can be allocated to simultaneously write up to >> the maximum number of active zones or maximum number of open zones of >> a zoned block device. >> >> Avoid any issue with memory allocation by pre-allocating zone write >> plugs up to the disk maximum number of open zones or maximum number of >> active zones, whichever is larger. For zoned devices that do not have >> open or active zone limits, the default 128 is used as the number of >> write plugs to pre-allocate. >> >> Pre-allocated zone write plugs are managed using a free list. If a >> change to the device zone limits is detected, the disk free list is >> grown if needed when blk_revalidate_disk_zones() is executed. > > Is there a way to retry bio submission if allocating a zone write plug > fails? Would that make it possible to drop this patch? This patch is merged into the main zone write plugging patch in v4 (about to post it) and the free list is replaced with a mempool. Note that for BIOs that do not have REQ_NOWAIT, the allocation is done with GFP_NIO. If that fails, the OOM killer is probably already wreaking the system... > > Thanks, > > Bart. >
On 3/29/24 06:38, Bart Van Assche wrote: > On 3/27/24 5:43 PM, Damien Le Moal wrote: >> + /* >> + * Remember the capacity of the first sequential zone and check >> + * if it is constant for all zones. >> + */ >> + if (!args->zone_capacity) >> + args->zone_capacity = zone->capacity; >> + if (zone->capacity != args->zone_capacity) { >> + pr_warn("%s: Invalid variable zone capacity\n", >> + disk->disk_name); >> + return -ENODEV; >> + } > > SMR disks may have a smaller last zone. Does the above code handle such > SMR disks correctly? SMR drives known to have a smaller last zone have a smaller conventional zone, not a sequential zone. But good point, I will handle that on the check for conventional zones. > > Thanks, > > Bart.
On 3/29/24 06:28, Bart Van Assche wrote: > On 3/27/24 5:43 PM, Damien Le Moal wrote: >> Moving req_bio_endio() code into its only caller, blk_update_request(), >> allows reducing accesses to and tests of bio and request fields. Also, >> given that partial completions of zone append operations is not >> possible and that zone append operations cannot be merged, the update >> of the BIO sector using the request sector for these operations can be >> moved directly before the call to bio_endio(). > > Reviewed-by: Bart Van Assche <bvanassche@acm.org> > >> - if (unlikely(error && !blk_rq_is_passthrough(req) && >> - !(req->rq_flags & RQF_QUIET)) && >> - !test_bit(GD_DEAD, &req->q->disk->state)) { >> + if (unlikely(error && !blk_rq_is_passthrough(req) && !quiet) && >> + !test_bit(GD_DEAD, &req->q->disk->state)) { > > A question that is independent of this patch series: is it a bug or is > it a feature that the GD_DEAD bit test is not marked as "unlikely"? likely/unlikely are optimizations... I guess that bit test could be under unlikely() as well. Though if we are dealing with a removable media device, this may not be appropriate, which may be why it is not under unlikely(). Not sure. > > Thanks, > > Bart.
On 3/28/24 4:43 PM, Damien Le Moal wrote: > On 3/29/24 03:14, Bart Van Assche wrote: >> On 3/27/24 17:43, Damien Le Moal wrote: >>> This reverts commit 748dc0b65ec2b4b7b3dbd7befcc4a54fdcac7988. >>> >>> Partial zone append completions cannot be supported as there is no >>> guarantees that the fragmented data will be written sequentially in the >>> same manner as with a full command. Commit 748dc0b65ec2 ("block: fix >>> partial zone append completion handling in req_bio_endio()") changed >>> req_bio_endio() to always advance a partially failed BIO by its full >>> length, but this can lead to incorrect accounting. So revert this >>> change and let low level device drivers handle this case by always >>> failing completely zone append operations. With this revert, users will >>> still see an IO error for a partially completed zone append BIO. >>> >>> Fixes: 748dc0b65ec2 ("block: fix partial zone append completion handling in req_bio_endio()") >>> Cc: stable@vger.kernel.org >>> Signed-off-by: Damien Le Moal <dlemoal@kernel.org> >>> --- >>> block/blk-mq.c | 9 ++------- >>> 1 file changed, 2 insertions(+), 7 deletions(-) >>> >>> diff --git a/block/blk-mq.c b/block/blk-mq.c >>> index 555ada922cf0..32afb87efbd0 100644 >>> --- a/block/blk-mq.c >>> +++ b/block/blk-mq.c >>> @@ -770,16 +770,11 @@ static void req_bio_endio(struct request *rq, struct bio *bio, >>> /* >>> * Partial zone append completions cannot be supported as the >>> * BIO fragments may end up not being written sequentially. >>> - * For such case, force the completed nbytes to be equal to >>> - * the BIO size so that bio_advance() sets the BIO remaining >>> - * size to 0 and we end up calling bio_endio() before returning. >>> */ >>> - if (bio->bi_iter.bi_size != nbytes) { >>> + if (bio->bi_iter.bi_size != nbytes) >>> bio->bi_status = BLK_STS_IOERR; >>> - nbytes = bio->bi_iter.bi_size; >>> - } else { >>> + else >>> bio->bi_iter.bi_sector = rq->__sector; >>> - } >>> } >>> >>> bio_advance(bio, nbytes); >> >> Hi Damien, >> >> This patch looks good to me but shouldn't it be separated from this >> patch series? I think that will help this patch to get merged sooner. > > Yes, it can go on its own. But patch 3 depends on it so I kept it in the series. > > Jens, > > How would you like to proceed with this one ? I can just pick it up separately.
On 3/29/24 08:05, Jens Axboe wrote: > > On Thu, 28 Mar 2024 09:43:39 +0900, Damien Le Moal wrote: >> The patch series introduces zone write plugging (ZWP) as the new >> mechanism to control the ordering of writes to zoned block devices. >> ZWP replaces zone write locking (ZWL) which is implemented only by >> mq-deadline today. ZWP also allows emulating zone append operations >> using regular writes for zoned devices that do not natively support this >> operation (e.g. SMR HDDs). This patch series removes the scsi disk >> driver and device mapper zone append emulation to use ZWP emulation. >> >> [...] > > Applied, thanks! > > [01/30] block: Do not force full zone append completion in req_bio_endio() > commit: 55251fbdf0146c252ceff146a1bb145546f3e034 > > Best regards, Thanks Jens. Will this also be in your block/for-next branch ? Otherwise, the series will have a conflict in patch 3.
On 3/29/24 08:27, Jens Axboe wrote: > On 3/28/24 5:13 PM, Damien Le Moal wrote: >> On 3/29/24 08:05, Jens Axboe wrote: >>> >>> On Thu, 28 Mar 2024 09:43:39 +0900, Damien Le Moal wrote: >>>> The patch series introduces zone write plugging (ZWP) as the new >>>> mechanism to control the ordering of writes to zoned block devices. >>>> ZWP replaces zone write locking (ZWL) which is implemented only by >>>> mq-deadline today. ZWP also allows emulating zone append operations >>>> using regular writes for zoned devices that do not natively support this >>>> operation (e.g. SMR HDDs). This patch series removes the scsi disk >>>> driver and device mapper zone append emulation to use ZWP emulation. >>>> >>>> [...] >>> >>> Applied, thanks! >>> >>> [01/30] block: Do not force full zone append completion in req_bio_endio() >>> commit: 55251fbdf0146c252ceff146a1bb145546f3e034 >>> >>> Best regards, >> >> Thanks Jens. Will this also be in your block/for-next branch ? >> Otherwise, the series will have a conflict in patch 3. > > It'll go into 6.9, and I'll rebase the for-6.10/block branch once -rc2 > is out. That should take care of the dependency. OK. Thanks. I will wait for next week to send out v4 then.
On 3/27/24 5:44 PM, Damien Le Moal wrote: > In preparation to completely remove zone write locking, replace the > "zone_wlock" mq-debugfs entry that was listing zones that are > write-locked with the zone_wplugs entry which lists the zones that > currently have a write plug allocated. > > The write plug information provided is: the zone number, the zone write > plug flags, the zone write plug write pointer offset and the number of > BIOs currently waiting for execution in the zone write plug BIO list. Reviewed-by: Bart Van Assche <bvanassche@acm.org>
On 3/27/24 5:43 PM, Damien Le Moal wrote: > In preparation for adding a generic zone append emulation using zone > write plugging, allow device drivers supporting zoned block device to > set a the max_zone_append_sectors queue limit of a device to 0 to > indicate the lack of native support for zone append operations and that > the block layer should emulate these operations using regular write > operations. Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
On 3/27/24 5:43 PM, Damien Le Moal wrote: > With zone write plugging enabled at the block layer level, any zone zone -> zoned Anyway: Reviewed-by: Bart Van Assche <bvanassche@acm.org>
On 3/27/24 5:43 PM, Damien Le Moal wrote: > Add the fua configfs attribute and module parameter to allow > configuring if the device supports FUA or not. Using this attribute > has an effect on the null_blk device only if memory backing is enabled > together with a write cache (cache_size option). > > This new attribute allows configuring a null_blk device with a write > cache but without FUA support. This is convenient to test the block > layer flush machinery. Reviewed-by: Bart Van Assche <bvanassche@acm.org>
On 3/27/24 17:43, Damien Le Moal wrote: > Add the fua configfs attribute and module parameter to allow > configuring if the device supports FUA or not. Using this attribute > has an effect on the null_blk device only if memory backing is enabled > together with a write cache (cache_size option). > > This new attribute allows configuring a null_blk device with a write > cache but without FUA support. This is convenient to test the block > layer flush machinery. > > Signed-off-by: Damien Le Moal<dlemoal@kernel.org> > Reviewed-by: Hannes Reinecke<hare@suse.de> Looks good. Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> -ck
On 3/27/24 17:43, Damien Le Moal wrote: > With zone write plugging enabled at the block layer level, any zone > device can only ever see at most a single write operation per zone. > There is thus no need to request a block scheduler with strick per-zone > sequential write ordering control through the ELEVATOR_F_ZBD_SEQ_WRITE > feature. Removing this allows using a zoned null_blk device with any > scheduler, including "none". > > Signed-off-by: Damien Le Moal<dlemoal@kernel.org> > Reviewed-by: Hannes Reinecke<hare@suse.de> Looks good. Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> -ck