Patch "scsi: target: Fix the pgr/alua_support_store functions" has been added to the 5.10-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

    scsi: target: Fix the pgr/alua_support_store functions

to the 5.10-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:
     scsi-target-fix-the-pgr-alua_support_store-functions.patch
and it can be found in the queue-5.10 subdirectory.

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



commit e9c4a21afa025c4b1d6b6bcf6fe4731455e78c3a
Author: Maurizio Lombardi <mlombard@xxxxxxxxxx>
Date:   Mon Sep 6 17:18:09 2021 +0200

    scsi: target: Fix the pgr/alua_support_store functions
    
    [ Upstream commit ef7ae7f746e95c6fa4ec2bcfacb949c36263da78 ]
    
    Commit 356ba2a8bc8d ("scsi: target: tcmu: Make pgr_support and alua_support
    attributes writable") introduced support for changeable alua_support and
    pgr_support target attributes. These can only be changed if the backstore
    is user-backed, otherwise the kernel returns -EINVAL.
    
    This triggers a warning in the targetcli/rtslib code when performing a
    target restore that includes non-userbacked backstores:
    
      # targetctl restore
      Storage Object block/storage1: Cannot set attribute alua_support:
      [Errno 22] Invalid argument, skipped
      Storage Object block/storage1: Cannot set attribute pgr_support:
      [Errno 22] Invalid argument, skipped
    
    Fix this warning by returning an error code only if we are really going to
    flip the PGR/ALUA bit in the transport_flags field, otherwise we will do
    nothing and return success.
    
    Return ENOSYS instead of EINVAL if the pgr/alua attributes can not be
    changed, this way it will be possible for userspace to understand if the
    operation failed because an invalid value has been passed to strtobool() or
    because the attributes are fixed.
    
    Fixes: 356ba2a8bc8d ("scsi: target: tcmu: Make pgr_support and alua_support attributes writable")
    Link: https://lore.kernel.org/r/20210906151809.52811-1-mlombard@xxxxxxxxxx
    Reviewed-by: Bodo Stroesser <bostroesser@xxxxxxxxx>
    Signed-off-by: Maurizio Lombardi <mlombard@xxxxxxxxxx>
    Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index f04352285155..56ae882fb7b3 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -1110,20 +1110,24 @@ static ssize_t alua_support_store(struct config_item *item,
 {
 	struct se_dev_attrib *da = to_attrib(item);
 	struct se_device *dev = da->da_dev;
-	bool flag;
+	bool flag, oldflag;
 	int ret;
 
+	ret = strtobool(page, &flag);
+	if (ret < 0)
+		return ret;
+
+	oldflag = !(dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA);
+	if (flag == oldflag)
+		return count;
+
 	if (!(dev->transport->transport_flags_changeable &
 	      TRANSPORT_FLAG_PASSTHROUGH_ALUA)) {
 		pr_err("dev[%p]: Unable to change SE Device alua_support:"
 			" alua_support has fixed value\n", dev);
-		return -EINVAL;
+		return -ENOSYS;
 	}
 
-	ret = strtobool(page, &flag);
-	if (ret < 0)
-		return ret;
-
 	if (flag)
 		dev->transport_flags &= ~TRANSPORT_FLAG_PASSTHROUGH_ALUA;
 	else
@@ -1145,20 +1149,24 @@ static ssize_t pgr_support_store(struct config_item *item,
 {
 	struct se_dev_attrib *da = to_attrib(item);
 	struct se_device *dev = da->da_dev;
-	bool flag;
+	bool flag, oldflag;
 	int ret;
 
+	ret = strtobool(page, &flag);
+	if (ret < 0)
+		return ret;
+
+	oldflag = !(dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR);
+	if (flag == oldflag)
+		return count;
+
 	if (!(dev->transport->transport_flags_changeable &
 	      TRANSPORT_FLAG_PASSTHROUGH_PGR)) {
 		pr_err("dev[%p]: Unable to change SE Device pgr_support:"
 			" pgr_support has fixed value\n", dev);
-		return -EINVAL;
+		return -ENOSYS;
 	}
 
-	ret = strtobool(page, &flag);
-	if (ret < 0)
-		return ret;
-
 	if (flag)
 		dev->transport_flags &= ~TRANSPORT_FLAG_PASSTHROUGH_PGR;
 	else



[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