From: Christoph Hellwig <hch@lst.de>
To: Nilay Shroff <nilay@linux.ibm.com>
Cc: linux-block@vger.kernel.org, hch@lst.de, ming.lei@redhat.com,
dlemoal@kernel.org, hare@suse.de, axboe@kernel.dk,
gjoyce@ibm.com
Subject: Re: [PATCH] block: protect debugfs attributes using q->elevator_lock
Date: Wed, 12 Mar 2025 15:12:51 +0100 [thread overview]
Message-ID: <20250312141251.GA13250@lst.de> (raw)
In-Reply-To: <20250312102903.3584358-1-nilay@linux.ibm.com>
On Wed, Mar 12, 2025 at 03:58:38PM +0530, Nilay Shroff wrote:
> Additionally, debugfs attribute "busy" is currently unprotected. This
> attribute iterates over all started requests in a tagset and prints them.
> However, the tags can be updated simultaneously via the sysfs attribute
> "nr_requests" or "scheduler" (elevator switch), leading to potential race
> conditions. Since the sysfs attributes "nr_requests" and "scheduler" are
> already protected using q->elevator_lock, extend this protection to the
> debugfs "busy" attribute as well.
I'd split that into a separate patch for bisectability.
> struct show_busy_params params = { .m = m, .hctx = hctx };
> + int res;
>
> + res = mutex_lock_interruptible(&hctx->queue->elevator_lock);
> + if (res)
> + goto out;
Is mutex_lock_interruptible really the right primitive here? We don't
really want this read system call interrupted by random signals, do
we? I guess this should be mutex_lock_killable.
(and the same for the existing methods this is copy and pasted from).
> blk_mq_tagset_busy_iter(hctx->queue->tag_set, hctx_show_busy_rq,
> ¶ms);
> -
> - return 0;
> + mutex_unlock(&hctx->queue->elevator_lock);
> +out:
> + return res;
And as Damien already said, no need for the labels here, including for
the existing code. That should probably be alsot changed in an extra
patch for the existing code while you're at it.
next prev parent reply other threads:[~2025-03-12 14:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-12 10:28 [PATCH] block: protect debugfs attributes using q->elevator_lock Nilay Shroff
2025-03-12 10:51 ` Damien Le Moal
2025-03-12 11:03 ` Nilay Shroff
2025-03-12 11:08 ` Nilay Shroff
2025-03-12 14:12 ` Christoph Hellwig [this message]
2025-03-12 15:19 ` Nilay Shroff
2025-03-13 7:54 ` Christoph Hellwig
2025-03-13 11:48 ` 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=20250312141251.GA13250@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=dlemoal@kernel.org \
--cc=gjoyce@ibm.com \
--cc=hare@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=nilay@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox