Patch "nvmet: fix ns enable/disable possible hang" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    nvmet: fix ns enable/disable possible hang

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     nvmet-fix-ns-enable-disable-possible-hang.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit abe9ae27c0b20c597426cb36287fb5a96a6597d7
Author: Sagi Grimberg <sagi@xxxxxxxxxxx>
Date:   Tue May 21 23:20:28 2024 +0300

    nvmet: fix ns enable/disable possible hang
    
    [ Upstream commit f97914e35fd98b2b18fb8a092e0a0799f73afdfe ]
    
    When disabling an nvmet namespace, there is a period where the
    subsys->lock is released, as the ns disable waits for backend IO to
    complete, and the ns percpu ref to be properly killed. The original
    intent was to avoid taking the subsystem lock for a prolong period as
    other processes may need to acquire it (for example new incoming
    connections).
    
    However, it opens up a window where another process may come in and
    enable the ns, (re)intiailizing the ns percpu_ref, causing the disable
    sequence to hang.
    
    Solve this by taking the global nvmet_config_sem over the entire configfs
    enable/disable sequence.
    
    Fixes: a07b4970f464 ("nvmet: add a generic NVMe target")
    Signed-off-by: Sagi Grimberg <sagi@xxxxxxxxxxx>
    Reviewed-by: Christoph Hellwig <hch@xxxxxx>
    Reviewed-by: Chaitanya Kulkarni <kch@xxxxxxxxxx>
    Signed-off-by: Keith Busch <kbusch@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index f999e18e4561d..384cd2b540d0c 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -538,10 +538,18 @@ static ssize_t nvmet_ns_enable_store(struct config_item *item,
 	if (kstrtobool(page, &enable))
 		return -EINVAL;
 
+	/*
+	 * take a global nvmet_config_sem because the disable routine has a
+	 * window where it releases the subsys-lock, giving a chance to
+	 * a parallel enable to concurrently execute causing the disable to
+	 * have a misaccounting of the ns percpu_ref.
+	 */
+	down_write(&nvmet_config_sem);
 	if (enable)
 		ret = nvmet_ns_enable(ns);
 	else
 		nvmet_ns_disable(ns);
+	up_write(&nvmet_config_sem);
 
 	return ret ? ret : count;
 }




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux