From: Mikulas Patocka <mpatocka@redhat.com>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
dm-devel@lists.linux.dev, Mike Snitzer <snitzer@kernel.org>,
Bart Van Assche <bvanassche@acm.org>
Subject: Re: [PATCH v3 5/5] dm: Check for forbidden splitting of zone write operations
Date: Wed, 25 Jun 2025 18:31:35 +0200 (CEST) [thread overview]
Message-ID: <aa216c0f-db15-05c4-cf4b-e24d418de761@redhat.com> (raw)
In-Reply-To: <20250625093327.548866-6-dlemoal@kernel.org>
On Wed, 25 Jun 2025, Damien Le Moal wrote:
> DM targets must not split zone append and write operations using
> dm_accept_partial_bio() as doing so is forbidden for zone append BIOs,
> breaks zone append emulation using regular write BIOs and potentially
> creates deadlock situations with queue freeze operations.
>
> Modify dm_accept_partial_bio() to add missing BUG_ON() checks for all
> these cases, that is, check that the BIO is a write or write zeroes
> operation. This change packs all the zone related checks together under
> a static_branch_unlikely(&zoned_enabled) and done only if the target is
> a zoned device.
>
> Fixes: f211268ed1f9 ("dm: Use the block layer zone append emulation")
> Cc: stable@vger.kernel.org
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Mikulas Patocka <mpatocka@redhat.com>
> ---
> drivers/md/dm.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/md/dm.c b/drivers/md/dm.c
> index f1e63c1808b4..f82457e7eed1 100644
> --- a/drivers/md/dm.c
> +++ b/drivers/md/dm.c
> @@ -1286,8 +1286,9 @@ static size_t dm_dax_recovery_write(struct dax_device *dax_dev, pgoff_t pgoff,
> /*
> * A target may call dm_accept_partial_bio only from the map routine. It is
> * allowed for all bio types except REQ_PREFLUSH, REQ_OP_ZONE_* zone management
> - * operations, REQ_OP_ZONE_APPEND (zone append writes) and any bio serviced by
> - * __send_duplicate_bios().
> + * operations, zone append writes (native with REQ_OP_ZONE_APPEND or emulated
> + * with write BIOs flagged with BIO_EMULATES_ZONE_APPEND) and any bio serviced
> + * by __send_duplicate_bios().
> *
> * dm_accept_partial_bio informs the dm that the target only wants to process
> * additional n_sectors sectors of the bio and the rest of the data should be
> @@ -1320,11 +1321,19 @@ void dm_accept_partial_bio(struct bio *bio, unsigned int n_sectors)
> unsigned int bio_sectors = bio_sectors(bio);
>
> BUG_ON(dm_tio_flagged(tio, DM_TIO_IS_DUPLICATE_BIO));
> - BUG_ON(op_is_zone_mgmt(bio_op(bio)));
> - BUG_ON(bio_op(bio) == REQ_OP_ZONE_APPEND);
> BUG_ON(bio_sectors > *tio->len_ptr);
> BUG_ON(n_sectors > bio_sectors);
>
> + if (static_branch_unlikely(&zoned_enabled) &&
> + unlikely(bdev_is_zoned(bio->bi_bdev))) {
> + enum req_op op = bio_op(bio);
> +
> + BUG_ON(op_is_zone_mgmt(op));
> + BUG_ON(op == REQ_OP_WRITE);
> + BUG_ON(op == REQ_OP_WRITE_ZEROES);
> + BUG_ON(op == REQ_OP_ZONE_APPEND);
> + }
> +
> *tio->len_ptr -= bio_sectors - n_sectors;
> bio->bi_iter.bi_size = n_sectors << SECTOR_SHIFT;
>
> --
> 2.49.0
>
next prev parent reply other threads:[~2025-06-25 16:31 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-25 9:33 [PATCH v3 0/5] Fix write operation handling for zoned DM devices Damien Le Moal
2025-06-25 9:33 ` [PATCH v3 1/5] block: Make REQ_OP_ZONE_FINISH a write operation Damien Le Moal
2025-06-25 11:28 ` Christoph Hellwig
2025-06-25 11:42 ` Johannes Thumshirn
2025-06-25 15:44 ` Bart Van Assche
2025-06-25 16:29 ` Bart Van Assche
2025-06-25 23:36 ` Damien Le Moal
2025-06-26 20:29 ` Bart Van Assche
2025-06-25 9:33 ` [PATCH v3 2/5] block: Introduce bio_needs_zone_write_plugging() Damien Le Moal
2025-06-25 11:28 ` Christoph Hellwig
2025-06-25 11:47 ` Johannes Thumshirn
2025-06-25 15:48 ` Bart Van Assche
2025-06-25 23:38 ` Damien Le Moal
2025-06-26 16:37 ` Bart Van Assche
2025-06-25 9:33 ` [PATCH v3 3/5] dm: Always split write BIOs to zoned device limits Damien Le Moal
2025-06-25 11:49 ` Johannes Thumshirn
2025-06-25 16:30 ` Mikulas Patocka
2025-06-25 16:34 ` Bart Van Assche
2025-06-25 23:41 ` Damien Le Moal
2025-06-25 9:33 ` [PATCH v3 4/5] dm: dm-crypt: Do not partially accept write BIOs with zoned targets Damien Le Moal
2025-06-25 16:31 ` Mikulas Patocka
2025-06-25 16:42 ` Bart Van Assche
2025-06-25 9:33 ` [PATCH v3 5/5] dm: Check for forbidden splitting of zone write operations Damien Le Moal
2025-06-25 16:31 ` Mikulas Patocka [this message]
2025-06-25 16:37 ` [PATCH v3 0/5] Fix write operation handling for zoned DM devices 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=aa216c0f-db15-05c4-cf4b-e24d418de761@redhat.com \
--to=mpatocka@redhat.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=dlemoal@kernel.org \
--cc=dm-devel@lists.linux.dev \
--cc=linux-block@vger.kernel.org \
--cc=snitzer@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