public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@kernel.org>
To: hch@lst.de
Cc: axboe@kernel.dk, dm-devel@lists.linux.dev,
	linux-block@vger.kernel.org, mpatocka@redhat.com,
	Abelardo Ricart III <aricart@memnix.com>,
	Brandon Smith <freedom@reardencode.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ming Lei <ming.lei@redhat.com>, Mike Snitzer <snitzer@kernel.org>
Subject: [PATCH for-6.10 2/2] dm: use queue_limits_set
Date: Thu, 11 Apr 2024 16:15:29 -0400	[thread overview]
Message-ID: <20240411201529.44846-3-snitzer@kernel.org> (raw)
In-Reply-To: <ZfDeMn6V8WzRUws3@infradead.org>

From: Christoph Hellwig <hch@lst.de>

Use queue_limits_set which validates the limits and takes care of
updating the readahead settings instead of directly assigning them to
the queue.  For that make sure all limits are actually updated before
the assignment.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
---
 drivers/md/dm-table.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 41f1d731ae5a..88114719fe18 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1963,26 +1963,27 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
 	bool wc = false, fua = false;
 	int r;
 
-	/*
-	 * Copy table's limits to the DM device's request_queue
-	 */
-	q->limits = *limits;
-
 	if (dm_table_supports_nowait(t))
 		blk_queue_flag_set(QUEUE_FLAG_NOWAIT, q);
 	else
 		blk_queue_flag_clear(QUEUE_FLAG_NOWAIT, q);
 
 	if (!dm_table_supports_discards(t)) {
-		q->limits.max_discard_sectors = 0;
-		q->limits.max_hw_discard_sectors = 0;
-		q->limits.discard_granularity = 0;
-		q->limits.discard_alignment = 0;
-		q->limits.discard_misaligned = 0;
+		limits->max_hw_discard_sectors = 0;
+		limits->discard_granularity = 0;
+		limits->discard_alignment = 0;
+		limits->discard_misaligned = 0;
 	}
 
+	if (!dm_table_supports_write_zeroes(t))
+		limits->max_write_zeroes_sectors = 0;
+
 	if (!dm_table_supports_secure_erase(t))
-		q->limits.max_secure_erase_sectors = 0;
+		limits->max_secure_erase_sectors = 0;
+
+	r = queue_limits_set(q, limits);
+	if (r)
+		return r;
 
 	if (dm_table_supports_flush(t, (1UL << QUEUE_FLAG_WC))) {
 		wc = true;
@@ -2007,9 +2008,6 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
 	else
 		blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
 
-	if (!dm_table_supports_write_zeroes(t))
-		q->limits.max_write_zeroes_sectors = 0;
-
 	dm_table_verify_integrity(t);
 
 	/*
@@ -2047,7 +2045,6 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
 	}
 
 	dm_update_crypto_profile(q, t);
-	disk_update_readahead(t->md->disk);
 
 	/*
 	 * Check for request-based device is left to
-- 
2.40.0


  parent reply	other threads:[~2024-04-11 20:15 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-10 20:30 [GIT PULL] Block updates for 6.9-rc1 Jens Axboe
2024-03-11 19:43 ` pr-tracker-bot
2024-03-11 23:50 ` Johannes Weiner
2024-03-11 23:53   ` Jens Axboe
2024-03-11 23:58   ` Linus Torvalds
2024-03-12  0:02     ` Jens Axboe
2024-03-12  0:21       ` Linus Torvalds
2024-03-12  0:28         ` Mike Snitzer
2024-03-12  1:03           ` Jens Axboe
2024-03-12  1:09           ` Christoph Hellwig
2024-03-12  1:17             ` Jens Axboe
2024-03-12  1:20               ` Linus Torvalds
2024-03-12  1:23                 ` Jens Axboe
2024-03-12  1:28                   ` Linus Torvalds
2024-03-12  1:37                     ` Jens Axboe
2024-03-12 16:39                       ` Keith Busch
2024-03-12 11:53                   ` Christoph Hellwig
2024-03-12 15:25                     ` Jens Axboe
2024-03-12 11:52                 ` Christoph Hellwig
2024-03-12 15:22             ` Mike Snitzer
2024-03-12 16:28               ` Keith Busch
2024-03-12 21:10               ` Christoph Hellwig
2024-03-12 22:22                 ` Mike Snitzer
2024-03-12 22:30                   ` Christoph Hellwig
2024-03-12 22:50                     ` Mike Snitzer
2024-03-12 22:58                       ` Christoph Hellwig
2024-04-11 20:15                         ` [PATCH for-6.10 0/2] dm: use late bio-splitting and queue_limits_set Mike Snitzer
2024-04-11 20:15                         ` [PATCH for-6.10 1/2] dm-crypt: stop constraining max_segment_size to PAGE_SIZE Mike Snitzer
2024-04-12  6:11                           ` Christoph Hellwig
2024-04-15 14:08                           ` Mikulas Patocka
2024-04-23  7:32                           ` Ming Lei
2024-04-11 20:15                         ` Mike Snitzer [this message]
2024-04-23  7:33                           ` [PATCH for-6.10 2/2] dm: use queue_limits_set Ming Lei
2024-03-13 13:11                 ` [GIT PULL] Block updates for 6.9-rc1 Ming Lei
2024-03-12  1:01         ` Jens Axboe
2024-03-12  0:25       ` Mike Snitzer

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=20240411201529.44846-3-snitzer@kernel.org \
    --to=snitzer@kernel.org \
    --cc=aricart@memnix.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@lists.linux.dev \
    --cc=freedom@reardencode.com \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=mpatocka@redhat.com \
    --cc=torvalds@linux-foundation.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