From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>, Damien Le Moal <dlemoal@kernel.org>
Cc: linux-block@vger.kernel.org
Subject: [PATCH 5/6] zloop: factor out zloop_mark_{full,empty} helpers
Date: Tue, 14 Apr 2026 10:17:50 +0200 [thread overview]
Message-ID: <20260414081811.549755-6-hch@lst.de> (raw)
In-Reply-To: <20260414081811.549755-1-hch@lst.de>
Move a few chunks of duplicated code into helpers.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/block/zloop.c | 48 +++++++++++++++++++++++--------------------
1 file changed, 26 insertions(+), 22 deletions(-)
diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
index 7257188dd3a8..3f69206d674a 100644
--- a/drivers/block/zloop.c
+++ b/drivers/block/zloop.c
@@ -288,6 +288,24 @@ static bool zloop_do_open_zone(struct zloop_device *zlo,
}
}
+static void zloop_mark_full(struct zloop_device *zlo, struct zloop_zone *zone)
+{
+ lockdep_assert_held(&zone->wp_lock);
+
+ zloop_lru_remove_open_zone(zlo, zone);
+ zone->cond = BLK_ZONE_COND_FULL;
+ zone->wp = ULLONG_MAX;
+}
+
+static void zloop_mark_empty(struct zloop_device *zlo, struct zloop_zone *zone)
+{
+ lockdep_assert_held(&zone->wp_lock);
+
+ zloop_lru_remove_open_zone(zlo, zone);
+ zone->cond = BLK_ZONE_COND_EMPTY;
+ zone->wp = zone->start;
+}
+
static int zloop_update_seq_zone(struct zloop_device *zlo, unsigned int zone_no)
{
struct zloop_zone *zone = &zlo->zones[zone_no];
@@ -321,13 +339,9 @@ static int zloop_update_seq_zone(struct zloop_device *zlo, unsigned int zone_no)
spin_lock_irqsave(&zone->wp_lock, flags);
if (!file_sectors) {
- zloop_lru_remove_open_zone(zlo, zone);
- zone->cond = BLK_ZONE_COND_EMPTY;
- zone->wp = zone->start;
+ zloop_mark_empty(zlo, zone);
} else if (file_sectors == zlo->zone_capacity) {
- zloop_lru_remove_open_zone(zlo, zone);
- zone->cond = BLK_ZONE_COND_FULL;
- zone->wp = ULLONG_MAX;
+ zloop_mark_full(zlo, zone);
} else {
if (zone->cond != BLK_ZONE_COND_IMP_OPEN &&
zone->cond != BLK_ZONE_COND_EXP_OPEN)
@@ -429,9 +443,7 @@ static int zloop_reset_zone(struct zloop_device *zlo, unsigned int zone_no)
}
spin_lock_irqsave(&zone->wp_lock, flags);
- zloop_lru_remove_open_zone(zlo, zone);
- zone->cond = BLK_ZONE_COND_EMPTY;
- zone->wp = zone->start;
+ zloop_mark_empty(zlo, zone);
clear_bit(ZLOOP_ZONE_SEQ_ERROR, &zone->flags);
spin_unlock_irqrestore(&zone->wp_lock, flags);
@@ -477,9 +489,7 @@ static int zloop_finish_zone(struct zloop_device *zlo, unsigned int zone_no)
}
spin_lock_irqsave(&zone->wp_lock, flags);
- zloop_lru_remove_open_zone(zlo, zone);
- zone->cond = BLK_ZONE_COND_FULL;
- zone->wp = ULLONG_MAX;
+ zloop_mark_full(zlo, zone);
clear_bit(ZLOOP_ZONE_SEQ_ERROR, &zone->flags);
spin_unlock_irqrestore(&zone->wp_lock, flags);
@@ -616,11 +626,8 @@ static int zloop_seq_write_prep(struct zloop_cmd *cmd)
*/
if (!is_append || !zlo->ordered_zone_append) {
zone->wp += nr_sectors;
- if (zone->wp == zone_end) {
- zloop_lru_remove_open_zone(zlo, zone);
- zone->cond = BLK_ZONE_COND_FULL;
- zone->wp = ULLONG_MAX;
- }
+ if (zone->wp == zone_end)
+ zloop_mark_full(zlo, zone);
}
out_unlock:
spin_unlock_irqrestore(&zone->wp_lock, flags);
@@ -873,11 +880,8 @@ static bool zloop_set_zone_append_sector(struct request *rq)
rq->__sector = zone->wp;
zone->wp += blk_rq_sectors(rq);
- if (zone->wp >= zone_end) {
- zloop_lru_remove_open_zone(zlo, zone);
- zone->cond = BLK_ZONE_COND_FULL;
- zone->wp = ULLONG_MAX;
- }
+ if (zone->wp >= zone_end)
+ zloop_mark_full(zlo, zone);
spin_unlock_irqrestore(&zone->wp_lock, flags);
--
2.53.0
next prev parent reply other threads:[~2026-04-14 8:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-14 8:17 zloop fixes Christoph Hellwig
2026-04-14 8:17 ` [PATCH 1/6] zloop: fix write pointer calculation in zloop_forget_cache Christoph Hellwig
2026-04-14 9:26 ` Damien Le Moal
2026-04-14 8:17 ` [PATCH 2/6] zloop: use vfs_truncate Christoph Hellwig
2026-04-14 9:26 ` Damien Le Moal
2026-04-14 8:17 ` [PATCH 3/6] zloop: improve the unaligned write pointer warning Christoph Hellwig
2026-04-14 9:27 ` Damien Le Moal
2026-04-14 8:17 ` [PATCH 4/6] zloop: set RQF_QUIET when completing requests on deleted devices Christoph Hellwig
2026-04-14 9:28 ` Damien Le Moal
2026-04-14 8:17 ` Christoph Hellwig [this message]
2026-04-14 9:29 ` [PATCH 5/6] zloop: factor out zloop_mark_{full,empty} helpers Damien Le Moal
2026-04-14 8:17 ` [PATCH 6/6] zloop: remove irq-safe locking Christoph Hellwig
2026-04-14 9:30 ` Damien Le Moal
2026-04-14 16:20 ` zloop fixes Johannes Thumshirn
2026-04-15 20:03 ` 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=20260414081811.549755-6-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=dlemoal@kernel.org \
--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