All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nilay Shroff <nilay@linux.ibm.com>
To: linux-block@vger.kernel.org
Cc: hch@lst.de, ming.lei@redhat.com, dlemoal@kernel.org,
	axboe@kernel.dk, gjoyce@ibm.com
Subject: [PATCHv2 5/6] blk-sysfs: protect wbt_lat_usec using q->elevator_lock
Date: Tue, 18 Feb 2025 13:58:58 +0530	[thread overview]
Message-ID: <20250218082908.265283-6-nilay@linux.ibm.com> (raw)
In-Reply-To: <20250218082908.265283-1-nilay@linux.ibm.com>

The wbt latency and state could be updated while initializing the
elevator or exiting the elevator. The elevator code path is now
protected with q->elevator_lock. So we should now protect the access
to sysfs attribute wbt_lat_usec using q->elevator_lock instead of
q->sysfs_lock.

Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
---
 block/blk-sysfs.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 37ac73468d4e..876376bfdac3 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -567,7 +567,7 @@ static ssize_t queue_wb_lat_show(struct gendisk *disk, char *page)
 {
 	int ret;
 
-	mutex_lock(&disk->queue->sysfs_lock);
+	mutex_lock(&disk->queue->elevator_lock);
 
 	if (!wbt_rq_qos(disk->queue)) {
 		ret = -EINVAL;
@@ -581,7 +581,7 @@ static ssize_t queue_wb_lat_show(struct gendisk *disk, char *page)
 				div_u64(wbt_get_min_lat(disk->queue), 1000));
 
 out:
-	mutex_unlock(&disk->queue->sysfs_lock);
+	mutex_unlock(&disk->queue->elevator_lock);
 	return ret;
 }
 
@@ -594,8 +594,8 @@ static ssize_t queue_wb_lat_store(struct gendisk *disk, const char *page,
 	s64 val;
 	unsigned int memflags;
 
-	mutex_lock(&q->sysfs_lock);
 	memflags = blk_mq_freeze_queue(q);
+	mutex_lock(&q->elevator_lock);
 
 	ret = queue_var_store64(&val, page);
 	if (ret < 0)
@@ -634,8 +634,8 @@ static ssize_t queue_wb_lat_store(struct gendisk *disk, const char *page,
 	blk_mq_unquiesce_queue(q);
 
 out:
+	mutex_unlock(&q->elevator_lock);
 	blk_mq_unfreeze_queue(q, memflags);
-	mutex_unlock(&q->sysfs_lock);
 	return ret;
 }
 
@@ -907,11 +907,11 @@ int blk_register_queue(struct gendisk *disk)
 			mutex_unlock(&q->elevator_lock);
 			goto out_crypto_sysfs_unregister;
 		}
+		wbt_enable_default(disk);
 	}
 	mutex_unlock(&q->elevator_lock);
 
 	blk_queue_flag_set(QUEUE_FLAG_REGISTERED, q);
-	wbt_enable_default(disk);
 
 	/* Now everything is ready and send out KOBJ_ADD uevent */
 	kobject_uevent(&disk->queue_kobj, KOBJ_ADD);
-- 
2.47.1


  parent reply	other threads:[~2025-02-18  8:31 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-18  8:28 [PATCHv2 0/6] block: fix lock order and remove redundant locking Nilay Shroff
2025-02-18  8:28 ` [PATCHv2 1/6] blk-sysfs: remove q->sysfs_lock for attributes which don't need it Nilay Shroff
2025-02-18  8:46   ` Christoph Hellwig
2025-02-18 11:26     ` Nilay Shroff
2025-02-21 14:02       ` Nilay Shroff
2025-02-22 12:44         ` Ming Lei
2025-02-24 13:09           ` Nilay Shroff
2025-02-24 14:49           ` Christoph Hellwig
2025-02-26 12:09             ` Nilay Shroff
2025-02-24  8:41         ` Hannes Reinecke
2025-02-24 13:12           ` Nilay Shroff
2025-02-18 12:10   ` Ming Lei
2025-02-18 13:11     ` Nilay Shroff
2025-02-18 13:45       ` Ming Lei
2025-02-18 16:29         ` Christoph Hellwig
2025-02-19  3:24           ` Ming Lei
2025-02-19  5:42             ` Christoph Hellwig
2025-02-19  8:34             ` Nilay Shroff
2025-02-19  8:56               ` Nilay Shroff
2025-02-19  9:20                 ` Ming Lei
2025-02-18  8:28 ` [PATCHv2 2/6] blk-sysfs: acquire q->limits_lock while reading attributes Nilay Shroff
2025-02-18  8:46   ` Christoph Hellwig
2025-02-18  8:28 ` [PATCHv2 3/6] block: Introduce a dedicated lock for protecting queue elevator updates Nilay Shroff
2025-02-18  9:05   ` Christoph Hellwig
2025-02-18 11:14     ` Nilay Shroff
2025-02-18 16:32       ` Christoph Hellwig
2025-02-19  8:41         ` Nilay Shroff
2025-02-18  8:28 ` [PATCHv2 4/6] blk-sysfs: protect nr_requests update using q->elevator_lock Nilay Shroff
2025-02-18  8:28 ` Nilay Shroff [this message]
2025-02-18  8:28 ` [PATCHv2 6/6] blk-sysfs: protect read_ahead_kb using q->limits_lock Nilay Shroff
2025-02-18  9:12   ` Christoph Hellwig
2025-02-18 11:27     ` Nilay Shroff
2025-02-18  9:21 ` [PATCHv2 0/6] block: fix lock order and remove redundant locking Christoph Hellwig
2025-02-18 12:09   ` Nilay Shroff

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=20250218082908.265283-6-nilay@linux.ibm.com \
    --to=nilay@linux.ibm.com \
    --cc=axboe@kernel.dk \
    --cc=dlemoal@kernel.org \
    --cc=gjoyce@ibm.com \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@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.