* [PATCH] ses: do not add a device to an enclosure if enclosure_add_links() fails.
@ 2017-06-27 9:53 Maurizio Lombardi
2017-06-27 12:50 ` Douglas Miller
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Maurizio Lombardi @ 2017-06-27 9:53 UTC (permalink / raw)
To: linux-scsi; +Cc: jejb, martin.petersen, dougmill
The enclosure_add_device() function should fail if it can't
create the relevant sysfs links.
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
---
drivers/misc/enclosure.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index d3fe3ea..eb29113 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -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);
--
Maurizio Lombardi
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] ses: do not add a device to an enclosure if enclosure_add_links() fails.
2017-06-27 9:53 [PATCH] ses: do not add a device to an enclosure if enclosure_add_links() fails Maurizio Lombardi
@ 2017-06-27 12:50 ` Douglas Miller
2017-07-10 13:27 ` Douglas Miller
2017-06-28 1:10 ` Martin K. Petersen
2017-07-01 20:53 ` Martin K. Petersen
2 siblings, 1 reply; 7+ messages in thread
From: Douglas Miller @ 2017-06-27 12:50 UTC (permalink / raw)
To: Maurizio Lombardi, linux-scsi; +Cc: jejb, martin.petersen
On 06/27/2017 04:53 AM, Maurizio Lombardi wrote:
> The enclosure_add_device() function should fail if it can't
> create the relevant sysfs links.
>
> Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
> ---
> drivers/misc/enclosure.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
> index d3fe3ea..eb29113 100644
> --- a/drivers/misc/enclosure.c
> +++ b/drivers/misc/enclosure.c
> @@ -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);
>
Tested-by: Douglas Miller <dougmill@linux.vnet.ibm.com>
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ses: do not add a device to an enclosure if enclosure_add_links() fails.
2017-06-27 9:53 [PATCH] ses: do not add a device to an enclosure if enclosure_add_links() fails Maurizio Lombardi
2017-06-27 12:50 ` Douglas Miller
@ 2017-06-28 1:10 ` Martin K. Petersen
2017-06-28 1:58 ` James Bottomley
2017-07-01 20:53 ` Martin K. Petersen
2 siblings, 1 reply; 7+ messages in thread
From: Martin K. Petersen @ 2017-06-28 1:10 UTC (permalink / raw)
To: Maurizio Lombardi; +Cc: linux-scsi, jejb, martin.petersen, dougmill
Maurizio,
> The enclosure_add_device() function should fail if it can't
> create the relevant sysfs links.
James?
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ses: do not add a device to an enclosure if enclosure_add_links() fails.
2017-06-28 1:10 ` Martin K. Petersen
@ 2017-06-28 1:58 ` James Bottomley
0 siblings, 0 replies; 7+ messages in thread
From: James Bottomley @ 2017-06-28 1:58 UTC (permalink / raw)
To: Martin K. Petersen, Maurizio Lombardi; +Cc: linux-scsi, dougmill
On Tue, 2017-06-27 at 21:10 -0400, Martin K. Petersen wrote:
> Maurizio,
>
> >
> > 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ses: do not add a device to an enclosure if enclosure_add_links() fails.
2017-06-27 9:53 [PATCH] ses: do not add a device to an enclosure if enclosure_add_links() fails Maurizio Lombardi
2017-06-27 12:50 ` Douglas Miller
2017-06-28 1:10 ` Martin K. Petersen
@ 2017-07-01 20:53 ` Martin K. Petersen
2 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2017-07-01 20:53 UTC (permalink / raw)
To: Maurizio Lombardi; +Cc: linux-scsi, jejb, martin.petersen, dougmill
Maurizio,
> The enclosure_add_device() function should fail if it can't
> create the relevant sysfs links.
Applied to 4.13/scsi-queue, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ses: do not add a device to an enclosure if enclosure_add_links() fails.
2017-06-27 12:50 ` Douglas Miller
@ 2017-07-10 13:27 ` Douglas Miller
2017-07-10 13:46 ` Maurizio Lombardi
0 siblings, 1 reply; 7+ messages in thread
From: Douglas Miller @ 2017-07-10 13:27 UTC (permalink / raw)
To: Maurizio Lombardi, linux-scsi; +Cc: jejb, martin.petersen
On 06/27/2017 07:50 AM, Douglas Miller wrote:
> On 06/27/2017 04:53 AM, Maurizio Lombardi wrote:
>> The enclosure_add_device() function should fail if it can't
>> create the relevant sysfs links.
>>
>> Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
>> ---
>> drivers/misc/enclosure.c | 14 ++++++++++----
>> 1 file changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
>> index d3fe3ea..eb29113 100644
>> --- a/drivers/misc/enclosure.c
>> +++ b/drivers/misc/enclosure.c
>> @@ -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);
>>
> Tested-by: Douglas Miller <dougmill@linux.vnet.ibm.com>
>
> 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.
>
Has there been any progress with getting this patch accepted?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ses: do not add a device to an enclosure if enclosure_add_links() fails.
2017-07-10 13:27 ` Douglas Miller
@ 2017-07-10 13:46 ` Maurizio Lombardi
0 siblings, 0 replies; 7+ messages in thread
From: Maurizio Lombardi @ 2017-07-10 13:46 UTC (permalink / raw)
To: Douglas Miller, linux-scsi; +Cc: jejb, martin.petersen
Douglas,
> Has there been any progress with getting this patch accepted?
>
It has been merged already.
It's in linux-next, commit 62e62ffd95539b9220894a7900a619e0f3ef4756
https://kernel.googlesource.com/pub/scm/linux/kernel/git/next/linux-next/+/62e62ffd95539b9220894a7900a619e0f3ef4756
Maurizio.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-07-10 13:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-27 9:53 [PATCH] ses: do not add a device to an enclosure if enclosure_add_links() fails Maurizio Lombardi
2017-06-27 12:50 ` Douglas Miller
2017-07-10 13:27 ` Douglas Miller
2017-07-10 13:46 ` Maurizio Lombardi
2017-06-28 1:10 ` Martin K. Petersen
2017-06-28 1:58 ` James Bottomley
2017-07-01 20:53 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).