From: Damien Le Moal <dlemoal@kernel.org>
To: Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>
Cc: Josef Bacik <josef@toxicpanda.com>, linux-block@vger.kernel.org
Subject: Re: [PATCH 2/4] zloop: share more code for opening a zone backing file
Date: Fri, 30 Oct 2026 08:10:22 +0700 [thread overview]
Message-ID: <e6bd8068-2c8a-4d96-bcaf-2191e0123026@kernel.org> (raw)
In-Reply-To: <20261029150353.2503201-3-hch@lst.de>
On 2026/10/29 22:03, Christoph Hellwig wrote:
> Use a common path for opening and querying the block size.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> drivers/block/zloop.c | 65 +++++++++++++++++--------------------------
> 1 file changed, 26 insertions(+), 39 deletions(-)
>
> diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
> index 71f7685efb13..3dc484e3c700 100644
> --- a/drivers/block/zloop.c
> +++ b/drivers/block/zloop.c
> @@ -1107,8 +1107,6 @@ static int zloop_init_zone(struct zloop_device *zlo, struct zloop_options *opts,
> {
> struct zloop_zone *zone = &zlo->zones[zone_no];
> int oflags = O_RDWR;
> - struct kstat stat;
> - sector_t file_sectors;
> int ret;
>
> mutex_init(&zone->lock);
> @@ -1122,27 +1120,33 @@ static int zloop_init_zone(struct zloop_device *zlo, struct zloop_options *opts,
> if (!opts->buffered_io)
> oflags |= O_DIRECT;
>
> + zone->file = zloop_filp_open_fmt(oflags, 0600, "%s/%u/%s-%06u",
> + zlo->base_dir, zlo->id,
> + zone_no < zlo->nr_conv_zones ? "cnv" : "seq",
> + zone_no);
> + if (IS_ERR(zone->file)) {
> + pr_err("Failed to open zone %u file %s/%u/%s-%06u (err=%ld)",
> + zone_no, zlo->base_dir, zlo->id,
> + zone_no < zlo->nr_conv_zones ? "cnv" : "seq",
> + zone_no, PTR_ERR(zone->file));
> + return PTR_ERR(zone->file);
> + }
> +
> + if (zlo->block_size) {
Shouldn't this be:
if (!zlo->block_size) {
?
Not a huge problem, but no need to repeatedly get the block size for all zones.
Other than that, this is a nice cleanup!
> + ret = zloop_get_block_size(zlo, zone);
> + if (ret)
> + return ret;
> + }
> +
> if (zone_no < zlo->nr_conv_zones) {
> + sector_t file_sectors;
> + struct kstat stat;
> +
> /* Conventional zone file. */
> set_bit(ZLOOP_ZONE_CONV, &zone->flags);
> zone->cond = BLK_ZONE_COND_NOT_WP;
> zone->wp = U64_MAX;
>
> - zone->file = zloop_filp_open_fmt(oflags, 0600, "%s/%u/cnv-%06u",
> - zlo->base_dir, zlo->id, zone_no);
> - if (IS_ERR(zone->file)) {
> - pr_err("Failed to open zone %u file %s/%u/cnv-%06u (err=%ld)",
> - zone_no, zlo->base_dir, zlo->id, zone_no,
> - PTR_ERR(zone->file));
> - return PTR_ERR(zone->file);
> - }
> -
> - if (!zlo->block_size) {
> - ret = zloop_get_block_size(zlo, zone);
> - if (ret)
> - return ret;
> - }
> -
> ret = vfs_getattr(&zone->file->f_path, &stat, STATX_SIZE, 0);
> if (ret < 0) {
> pr_err("Failed to get zone %u file stat\n", zone_no);
> @@ -1163,30 +1167,13 @@ static int zloop_init_zone(struct zloop_device *zlo, struct zloop_options *opts,
> zone_no, ret);
> return ret;
> }
> -
> - return 0;
> - }
> -
> - /* Sequential zone file. */
> - zone->file = zloop_filp_open_fmt(oflags, 0600, "%s/%u/seq-%06u",
> - zlo->base_dir, zlo->id, zone_no);
> - if (IS_ERR(zone->file)) {
> - pr_err("Failed to open zone %u file %s/%u/seq-%06u (err=%ld)",
> - zone_no, zlo->base_dir, zlo->id, zone_no,
> - PTR_ERR(zone->file));
> - return PTR_ERR(zone->file);
> - }
> -
> - if (!zlo->block_size) {
> - ret = zloop_get_block_size(zlo, zone);
> - if (ret)
> - return ret;
> + } else {
> + /* Sequential zone file. */
> + mutex_lock(&zone->lock);
> + ret = zloop_update_seq_zone(zlo, zone_no);
> + mutex_unlock(&zone->lock);
> }
>
> - mutex_lock(&zone->lock);
> - ret = zloop_update_seq_zone(zlo, zone_no);
> - mutex_unlock(&zone->lock);
> -
> return ret;
> }
>
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2026-10-30 1:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 15:03 zloop fixes Christoph Hellwig
2026-10-29 15:03 ` [PATCH 1/4] zloop: remove a duplicate call to zloop_get_block_size Christoph Hellwig
2026-10-30 1:11 ` Damien Le Moal
2026-10-29 15:03 ` [PATCH 2/4] zloop: share more code for opening a zone backing file Christoph Hellwig
2026-10-30 1:10 ` Damien Le Moal [this message]
2026-10-29 15:03 ` [PATCH 3/4] zloop: fput file after failed zone init Christoph Hellwig
2026-10-30 1:11 ` Damien Le Moal
2026-10-29 15:03 ` [PATCH 4/4] zloop: check that the zone backing file support ->{read,write}_iter Christoph Hellwig
2026-10-30 1:11 ` Damien Le Moal
2026-10-29 15:34 ` zloop fixes Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e6bd8068-2c8a-4d96-bcaf-2191e0123026@kernel.org \
--to=dlemoal@kernel.org \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox