Skip to contentSkip to conversation

scsi: make "access_state" sysfs attribute always visible

PATCH Applied [email protected] 3 participants 4 messages Jan 27, 2022 – Feb 11, 2022 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: make "access_state" sysfs attribute always visible

From: Martin Wilck <[email protected]>

If a SCSI device handler module is loaded after some SCSI devices have already been probed (e.g. via request_module() by dm-multipath), the "access_state" and "preferred_path" sysfs attributes remain invisible for these devices, although the handler is attached and live. The reason is that the visibility is only checked when the sysfs attribute group is first created. This results in an inconsistent user experience depending on the load order of SCSI low-level drivers vs. device handler modules.

This patch changes user space API: attempting to read the "access_state" or "preferred_path" attributes will now result in -EINVAL rather than -ENODEV for devices that have no device handler, and tests for the existence of these attributes will have a different result.

---
 drivers/scsi/scsi_sysfs.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/scsi/scsi_sysfs.c +0 -8
index f1e0c131b77c..226a50944c00 100644
@@ -1228,14 +1228,6 @@ static umode_t scsi_sdev_attr_is_visible(struct kobject *kobj,
 	    !sdev->host->hostt->change_queue_depth)
 		return 0;
 
-#ifdef CONFIG_SCSI_DH
-	if (attr == &dev_attr_access_state.attr &&
-	    !sdev->handler)
-		return 0;
-	if (attr == &dev_attr_preferred_path.attr &&
-	    !sdev->handler)
-		return 0;
-#endif
 	return attr->mode;
 }
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 30 lines · On 1/27/22 15:13, [email protected] wrote:

From: Martin Wilck <[email protected]>

If a SCSI device handler module is loaded after some SCSI devices have already been probed (e.g. via request_module() by dm-multipath), the "access_state" and "preferred_path" sysfs attributes remain invisible for these devices, although the handler is attached and live. The reason is that the visibility is only checked when the sysfs attribute group is first created. This results in an inconsistent user experience depending on the load order of SCSI low-level drivers vs. device handler modules.

This patch changes user space API: attempting to read the "access_state" or "preferred_path" attributes will now result in -EINVAL rather than -ENODEV for devices that have no device handler, and tests for the existence of these attributes will have a different result.

---
  drivers/scsi/scsi_sysfs.c | 8 --------
  1 file changed, 8 deletions(-)
drivers/scsi/scsi_sysfs.c +0 -1
index f1e0c131b77c..226a50944c00 100644
@@ -1228,14 +1228,6 @@ static umode_t scsi_sdev_attr_is_visible(struct kobject *kobj,
  	    !sdev->host->hostt->change_queue_depth)
  		return 0;
 
-#ifdef CONFIG_SCSI_DH

drivers/scsi/scsi_sysfs.c static umode_t scsi_sdev_attr_is_visible(struct kobject *kobj, · line 1233

Quoted 10 lines
drivers/scsi/scsi_sysfs.c +0 -7
-	if (attr == &dev_attr_access_state.attr &&
-	    !sdev->handler)
-		return 0;
-	if (attr == &dev_attr_preferred_path.attr &&
-	    !sdev->handler)
-		return 0;
-#endif
  	return attr->mode;
  }
 

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke		           Kernel Storage Architect
[email protected]			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
#2 lore raw
In reply to [email protected]
Quoted 10 lines

If a SCSI device handler module is loaded after some SCSI devices have already been probed (e.g. via request_module() by dm-multipath), the "access_state" and "preferred_path" sysfs attributes remain invisible for these devices, although the handler is attached and live. The reason is that the visibility is only checked when the sysfs attribute group is first created. This results in an inconsistent user experience depending on the load order of SCSI low-level drivers vs. device handler modules.

Quoted 5 lines

This patch changes user space API: attempting to read the "access_state" or "preferred_path" attributes will now result in -EINVAL rather than -ENODEV for devices that have no device handler, and tests for the existence of these attributes will have a different result.

Applied to 5.18/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#3 lore raw
In reply to [email protected]
Quoted 11 lines · On Thu, 27 Jan 2022 15:13:51 +0100, [email protected] wrote:

From: Martin Wilck <[email protected]>

If a SCSI device handler module is loaded after some SCSI devices have already been probed (e.g. via request_module() by dm-multipath), the "access_state" and "preferred_path" sysfs attributes remain invisible for these devices, although the handler is attached and live. The reason is that the visibility is only checked when the sysfs attribute group is first created. This results in an inconsistent user experience depending on the load order of SCSI low-level drivers vs. device handler modules.

[...]

Applied to 5.18/scsi-queue, thanks!

[1/1] scsi: make "access_state" sysfs attribute always visible

      https://git.kernel.org/mkp/scsi/c/7cddf7e8d1e8
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering