Patch "nvme: Fix IOC_PR_CLEAR and IOC_PR_RELEASE ioctls for nvme devices" has been added to the 5.15-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

    nvme: Fix IOC_PR_CLEAR and IOC_PR_RELEASE ioctls for nvme devices

to the 5.15-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:
     nvme-fix-ioc_pr_clear-and-ioc_pr_release-ioctls-for-.patch
and it can be found in the queue-5.15 subdirectory.

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



commit e9df599681f606d3044190930b233b98a3e8ad23
Author: Michael Kelley <mikelley@xxxxxxxxxxxxx>
Date:   Thu Sep 22 21:49:09 2022 -0700

    nvme: Fix IOC_PR_CLEAR and IOC_PR_RELEASE ioctls for nvme devices
    
    [ Upstream commit c292a337d0e45a292c301e3cd51c35aa0ae91e95 ]
    
    The IOC_PR_CLEAR and IOC_PR_RELEASE ioctls are
    non-functional on NVMe devices because the nvme_pr_clear()
    and nvme_pr_release() functions set the IEKEY field incorrectly.
    The IEKEY field should be set only when the key is zero (i.e,
    not specified).  The current code does it backwards.
    
    Furthermore, the NVMe spec describes the persistent
    reservation "clear" function as an option on the reservation
    release command. The current implementation of nvme_pr_clear()
    erroneously uses the reservation register command.
    
    Fix these errors. Note that NVMe version 1.3 and later specify
    that setting the IEKEY field will return an error of Invalid
    Field in Command.  The fix will set IEKEY when the key is zero,
    which is appropriate as these ioctls consider a zero key to
    be "unspecified", and the intention of the spec change is
    to require a valid key.
    
    Tested on a version 1.4 PCI NVMe device in an Azure VM.
    
    Fixes: 1673f1f08c88 ("nvme: move block_device_operations and ns/ctrl freeing to common code")
    Fixes: 1d277a637a71 ("NVMe: Add persistent reservation ops")
    Signed-off-by: Michael Kelley <mikelley@xxxxxxxxxxxxx>
    Signed-off-by: Christoph Hellwig <hch@xxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index ed2740585c5d..76d8a72f52e2 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2056,14 +2056,14 @@ static int nvme_pr_preempt(struct block_device *bdev, u64 old, u64 new,
 
 static int nvme_pr_clear(struct block_device *bdev, u64 key)
 {
-	u32 cdw10 = 1 | (key ? 1 << 3 : 0);
+	u32 cdw10 = 1 | (key ? 0 : 1 << 3);
 
-	return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_register);
+	return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_release);
 }
 
 static int nvme_pr_release(struct block_device *bdev, u64 key, enum pr_type type)
 {
-	u32 cdw10 = nvme_pr_type(type) << 8 | (key ? 1 << 3 : 0);
+	u32 cdw10 = nvme_pr_type(type) << 8 | (key ? 0 : 1 << 3);
 
 	return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_release);
 }



[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