summaryrefslogtreecommitdiffstats
path: root/block/blk-sysfs.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2024-02-13 08:34:17 +0100
committerJens Axboe <axboe@kernel.dk>2024-02-13 08:56:59 -0700
commitff956a3be95b45b2a823693a8c9db740939ca35e (patch)
treefbe940ff3b81d3c96b877536f27426ec1d6bf323 /block/blk-sysfs.c
parent4f563a64732dabb2677c7d1232a8f714a18b41b3 (diff)
downloadlinux-ff956a3be95b45b2a823693a8c9db740939ca35e.tar.gz
linux-ff956a3be95b45b2a823693a8c9db740939ca35e.tar.bz2
linux-ff956a3be95b45b2a823693a8c9db740939ca35e.zip
block: use queue_limits_commit_update in queue_discard_max_store
Convert queue_discard_max_store to use queue_limits_commit_update to check and update the max_discard_sectors limit and freeze the queue before doing so to ensure we don't have requests in flight while changing the limits. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Link: https://lore.kernel.org/r/20240213073425.1621680-8-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-sysfs.c')
-rw-r--r--block/blk-sysfs.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index a1ec27f0ba41..8c8f69d8ba48 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -175,7 +175,9 @@ static ssize_t queue_discard_max_store(struct request_queue *q,
const char *page, size_t count)
{
unsigned long max_discard_bytes;
+ struct queue_limits lim;
ssize_t ret;
+ int err;
ret = queue_var_store(&max_discard_bytes, page, count);
if (ret < 0)
@@ -187,9 +189,14 @@ static ssize_t queue_discard_max_store(struct request_queue *q,
if ((max_discard_bytes >> SECTOR_SHIFT) > UINT_MAX)
return -EINVAL;
- q->limits.max_user_discard_sectors = max_discard_bytes >> SECTOR_SHIFT;
- q->limits.max_discard_sectors = min(q->limits.max_hw_discard_sectors,
- q->limits.max_user_discard_sectors);
+ blk_mq_freeze_queue(q);
+ lim = queue_limits_start_update(q);
+ lim.max_user_discard_sectors = max_discard_bytes >> SECTOR_SHIFT;
+ err = queue_limits_commit_update(q, &lim);
+ blk_mq_unfreeze_queue(q);
+
+ if (err)
+ return err;
return ret;
}