diff options
| author | Nilay Shroff <nilay@linux.ibm.com> | 2026-09-18 21:57:31 +0530 |
|---|---|---|
| committer | Keith Busch <kbusch@kernel.org> | 2026-09-25 08:06:21 -0700 |
| commit | 3fdd281e0a049a804b2512c4cb3d685e5358aee8 (patch) | |
| tree | 74b8621b2bfdfcdc2dff260af62f1dfd57e3af27 /tools/perf/scripts/python/stackcollapse.py | |
| parent | 42b0f5196dc2f2113368993317eccbfd1127f298 (diff) | |
| download | linux-next-3fdd281e0a049a804b2512c4cb3d685e5358aee8.tar.gz linux-next-3fdd281e0a049a804b2512c4cb3d685e5358aee8.zip | |
nvmet: don't allow I/O admission after percpu ns reference is killed
nvmet_req_find_ns() uses percpu_ref_get() to obtain a reference to
the namespace. However, percpu_ref_get() can acquire a reference even
after the namespace reference has been killed (or marked DEAD).
This is undesirable during namespace disable because nvmet_ns_disable()
kills the namespace reference and then waits for all outstanding
references to drain. Acquiring a new reference after the reference is
killed can therefore extend the namespace drain period.
Replace percpu_ref_get() in nvmet_req_find_ns() with
percpu_ref_tryget_live_rcu(), which only acquires a reference while
the namespace reference is still live. This handles the race where
nvmet_req_find_ns() finds ns is admitting I/O (or it's live) but before
it acquires the reference to ns, its reference is killed in
nvmet_ns_disable(). For instance check this race:
CPU0 CPU1
nvmet_req_find_ns(): nvmet_ns_disable():
xa_load() -> ns
IO_LIVE == set
xa_clear_mark()
percpu_ref_kill() // DEAD
percpu_ref_get() synchronize_rcu()
| wait_for_completion()
+-- succeed
Replacing percpu_ref_get() with percpu_ref_tryget_live_rcu() prevents
the I/O request from acquiring a namespace reference once the
reference has been marked DEAD.
Perform the namespace lookup and reference acquisition in
nvmet_req_find_ns() within an RCU read-side critical section.
nvmet_ns_disable() uses synchronize_rcu() before draining and exiting
the namespace reference, ensuring that RCU readers which may be
acquiring the namespace reference have completed before the reference
is exited.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python/stackcollapse.py')
0 files changed, 0 insertions, 0 deletions
