All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Subject: [PATCH 2/8] block: remove BLK_ZONE_WPLUG_UNHASHED
Date: Sat, 21 Feb 2026 09:44:05 +0900	[thread overview]
Message-ID: <20260221004411.548482-3-dlemoal@kernel.org> (raw)
In-Reply-To: <20260221004411.548482-1-dlemoal@kernel.org>

Detecting that a zone write plug has been removed from a disk hash table
can be done using hlist_unhashed(), so there is no need for the zone
write plug flag BLK_ZONE_WPLUG_UNHASHED. Remove this flag and convert
all tests using it to use hlist_unhashed().

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 block/blk-zoned.c | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 9c38497e7258..3dd50b2ba2bb 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -99,17 +99,9 @@ static inline unsigned int disk_zone_wplugs_hash_size(struct gendisk *disk)
  *    being executed or the zone write plug bio list is not empty.
  *  - BLK_ZONE_WPLUG_NEED_WP_UPDATE: Indicates that we lost track of a zone
  *    write pointer offset and need to update it.
- *  - BLK_ZONE_WPLUG_UNHASHED: Indicates that the zone write plug was removed
- *    from the disk hash table and that the initial reference to the zone
- *    write plug set when the plug was first added to the hash table has been
- *    dropped. This flag is set when a zone is reset, finished or become full,
- *    to prevent new references to the zone write plug to be taken for
- *    newly incoming BIOs. A zone write plug flagged with this flag will be
- *    freed once all remaining references from BIOs or functions are dropped.
  */
 #define BLK_ZONE_WPLUG_PLUGGED		(1U << 0)
 #define BLK_ZONE_WPLUG_NEED_WP_UPDATE	(1U << 1)
-#define BLK_ZONE_WPLUG_UNHASHED		(1U << 2)
 
 /**
  * blk_zone_cond_str - Return a zone condition name string
@@ -592,7 +584,7 @@ static inline void disk_put_zone_wplug(struct blk_zone_wplug *zwplug)
 	if (refcount_dec_and_test(&zwplug->ref)) {
 		WARN_ON_ONCE(!bio_list_empty(&zwplug->bio_list));
 		WARN_ON_ONCE(zwplug->flags & BLK_ZONE_WPLUG_PLUGGED);
-		WARN_ON_ONCE(!(zwplug->flags & BLK_ZONE_WPLUG_UNHASHED));
+		WARN_ON_ONCE(!hlist_unhashed_lockless(&zwplug->node));
 
 		call_rcu(&zwplug->rcu_head, disk_free_zone_wplug_rcu);
 	}
@@ -603,14 +595,14 @@ static inline bool disk_should_remove_zone_wplug(struct gendisk *disk,
 {
 	lockdep_assert_held(&zwplug->lock);
 
-	/* If the zone write plug was already removed, we are done. */
-	if (zwplug->flags & BLK_ZONE_WPLUG_UNHASHED)
-		return false;
-
 	/* If the zone write plug is still plugged, it cannot be removed. */
 	if (zwplug->flags & BLK_ZONE_WPLUG_PLUGGED)
 		return false;
 
+	/* If the zone write plug was already removed, we have nothing to do. */
+	if (hlist_unhashed(&zwplug->node))
+		return false;
+
 	/*
 	 * Completions of BIOs with blk_zone_write_plug_bio_endio() may
 	 * happen after handling a request completion with
@@ -635,16 +627,14 @@ static void disk_remove_zone_wplug(struct gendisk *disk,
 	unsigned long flags;
 
 	/* If the zone write plug was already removed, we have nothing to do. */
-	if (zwplug->flags & BLK_ZONE_WPLUG_UNHASHED)
+	if (hlist_unhashed(&zwplug->node))
 		return;
 
 	/*
-	 * Mark the zone write plug as unhashed and drop the extra reference we
-	 * took when the plug was inserted in the hash table. Also update the
-	 * disk zone condition array with the current condition of the zone
-	 * write plug.
+	 * Update the disk zone condition array with the current condition of
+	 * the zone write plug and drop the extra reference we took when the
+	 * plug was inserted in the hash table.
 	 */
-	zwplug->flags |= BLK_ZONE_WPLUG_UNHASHED;
 	spin_lock_irqsave(&disk->zone_wplugs_lock, flags);
 	blk_zone_set_cond(rcu_dereference_check(disk->zones_cond,
 				lockdep_is_held(&disk->zone_wplugs_lock)),
@@ -702,7 +692,7 @@ static struct blk_zone_wplug *disk_get_and_lock_zone_wplug(struct gendisk *disk,
 		 * we need to get a new plug so start over from the beginning.
 		 */
 		spin_lock_irqsave(&zwplug->lock, *flags);
-		if (zwplug->flags & BLK_ZONE_WPLUG_UNHASHED) {
+		if (hlist_unhashed(&zwplug->node)) {
 			spin_unlock_irqrestore(&zwplug->lock, *flags);
 			disk_put_zone_wplug(zwplug);
 			goto again;
-- 
2.53.0


  parent reply	other threads:[~2026-02-21  0:49 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-21  0:44 [PATCH 0/8] Improve zoned (SMR) HDD write throughput Damien Le Moal
2026-02-21  0:44 ` [PATCH 1/8] block: fix zone write plug removal Damien Le Moal
2026-02-23 11:56   ` Hannes Reinecke
2026-02-23 19:30     ` Bart Van Assche
2026-02-23 20:21       ` Bart Van Assche
2026-02-24  1:57         ` Damien Le Moal
2026-02-21  0:44 ` Damien Le Moal [this message]
2026-02-23 11:48   ` [PATCH 2/8] block: remove BLK_ZONE_WPLUG_UNHASHED Hannes Reinecke
2026-02-24  2:04     ` Damien Le Moal
2026-02-21  0:44 ` [PATCH 3/8] block: remove disk_zone_is_full() Damien Le Moal
2026-02-23 11:56   ` Hannes Reinecke
2026-02-24 13:15   ` Johannes Thumshirn
2026-02-21  0:44 ` [PATCH 4/8] block: improve disk_zone_wplug_schedule_bio_work() Damien Le Moal
2026-02-23 11:59   ` Hannes Reinecke
2026-02-23 18:56     ` Bart Van Assche
2026-02-24  2:03     ` Damien Le Moal
2026-02-24 15:00       ` Hannes Reinecke
2026-02-24 15:08         ` Christoph Hellwig
2026-02-24 13:18   ` Johannes Thumshirn
2026-02-21  0:44 ` [PATCH 5/8] block: rename struct gendisk zone_wplugs_lock field Damien Le Moal
2026-02-23 12:00   ` Hannes Reinecke
2026-02-24 13:19   ` Johannes Thumshirn
2026-02-21  0:44 ` [PATCH 6/8] block: allow submitting all zone writes from a single context Damien Le Moal
2026-02-23 12:07   ` Hannes Reinecke
2026-02-24  2:00     ` Damien Le Moal
2026-02-21  0:44 ` [PATCH 7/8] block: default to QD=1 writes for blk-mq rotational zoned devices Damien Le Moal
2026-02-23 12:07   ` Hannes Reinecke
2026-02-21  0:44 ` [PATCH 8/8] Documentation: ABI: stable: document the zoned_qd1_writes attribute Damien Le Moal
2026-02-23 12:07   ` Hannes Reinecke
2026-02-23 17:03 ` [PATCH 0/8] Improve zoned (SMR) HDD write throughput Bart Van Assche
2026-02-24  1:07   ` Damien Le Moal

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=20260221004411.548482-3-dlemoal@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=axboe@kernel.dk \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.