Skip to contentSkip to conversation

target: Allow non-supporting backends to set pi_prot_type to 0

PATCH Applied Andy Grover 4 participants 4 messages Apr 15, 2014 – Apr 18, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target: Allow non-supporting backends to set pi_prot_type to 0

Userspace tools assume if a value is read from configfs, it is valid and will not cause an error if the same value is written back. The only valid value for pi_prot_type for backends not supporting DIF is 0, so allow this particular value to be set without returning an error.

---
 drivers/target/target_core_device.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/target/target_core_device.c +4 -0
index 65001e1..382b66b 100644
@@ -936,6 +936,10 @@ int se_dev_set_pi_prot_type(struct se_device *dev, int flag)
 		return 0;
 	}
 	if (!dev->transport->init_prot || !dev->transport->free_prot) {
+		/* 0 is only allowed value for non-supporting backends */
+		if (flag == 0)
+			return 0;
+
 		pr_err("DIF protection not supported by backend: %s\n",
 		       dev->transport->name);
 		return -ENOSYS;
Signature · 1 line
1.9.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Andy Grover

Userspace tools assume if a value is read from configfs, it is valid and will not cause an error if the same value is written back. The only valid value for pi_prot_type for backends not supporting DIF is 0, so allow this particular value to be set without returning an error.

---
  drivers/target/target_core_device.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/target/target_core_device.c +0 -0
index 65001e1..382b66b 100644

drivers/target/target_core_device.c int se_dev_set_pi_prot_type(struct se_device *dev, int flag) · line 945

Quoted 10 lines
drivers/target/target_core_device.c +4 -0
@@ -936,6 +936,10 @@ int se_dev_set_pi_prot_type(struct se_device *dev, int flag)
  		return 0;
  	}
  	if (!dev->transport->init_prot || !dev->transport->free_prot) {
+		/* 0 is only allowed value for non-supporting backends */
+		if (flag == 0)
+			return 0;
+
  		pr_err("DIF protection not supported by backend: %s\n",
  		       dev->transport->name);
  		return -ENOSYS;

Makes sense.

#2 lore raw
In reply to Andy Grover
Quoted 16 lines · Andy Grover

Userspace tools assume if a value is read from configfs, it is valid and will not cause an error if the same value is written back. The only valid value for pi_prot_type for backends not supporting DIF is 0, so allow this particular value to be set without returning an error.

---
 drivers/target/target_core_device.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/target/target_core_device.c +0 -0
index 65001e1..382b66b 100644

drivers/target/target_core_device.c int se_dev_set_pi_prot_type(struct se_device *dev, int flag) · line 945

Quoted 10 lines
drivers/target/target_core_device.c +4 -0
@@ -936,6 +936,10 @@ int se_dev_set_pi_prot_type(struct se_device *dev, int flag)
 		return 0;
 	}
 	if (!dev->transport->init_prot || !dev->transport->free_prot) {
+		/* 0 is only allowed value for non-supporting backends */
+		if (flag == 0)
+			return 0;
+
 		pr_err("DIF protection not supported by backend: %s\n",
 		       dev->transport->name);
 		return -ENOSYS;

Applied to target-pending/queue, and will merge into master as soon as the rebase to v3.15-rc occurs.

Thanks!

--nab

#3 lore raw

Excellent, thank you Nic and Andy, that will fix the issue with rtslib/targetcli main branch too.

Quoted 42 lines · Nicholas A. Bellinger
Quoted 16 lines · Andy Grover

Userspace tools assume if a value is read from configfs, it is valid and will not cause an error if the same value is written back. The only valid value for pi_prot_type for backends not supporting DIF is 0, so allow this particular value to be set without returning an error.

---
  drivers/target/target_core_device.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/target/target_core_device.c +0 -0
index 65001e1..382b66b 100644

drivers/target/target_core_device.c int se_dev_set_pi_prot_type(struct se_device *dev, int flag) · line 945

Quoted 10 lines
drivers/target/target_core_device.c +4 -0
@@ -936,6 +936,10 @@ int se_dev_set_pi_prot_type(struct se_device *dev, int flag)
  		return 0;
  	}
  	if (!dev->transport->init_prot || !dev->transport->free_prot) {
+		/* 0 is only allowed value for non-supporting backends */
+		if (flag == 0)
+			return 0;
+
  		pr_err("DIF protection not supported by backend: %s\n",
  		       dev->transport->name);
  		return -ENOSYS;

Applied to target-pending/queue, and will merge into master as soon as the rebase to v3.15-rc occurs.

Thanks!

--nab

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html