Skip to content

Commit 792d77b

Browse files
committed
Merge: nvmet: fix ns enable/disable possible hang
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4444 # Merge Request Required Information JIRA: https://issues.redhat.com/browse/RHEL-37676 ## Summary of Changes ## Approved Development Ticket All submissions to CentOS Stream must reference an approved ticket in [Red Hat Jira](https://issues.redhat.com/). Please follow the CentOS Stream [contribution documentation](https://docs.centos.org/en-US/stream-contrib/quickstart/) for how to file this ticket and have it approved. Signed-off-by: Maurizio Lombardi <mlombard@redhat.com> Approved-by: John Meneghini <jmeneghi@redhat.com> Approved-by: Chris Leech <cleech@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Approved-by: Tomas Henzl <thenzl@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents 97720d9 + 30980ea commit 792d77b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/nvme/target/configfs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,18 @@ static ssize_t nvmet_ns_enable_store(struct config_item *item,
676676
if (kstrtobool(page, &enable))
677677
return -EINVAL;
678678

679+
/*
680+
* take a global nvmet_config_sem because the disable routine has a
681+
* window where it releases the subsys-lock, giving a chance to
682+
* a parallel enable to concurrently execute causing the disable to
683+
* have a misaccounting of the ns percpu_ref.
684+
*/
685+
down_write(&nvmet_config_sem);
679686
if (enable)
680687
ret = nvmet_ns_enable(ns);
681688
else
682689
nvmet_ns_disable(ns);
690+
up_write(&nvmet_config_sem);
683691

684692
return ret ? ret : count;
685693
}

0 commit comments

Comments
 (0)