From: Maurizio Lombardi <mlombard@redhat.com>
To: jejb@linux.vnet.ibm.com
Cc: linux-scsi@vger.kernel.org
Subject: [PATCH RFC] enclosure: fix sysfs symlinks creation when using multipath
Date: Tue, 7 Feb 2017 15:08:48 +0100 [thread overview]
Message-ID: <1486476528-27580-2-git-send-email-mlombard@redhat.com> (raw)
In-Reply-To: <1486476528-27580-1-git-send-email-mlombard@redhat.com>
With multipath, it may happen that the same device is passed
to enclosure_add_device() multiple times and that the enclosure_add_links()
function fails to create the symlinks because the device's sysfs
directory entry is still NULL.
In this case, the links will never be created because all the subsequent
calls to enclosure_add_device() will immediately fail with EEXIST.
This patch modifies the code so the driver will detect this condition
and will retry to create the symlinks when enclosure_add_device() is called.
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
---
drivers/misc/enclosure.c | 16 ++++++++++++++--
include/linux/enclosure.h | 1 +
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 65fed71..a856c98 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -375,21 +375,33 @@ int enclosure_add_device(struct enclosure_device *edev, int component,
struct device *dev)
{
struct enclosure_component *cdev;
+ int error;
if (!edev || component >= edev->components)
return -EINVAL;
cdev = &edev->component[component];
- if (cdev->dev == dev)
+ if (cdev->dev == dev) {
+ if (!cdev->links_created) {
+ error = enclosure_add_links(cdev);
+ if (!error)
+ cdev->links_created = 1;
+ }
return -EEXIST;
+ }
if (cdev->dev)
enclosure_remove_links(cdev);
put_device(cdev->dev);
cdev->dev = get_device(dev);
- return enclosure_add_links(cdev);
+ error = enclosure_add_links(cdev);
+ if (!error)
+ cdev->links_created = 1;
+ else
+ cdev->links_created = 0;
+ return error;
}
EXPORT_SYMBOL_GPL(enclosure_add_device);
diff --git a/include/linux/enclosure.h b/include/linux/enclosure.h
index a4cf57c..c3bdc4c 100644
--- a/include/linux/enclosure.h
+++ b/include/linux/enclosure.h
@@ -97,6 +97,7 @@ struct enclosure_component {
struct device cdev;
struct device *dev;
enum enclosure_component_type type;
+ int links_created;
int number;
int fault;
int active;
--
Maurizio Lombardi
next prev parent reply other threads:[~2017-02-07 14:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-07 14:08 [PATCH RFC] enclosure: fix symlinks creation Maurizio Lombardi
2017-02-07 14:08 ` Maurizio Lombardi [this message]
2017-02-16 13:13 ` [PATCH RFC] enclosure: fix sysfs symlinks creation when using multipath Maurizio Lombardi
2017-06-16 12:40 ` [RFC] " Douglas Miller
2017-06-16 12:48 ` Maurizio Lombardi
2017-06-16 12:53 ` Douglas Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1486476528-27580-2-git-send-email-mlombard@redhat.com \
--to=mlombard@redhat.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).