ses: do not add a device to an enclosure if enclosure_add_links() fails.
Subsystems (2)
PATCH 1/1 ses: do not add a device to an enclosure if enclosure_add_links() fails.
The enclosure_add_device() function should fail if it can't create the relevant sysfs links.
--- drivers/misc/enclosure.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/misc/enclosure.c +10 -4
@@ -375,6 +375,7 @@ int enclosure_add_device(struct enclosure_device *edev, int component, struct device *dev) {struct enclosure_component *cdev; +int err;if (!edev || component >= edev->components)return -EINVAL ;
@@ -384,12 +385,17 @@ int enclosure_add_device(struct enclosure_device *edev, int component,if (cdev->dev == dev)return -EEXIST ; -if (cdev->dev) +if (cdev->dev) {enclosure_remove_links (cdev); - -put_device (cdev->dev); +put_device (cdev->dev); + } cdev->dev =get_device (dev); -return enclosure_add_links (cdev); + err =enclosure_add_links (cdev); +if (err) { +put_device (cdev->dev); + cdev->dev =NULL ; + } +return err; }EXPORT_SYMBOL_GPL (enclosure_add_device);
Signature · 1 line
Maurizio Lombardi
Quoted 32 lines · Maurizio Lombardi
The
enclosure_add_device()function should fail if it can't create the relevant sysfs links.Signed-off-by Maurizio Lombardi <[email protected]>--- drivers/misc/enclosure.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/misc/enclosure.c +4
-3@@ -375,6 +375,7 @@ int enclosure_add_device(struct enclosure_device *edev, int component, struct device *dev) {struct enclosure_component *cdev; +int err;if (!edev || component >= edev->components)return -EINVAL ;@@ -384,12 +385,17 @@ int enclosure_add_device(struct enclosure_device *edev, int component,if (cdev->dev == dev)return -EEXIST ; -if (cdev->dev) +if (cdev->dev) {enclosure_remove_links (cdev); - -put_device (cdev->dev); +put_device (cdev->dev); + } cdev->dev =get_device (dev);
drivers/misc/enclosure.c int enclosure_add_device(struct enclosure_device *edev, int component, · line 401
Quoted 10 lines
drivers/misc/enclosure.c +6
-1-return enclosure_add_links (cdev); + err =enclosure_add_links (cdev); +if (err) { +put_device (cdev->dev); + cdev->dev =NULL ; + } +return err; }EXPORT_SYMBOL_GPL (enclosure_add_device);
This fixes a problem where udevd (insmod ses) races with/overtakes do_scan_async(), which creates the directory target of the symlink, resulting in missing enclosure symlinks. This patch relaxes the symlink creation allowing for delayed addition to enclosure and creation of symlinks after do_scan_async() has created the target directory.
Quoted 47 lines · Douglas Miller
Quoted 34 lines · Maurizio Lombardi
The
enclosure_add_device()function should fail if it can't create the relevant sysfs links.Signed-off-by Maurizio Lombardi <[email protected]>--- drivers/misc/enclosure.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/misc/enclosure.c +1
-0@@ -375,6 +375,7 @@ int enclosure_add_device(struct enclosure_device *edev, int component, struct device *dev) {struct enclosure_component *cdev; +int err;if (!edev || component >= edev->components)return -EINVAL;drivers/misc/enclosure.c +3
-3@@ -384,12 +385,17 @@ int enclosure_add_device(struct enclosure_device *edev, int component, if (cdev->dev == dev) return -EEXIST; -if (cdev->dev) +if (cdev->dev) {enclosure_remove_links (cdev); - -put_device (cdev->dev); +put_device (cdev->dev); + }drivers/misc/enclosure.c int enclosure_add_device(struct · line 401
Quoted 10 lines
drivers/misc/enclosure.c +6
-1cdev->dev =get_device (dev); -return enclosure_add_links (cdev); + err =enclosure_add_links (cdev); +if (err) { +put_device (cdev->dev); + cdev->dev =NULL ; + } +return err; }EXPORT_SYMBOL_GPL (enclosure_add_device);Tested-by Douglas Miller <[email protected]>
Quoted 2 lines
This fixes a problem where udevd (insmod ses) races with/overtakes
do_scan_async(), which creates the directory target of the symlink, resulting in missing enclosure symlinks. This patch relaxes the symlink creation allowing for delayed addition to enclosure and creation of symlinks afterdo_scan_async()has created the target directory.
Has there been any progress with getting this patch accepted?
Douglas,
Quoted 2 lines
Has there been any progress with getting this patch accepted?
It has been merged already.
It's in linux-next, commit 62e62ffd95539b9220894a7900a619e0f3ef4756
Maurizio.
Maurizio,
Quoted 2 lines
The
enclosure_add_device()function should fail if it can't create the relevant sysfs links.
James?
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 7 lines · Martin K. Petersen
Maurizio,
Quoted 3 lines
The
enclosure_add_device()function should fail if it can't create the relevant sysfs links.James?
It's essentially the patch I proposed, so I'm fine with it. Although I would like more root cause analysis about why we have this problem.
James
Martin K. Petersen
AppliedMaurizio,
Quoted 2 lines
The
enclosure_add_device()function should fail if it can't create the relevant sysfs links.
Applied to 4.13/scsi-queue, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering