<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/git/stable/linux-stable.git/block/blk-sysfs.c, branch linux-6.15.y</title>
<subtitle>Linux kernel stable tree</subtitle>
<id>https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/atom?h=linux-6.15.y</id>
<link rel='self' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/atom?h=linux-6.15.y'/>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/'/>
<updated>2025-07-24T06:58:34+00:00</updated>
<entry>
<title>block: fix kobject leak in blk_unregister_queue</title>
<updated>2025-07-24T06:58:34+00:00</updated>
<author>
<name>Ming Lei</name>
<email>ming.lei@redhat.com</email>
</author>
<published>2025-07-11T08:30:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=d3c48fc43319183365a49057078ab88123acc22d'/>
<id>urn:sha1:d3c48fc43319183365a49057078ab88123acc22d</id>
<content type='text'>
[ Upstream commit 3051247e4faa32a3d90c762a243c2c62dde310db ]

The kobject for the queue, `disk-&gt;queue_kobj`, is initialized with a
reference count of 1 via `kobject_init()` in `blk_register_queue()`.
While `kobject_del()` is called during the unregister path to remove
the kobject from sysfs, the initial reference is never released.

Add a call to `kobject_put()` in `blk_unregister_queue()` to properly
decrement the reference count and fix the leak.

Fixes: 2bd85221a625 ("block: untangle request_queue refcounting from sysfs")
Cc: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Ming Lei &lt;ming.lei@redhat.com&gt;
Link: https://lore.kernel.org/r/20250711083009.2574432-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>block: fix resource leak in blk_register_queue() error path</title>
<updated>2025-04-14T14:28:26+00:00</updated>
<author>
<name>Zheng Qixing</name>
<email>zhengqixing@huawei.com</email>
</author>
<published>2025-04-12T09:25:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=40f2eb9b531475dd01b683fdaf61ca3cfd03a51e'/>
<id>urn:sha1:40f2eb9b531475dd01b683fdaf61ca3cfd03a51e</id>
<content type='text'>
When registering a queue fails after blk_mq_sysfs_register() is
successful but the function later encounters an error, we need
to clean up the blk_mq_sysfs resources.

Add the missing blk_mq_sysfs_unregister() call in the error path
to properly clean up these resources and prevent a memory leak.

Fixes: 320ae51feed5 ("blk-mq: new multi-queue block IO queueing mechanism")
Signed-off-by: Zheng Qixing &lt;zhengqixing@huawei.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Yu Kuai &lt;yukuai3@huawei.com&gt;
Link: https://lore.kernel.org/r/20250412092554.475218-1-zhengqixing@huaweicloud.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>block: fix a comment in the queue_attrs[] array</title>
<updated>2025-03-18T13:54:50+00:00</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@lst.de</email>
</author>
<published>2025-03-12T15:01:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=b0d42581195603f38184d7c130d0e2f43f40fb33'/>
<id>urn:sha1:b0d42581195603f38184d7c130d0e2f43f40fb33</id>
<content type='text'>
queue_ra_entry uses limits_lock just like the attributes above it.

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Chaitanya Kulkarni &lt;kch@nvidia.com&gt;
Reviewed-by: Nilay Shroff &lt;nilay@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20250312150127.703534-1-hch@lst.de
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>block: protect read_ahead_kb using q-&gt;limits_lock</title>
<updated>2025-03-10T13:30:19+00:00</updated>
<author>
<name>Nilay Shroff</name>
<email>nilay@linux.ibm.com</email>
</author>
<published>2025-03-04T10:22:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=5e40f4452dc9a3fb44d13bb6bc7032f3911a2675'/>
<id>urn:sha1:5e40f4452dc9a3fb44d13bb6bc7032f3911a2675</id>
<content type='text'>
The bdi-&gt;ra_pages could be updated under q-&gt;limits_lock because it's
usually calculated from the queue limits by queue_limits_commit_update.
So protect reading/writing the sysfs attribute read_ahead_kb using
q-&gt;limits_lock instead of q-&gt;sysfs_lock.

Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.de&gt;
Reviewed-by: Ming Lei &lt;ming.lei@redhat.com&gt;
Signed-off-by: Nilay Shroff &lt;nilay@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20250304102551.2533767-8-nilay@linux.ibm.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>block: protect wbt_lat_usec using q-&gt;elevator_lock</title>
<updated>2025-03-10T13:30:18+00:00</updated>
<author>
<name>Nilay Shroff</name>
<email>nilay@linux.ibm.com</email>
</author>
<published>2025-03-04T10:22:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=245618f8e45ff4f79327627b474b563da71c2c75'/>
<id>urn:sha1:245618f8e45ff4f79327627b474b563da71c2c75</id>
<content type='text'>
The wbt latency and state could be updated while initializing the
elevator or exiting the elevator. It could be also updated while
configuring IO latency QoS parameters using cgroup. The elevator
code path is now protected with q-&gt;elevator_lock. So we should
protect the access to sysfs attribute wbt_lat_usec using q-&gt;elevator
_lock instead of q-&gt;sysfs_lock. White we're at it, also protect
ioc_qos_write(), which configures wbt parameters via cgroup, using
q-&gt;elevator_lock.

Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.de&gt;
Reviewed-by: Ming Lei &lt;ming.lei@redhat.com&gt;
Signed-off-by: Nilay Shroff &lt;nilay@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20250304102551.2533767-7-nilay@linux.ibm.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>block: protect nr_requests update using q-&gt;elevator_lock</title>
<updated>2025-03-10T13:30:18+00:00</updated>
<author>
<name>Nilay Shroff</name>
<email>nilay@linux.ibm.com</email>
</author>
<published>2025-03-04T10:22:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=3efe7571c3ae2b6481253a2616c2bb3fbadd503b'/>
<id>urn:sha1:3efe7571c3ae2b6481253a2616c2bb3fbadd503b</id>
<content type='text'>
The sysfs attribute nr_requests could be simultaneously updated from
elevator switch/update or nr_hw_queue update code path. The update to
nr_requests for each of those code paths runs holding q-&gt;elevator_lock.
So we should protect access to sysfs attribute nr_requests using q-&gt;
elevator_lock instead of q-&gt;sysfs_lock.

Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.de&gt;
Reviewed-by: Ming Lei &lt;ming.lei@redhat.com&gt;
Signed-off-by: Nilay Shroff &lt;nilay@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20250304102551.2533767-6-nilay@linux.ibm.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>block: introduce a dedicated lock for protecting queue elevator updates</title>
<updated>2025-03-10T13:30:18+00:00</updated>
<author>
<name>Nilay Shroff</name>
<email>nilay@linux.ibm.com</email>
</author>
<published>2025-03-04T10:22:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=1bf70d08cc3b55abd1763e6dff5855cb8dd8318b'/>
<id>urn:sha1:1bf70d08cc3b55abd1763e6dff5855cb8dd8318b</id>
<content type='text'>
A queue's elevator can be updated either when modifying nr_hw_queues
or through the sysfs scheduler attribute. Currently, elevator switching/
updating is protected using q-&gt;sysfs_lock, but this has led to lockdep
splats[1] due to inconsistent lock ordering between q-&gt;sysfs_lock and
the freeze-lock in multiple block layer call sites.

As the scope of q-&gt;sysfs_lock is not well-defined, its (mis)use has
resulted in numerous lockdep warnings. To address this, introduce a new
q-&gt;elevator_lock, dedicated specifically for protecting elevator
switches/updates. And we'd now use this new q-&gt;elevator_lock instead of
q-&gt;sysfs_lock for protecting elevator switches/updates.

While at it, make elv_iosched_load_module() a static function, as it is
only called from elv_iosched_store(). Also, remove redundant parameters
from elv_iosched_load_module() function signature.

[1] https://lore.kernel.org/all/67637e70.050a0220.3157ee.000c.GAE@google.com/

Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.de&gt;
Reviewed-by: Ming Lei &lt;ming.lei@redhat.com&gt;
Signed-off-by: Nilay Shroff &lt;nilay@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20250304102551.2533767-5-nilay@linux.ibm.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>block: remove q-&gt;sysfs_lock for attributes which don't need it</title>
<updated>2025-03-10T13:30:18+00:00</updated>
<author>
<name>Nilay Shroff</name>
<email>nilay@linux.ibm.com</email>
</author>
<published>2025-03-04T10:22:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=d23977fee1ee838316fb1b00945064a146460843'/>
<id>urn:sha1:d23977fee1ee838316fb1b00945064a146460843</id>
<content type='text'>
There're few sysfs attributes in block layer which don't really need
acquiring q-&gt;sysfs_lock while accessing it. The reason being, reading/
writing a value from/to such attributes are either atomic or could be
easily protected using READ_ONCE()/WRITE_ONCE(). Moreover, sysfs
attributes are inherently protected with sysfs/kernfs internal locking.

So this change help segregate all existing sysfs attributes for which
we could avoid acquiring q-&gt;sysfs_lock. For all read-only attributes
we removed the q-&gt;sysfs_lock from show method of such attributes. In
case attribute is read/write then we removed the q-&gt;sysfs_lock from
both show and store methods of these attributes.

We audited all block sysfs attributes and found following list of
attributes which shouldn't require q-&gt;sysfs_lock protection:

1. io_poll:
   Write to this attribute is ignored. So, we don't need q-&gt;sysfs_lock.

2. io_poll_delay:
   Write to this attribute is NOP, so we don't need q-&gt;sysfs_lock.

3. io_timeout:
   Write to this attribute updates q-&gt;rq_timeout and read of this
   attribute returns the value stored in q-&gt;rq_timeout Moreover, the
   q-&gt;rq_timeout is set only once when we init the queue (under blk_mq_
   init_allocated_queue()) even before disk is added. So that means
   that we don't need to protect it with q-&gt;sysfs_lock. As this
   attribute is not directly correlated with anything else simply using
   READ_ONCE/WRITE_ONCE should be enough.

4. nomerges:
   Write to this attribute file updates two q-&gt;flags : QUEUE_FLAG_
   NOMERGES and QUEUE_FLAG_NOXMERGES. These flags are accessed during
   bio-merge which anyways doesn't run with q-&gt;sysfs_lock held.
   Moreover, the q-&gt;flags are updated/accessed with bitops which are
   atomic. So, protecting it with q-&gt;sysfs_lock is not necessary.

5. rq_affinity:
   Write to this attribute file makes atomic updates to q-&gt;flags:
   QUEUE_FLAG_SAME_COMP and QUEUE_FLAG_SAME_FORCE. These flags are
   also accessed from blk_mq_complete_need_ipi() using test_bit macro.
   As read/write to q-&gt;flags uses bitops which are atomic, protecting
   it with q-&gt;stsys_lock is not necessary.

6. nr_zones:
   Write to this attribute happens in the driver probe method (except
   nvme) before disk is added and outside of q-&gt;sysfs_lock or any other
   lock. Moreover nr_zones is defined as "unsigned int" and so reading
   this attribute, even when it's simultaneously being updated on other
   cpu, should not return torn value on any architecture supported by
   linux. So we can avoid using q-&gt;sysfs_lock or any other lock/
   protection while reading this attribute.

7. discard_zeroes_data:
   Reading of this attribute always returns 0, so we don't require
   holding q-&gt;sysfs_lock.

8. write_same_max_bytes
   Reading of this attribute always returns 0, so we don't require
   holding q-&gt;sysfs_lock.

Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.de&gt;
Reviewed-by: Ming Lei &lt;ming.lei@redhat.com&gt;
Signed-off-by: Nilay Shroff &lt;nilay@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20250304102551.2533767-4-nilay@linux.ibm.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>block: move q-&gt;sysfs_lock and queue-freeze under show/store method</title>
<updated>2025-03-10T13:30:18+00:00</updated>
<author>
<name>Nilay Shroff</name>
<email>nilay@linux.ibm.com</email>
</author>
<published>2025-03-04T10:22:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=b07a889e833555735ce72ca4a6d39f4c2ca725ba'/>
<id>urn:sha1:b07a889e833555735ce72ca4a6d39f4c2ca725ba</id>
<content type='text'>
In preparation to further simplify and group sysfs attributes which
don't require locking or require some form of locking other than q-&gt;
limits_lock, move acquire/release of q-&gt;sysfs_lock and queue freeze/
unfreeze under each attributes' respective show/store method.

While we are at it, also remove -&gt;load_module() as it's used to load
the module before queue is freezed. Now as we moved queue-freeze under
-&gt;store(), we could load module directly from the attributes' store
method before we actually start freezing the queue. Currently, the
-&gt;load_module() is only used by "scheduler" attribute, so we now load
the relevant elevator module before we start freezing the queue in
elv_iosched_store().

Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.de&gt;
Reviewed-by: Ming Lei &lt;ming.lei@redhat.com&gt;
Signed-off-by: Nilay Shroff &lt;nilay@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20250304102551.2533767-3-nilay@linux.ibm.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>block: acquire q-&gt;limits_lock while reading sysfs attributes</title>
<updated>2025-03-10T13:30:18+00:00</updated>
<author>
<name>Nilay Shroff</name>
<email>nilay@linux.ibm.com</email>
</author>
<published>2025-03-04T10:22:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=6e51a1279cd60cb93e3379ff140d8fa6c39ecf20'/>
<id>urn:sha1:6e51a1279cd60cb93e3379ff140d8fa6c39ecf20</id>
<content type='text'>
There're few sysfs attributes(RW) whose store method is protected
with q-&gt;limits_lock, however the corresponding show method of these
attributes run holding q-&gt;sysfs_lock and that doesn't make sense
as ideally the show method of these attributes should also run
holding q-&gt;limits_lock instead of q-&gt;sysfs_lock. Hence update the
show method of these sysfs attributes so that reading of these
attributes acquire q-&gt;limits_lock instead of q-&gt;sysfs_lock.

Similarly, there're few sysfs attributes(RO) whose show method is
currently protected with q-&gt;sysfs_lock however updates to these
attributes could occur using atomic limit update APIs such as queue_
limits_start_update() and queue_limits_commit_update() which run
holding q-&gt;limits_lock. So that means that reading these attributes
holding q-&gt;sysfs_lock doesn't make sense. Hence update the show method
of these sysfs attributes(RO) such that they run with holding q-&gt;
limits_lock instead of q-&gt;sysfs_lock.

We have defined a new macro QUEUE_LIM_RO_ENTRY() which uses new -&gt;show_
limit() method and it runs holding q-&gt;limits_lock. All existing sysfs
attributes(RO) which needs protection using q-&gt;limits_lock while
reading have been now updated to use this new macro for initialization.

Also, the existing QUEUE_LIM_RW_ENTRY() is updated to use new -&gt;show_
limit() method for reading attributes instead of existing -&gt;show()
method. As -&gt;show_limit() runs holding q-&gt;limits_lock, the existing
sysfs attributes(RW) requiring protection are now inherently protected
using q-&gt;limits_lock instead of q-&gt;sysfs_lock.

Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.de&gt;
Reviewed-by: Ming Lei &lt;ming.lei@redhat.com&gt;
Signed-off-by: Nilay Shroff &lt;nilay@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20250304102551.2533767-2-nilay@linux.ibm.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
</feed>
