All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@wdc.com>
To: dm-devel@redhat.com, Mike Snitzer <snitzer@redhat.com>,
	linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Subject: [PATCH v5 04/11] dm: Fix dm_accept_partial_bio()
Date: Wed, 26 May 2021 06:24:54 +0900	[thread overview]
Message-ID: <20210525212501.226888-5-damien.lemoal@wdc.com> (raw)
In-Reply-To: <20210525212501.226888-1-damien.lemoal@wdc.com>

Fix dm_accept_partial_bio() to actually check that zone management
commands are not passed as explained in the function documentation
comment. Also, since a zone append operation cannot be split, add
REQ_OP_ZONE_APPEND as a forbidden command.

White lines are added around the group of BUG_ON() calls to make the
code more legible.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/md/dm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index ca2aedd8ee7d..11af20080639 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1237,8 +1237,8 @@ static int dm_dax_zero_page_range(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_RESET,
- * REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH.
+ * allowed for all bio types except REQ_PREFLUSH, REQ_OP_ZONE_* zone management
+ * operations and REQ_OP_ZONE_APPEND (zone append writes).
  *
  * 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
@@ -1268,9 +1268,13 @@ void dm_accept_partial_bio(struct bio *bio, unsigned n_sectors)
 {
 	struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone);
 	unsigned bi_size = bio->bi_iter.bi_size >> SECTOR_SHIFT;
+
 	BUG_ON(bio->bi_opf & REQ_PREFLUSH);
+	BUG_ON(op_is_zone_mgmt(bio_op(bio)));
+	BUG_ON(bio_op(bio) == REQ_OP_ZONE_APPEND);
 	BUG_ON(bi_size > *tio->len_ptr);
 	BUG_ON(n_sectors > bi_size);
+
 	*tio->len_ptr -= bi_size - n_sectors;
 	bio->bi_iter.bi_size = n_sectors << SECTOR_SHIFT;
 }
-- 
2.31.1


WARNING: multiple messages have this Message-ID (diff)
From: Damien Le Moal <damien.lemoal@wdc.com>
To: dm-devel@redhat.com, Mike Snitzer <snitzer@redhat.com>,
	linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Subject: [dm-devel] [PATCH v5 04/11] dm: Fix dm_accept_partial_bio()
Date: Wed, 26 May 2021 06:24:54 +0900	[thread overview]
Message-ID: <20210525212501.226888-5-damien.lemoal@wdc.com> (raw)
In-Reply-To: <20210525212501.226888-1-damien.lemoal@wdc.com>

Fix dm_accept_partial_bio() to actually check that zone management
commands are not passed as explained in the function documentation
comment. Also, since a zone append operation cannot be split, add
REQ_OP_ZONE_APPEND as a forbidden command.

White lines are added around the group of BUG_ON() calls to make the
code more legible.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/md/dm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index ca2aedd8ee7d..11af20080639 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1237,8 +1237,8 @@ static int dm_dax_zero_page_range(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_RESET,
- * REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH.
+ * allowed for all bio types except REQ_PREFLUSH, REQ_OP_ZONE_* zone management
+ * operations and REQ_OP_ZONE_APPEND (zone append writes).
  *
  * 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
@@ -1268,9 +1268,13 @@ void dm_accept_partial_bio(struct bio *bio, unsigned n_sectors)
 {
 	struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone);
 	unsigned bi_size = bio->bi_iter.bi_size >> SECTOR_SHIFT;
+
 	BUG_ON(bio->bi_opf & REQ_PREFLUSH);
+	BUG_ON(op_is_zone_mgmt(bio_op(bio)));
+	BUG_ON(bio_op(bio) == REQ_OP_ZONE_APPEND);
 	BUG_ON(bi_size > *tio->len_ptr);
 	BUG_ON(n_sectors > bi_size);
+
 	*tio->len_ptr -= bi_size - n_sectors;
 	bio->bi_iter.bi_size = n_sectors << SECTOR_SHIFT;
 }
-- 
2.31.1

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  parent reply	other threads:[~2021-05-25 21:25 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-25 21:24 [PATCH v5 00/11] dm: Improve zoned block device support Damien Le Moal
2021-05-25 21:24 ` [dm-devel] " Damien Le Moal
2021-05-25 21:24 ` [PATCH v5 01/11] block: improve handling of all zones reset operation Damien Le Moal
2021-05-25 21:24   ` [dm-devel] " Damien Le Moal
2021-05-26  6:36   ` Hannes Reinecke
2021-05-26  6:36     ` [dm-devel] " Hannes Reinecke
2021-05-25 21:24 ` [PATCH v5 02/11] block: introduce bio zone helpers Damien Le Moal
2021-05-25 21:24   ` [dm-devel] " Damien Le Moal
2021-05-25 21:24 ` [PATCH v5 03/11] block: introduce BIO_ZONE_WRITE_LOCKED bio flag Damien Le Moal
2021-05-25 21:24   ` [dm-devel] " Damien Le Moal
2021-05-25 21:24 ` Damien Le Moal [this message]
2021-05-25 21:24   ` [dm-devel] [PATCH v5 04/11] dm: Fix dm_accept_partial_bio() Damien Le Moal
2021-05-25 21:24 ` [PATCH v5 05/11] dm: cleanup device_area_is_invalid() Damien Le Moal
2021-05-25 21:24   ` [dm-devel] " Damien Le Moal
2021-05-25 21:24 ` [PATCH v5 06/11] dm: move zone related code to dm-zone.c Damien Le Moal
2021-05-25 21:24   ` [dm-devel] " Damien Le Moal
2021-05-25 21:24 ` [PATCH v5 07/11] dm: Introduce dm_report_zones() Damien Le Moal
2021-05-25 21:24   ` [dm-devel] " Damien Le Moal
2021-05-25 21:24 ` [PATCH v5 08/11] dm: Forbid requeue of writes to zones Damien Le Moal
2021-05-25 21:24   ` [dm-devel] " Damien Le Moal
2021-06-04 14:56   ` Mike Snitzer
2021-06-04 14:56     ` [dm-devel] " Mike Snitzer
2021-06-05  0:17     ` Damien Le Moal
2021-06-05  0:17       ` [dm-devel] " Damien Le Moal
2021-05-25 21:24 ` [PATCH v5 09/11] dm: rearrange core declarations Damien Le Moal
2021-05-25 21:24   ` [dm-devel] " Damien Le Moal
2021-05-25 21:25 ` [PATCH v5 10/11] dm: introduce zone append emulation Damien Le Moal
2021-05-25 21:25   ` [dm-devel] " Damien Le Moal
2021-05-26  6:40   ` Hannes Reinecke
2021-05-26  6:40     ` [dm-devel] " Hannes Reinecke
2021-05-25 21:25 ` [PATCH v5 11/11] dm crypt: Fix zoned block device support Damien Le Moal
2021-05-25 21:25   ` [dm-devel] " Damien Le Moal
2021-06-01 22:57 ` [PATCH v5 00/11] dm: Improve " Damien Le Moal
2021-06-01 22:57   ` [dm-devel] " Damien Le Moal
2021-06-02 18:32   ` Mike Snitzer
2021-06-02 18:32     ` [dm-devel] " Mike Snitzer
2021-06-03 17:46     ` Jens Axboe
2021-06-03 17:46       ` [dm-devel] " Jens Axboe
2021-06-03 22:16       ` Mike Snitzer
2021-06-03 22:16         ` [dm-devel] " Mike Snitzer
2021-06-03 23:44         ` Damien Le Moal
2021-06-03 23:44           ` [dm-devel] " 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=20210525212501.226888-5-damien.lemoal@wdc.com \
    --to=damien.lemoal@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=linux-block@vger.kernel.org \
    --cc=snitzer@redhat.com \
    /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.