Commit 7cddf7e8 authored by Martin Wilck's avatar Martin Wilck Committed by Martin K. Petersen

scsi: core: Make "access_state" sysfs attribute always visible

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.

Link: https://lore.kernel.org/r/20220127141351.30706-1-mwilck@suse.comReviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarMartin Wilck <mwilck@suse.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent d1d87c33
...@@ -1228,14 +1228,6 @@ static umode_t scsi_sdev_attr_is_visible(struct kobject *kobj, ...@@ -1228,14 +1228,6 @@ static umode_t scsi_sdev_attr_is_visible(struct kobject *kobj,
!sdev->host->hostt->change_queue_depth) !sdev->host->hostt->change_queue_depth)
return 0; 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; return attr->mode;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment