block: clear zone write plugging flag before failing rejected BIOs
Subsystems (2)
PATCH 1/1 block: clear zone write plugging flag before failing rejected BIOs
From: Jackie Liu <[email protected]>
Commit fe0418eb9bd6 ("block: Prevent potential deadlocks in zone write plug error recovery") changed blk_zone_wplug_handle_write() to fail BIOs directly when blk_zone_wplug_prepare_bio() rejects them, for example because the write is not aligned to the cached write pointer or the plug needs a write pointer update. However, the BIO is already marked with BIO_ZONE_WRITE_PLUGGING at that point even though it is not issued.
Completing such a BIO with bio_io_error() makes bio_endio() call blk_zone_write_plug_bio_endio(), which treats the completion as a failed device write and may poison the cached zone write pointer state by setting BLK_ZONE_WPLUG_NEED_WP_UPDATE.
Clear BIO_ZONE_WRITE_PLUGGING and drop the zone write plug reference before failing the rejected BIO.
--- block/blk-zoned.c | 2 ++ 1 file changed, 2 insertions(+)
block/blk-zoned.c +2 -0
@@ -1502,7 +1502,9 @@ static bool blk_zone_wplug_handle_write(struct bio *bio, unsigned int nr_segs) goto queue_bio;if (!blk_zone_wplug_prepare_bio (zwplug, bio)) { +bio_clear_flag (bio,BIO_ZONE_WRITE_PLUGGING );spin_unlock_irqrestore (&zwplug->lock, flags); +disk_put_zone_wplug (zwplug);bio_io_error (bio);return true; }
Signature · 1 line
2.54.0
Damien Le Moal
maintainerQuoted 9 lines · Jackie Liu
From: Jackie Liu <[email protected]>
Commit
fe0418eb9bd6("block: Prevent potential deadlocks in zone write plug error recovery") changedblk_zone_wplug_handle_write()to fail BIOs directly whenblk_zone_wplug_prepare_bio()rejects them, for example because the write is not aligned to the cached write pointer or the plug needs a write pointer update. However, the BIO is already marked withBIO_ZONE_WRITE_PLUGGINGat that point even though it is not issued.
Quoted 4 lines
Completing such a BIO with
bio_io_error()makesbio_endio()callblk_zone_write_plug_bio_endio(), which treats the completion as a failed device write and may poison the cached zone write pointer state by settingBLK_ZONE_WPLUG_NEED_WP_UPDATE.
Yes, true. But you did not explain clearly why that is a problem. After all, if we hit this case, the user issued an unaligned BIO, and so forcing it to do a report zones to get everything in sync and the correct write pointer is not a bad thing.
If fe0418eb9bd6 change is actually causing you problems, please describe that problem clearly. But ideally, I do not want to special case some error completions over others and prefer to have a single error path that result in the same state for the zone write plugs, regardless of a write error root cause.
Quoted 25 lines
Clear
BIO_ZONE_WRITE_PLUGGINGand drop the zone write plug reference before failing the rejected BIO.Fixes fe0418eb9bd6 ("block: Prevent potential deadlocks in zone write plug error recovery")Cc [email protected] # 6.13+Signed-off-by Jackie Liu <[email protected]>--- block/blk-zoned.c | 2 ++ 1 file changed, 2 insertions(+)block/blk-zoned.c +2
-0@@ -1502,7 +1502,9 @@ static bool blk_zone_wplug_handle_write(struct bio *bio, unsigned int nr_segs) goto queue_bio;if (!blk_zone_wplug_prepare_bio (zwplug, bio)) { +bio_clear_flag (bio,BIO_ZONE_WRITE_PLUGGING );spin_unlock_irqrestore (&zwplug->lock, flags); +disk_put_zone_wplug (zwplug);bio_io_error (bio);return true; }
Signature · 2 lines
Damien Le Moal Western Digital Research
2026年6月8日 19:42, "Damien Le Moal" <[email protected] mailto:[email protected]?to=%22Damien%20Le%20Moal%22%20%3Cdlemoal%40kernel.org%3E > 写到:
Quoted 23 lines · Jackie Liu
Quoted 11 lines
From: Jackie Liu <[email protected]>
Commit
fe0418eb9bd6("block: Prevent potential deadlocks in zone write plug error recovery") changedblk_zone_wplug_handle_write()to fail BIOs directly whenblk_zone_wplug_prepare_bio()rejects them, for example because the write is not aligned to the cached write pointer or the plug needs a write pointer update. However, the BIO is already marked withBIO_ZONE_WRITE_PLUGGINGat that point even though it is not issued.Quoted 5 lines
Completing such a BIO with
bio_io_error()makesbio_endio()callblk_zone_write_plug_bio_endio(), which treats the completion as a failed device write and may poison the cached zone write pointer state by settingBLK_ZONE_WPLUG_NEED_WP_UPDATE.Yes, true. But you did not explain clearly why that is a problem. After all, if we hit this case, the user issued an unaligned BIO, and so forcing it to do a report zones to get everything in sync and the correct write pointer is not a bad thing.
Quoted 4 lines
If
fe0418eb9bd6change is actually causing you problems, please describe that problem clearly. But ideally, I do not want to special case some error completions over others and prefer to have a single error path that result in the same state for the zone write plugs, regardless of a write error root cause.
Thanks for the review. I agree that the changelog did not describe a concrete user-visible problem clearly enough.
I was treating NEED_WP_UPDATE on a BIO rejected before submission as stale state poisoning, because no device write was actually issued. But as you pointed out, for an invalid/non-sequential write, forcing the user to resynchronize the write pointer through report zones is consistent with the current conservative recovery model.
I do not have a concrete regression from fe0418eb9bd6 beyond that extra recovery requirement, so please drop this patch for now.
Thanks.
Jackie
Quoted 31 lines
Quoted 27 lines
Clear
BIO_ZONE_WRITE_PLUGGINGand drop the zone write plug reference before
failing the rejected BIO.Fixes fe0418eb9bd6 ("block: Prevent potential deadlocks in zone write plug error recovery")Cc [email protected] # 6.13+Signed-off-by Jackie Liu <[email protected]>---
block/blk-zoned.c | 2 ++ 1 file changed, 2 insertions(+)diff --git
a/block/blk-zoned.cb/block/blk-zoned.c
index6a221c180889..855767d8bfc1100644
---a/block/blk-zoned.c
+++b/block/blk-zoned.c
@@ -1502,7 +1502,9 @@ static boolblk_zone_wplug_handle_write(struct bio *bio, unsigned int nr_segs)gotoqueue_bio;if (!blk_zone_wplug_prepare_bio(zwplug, bio)) {
+bio_clear_flag(bio, BIO_ZONE_WRITE_PLUGGING);
spin_unlock_irqrestore(&zwplug->lock, flags);
+disk_put_zone_wplug(zwplug);
bio_io_error(bio);
return true;
}Signature · 2 lines
Damien Le Moal Western Digital Research