All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Feature enhancements for ses module
@ 2014-12-30 22:46 Song Liu
  2014-12-30 22:46 ` [PATCH 1/5] ses: close potential registration race Song Liu
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Song Liu @ 2014-12-30 22:46 UTC (permalink / raw)
  To: linux-scsi; +Cc: hch, hare, dgilbert, Song Liu

1: close potential race condition by at enclosure race condition

2,3,4: add enclosure id and device slot, so we can create symlink
       in /dev/disk/by-slot:
  # ls -d /dev/disk/by-slot/*
    /dev/disk/by-slot/enclosure-0x5000ae41fc1310ff-slot0

5: add ability to power on/off device with power_status file in
   sysfs.

Due to the complexity of SES standard, the module is not to replace implement \
all features of sg_ses (sg3_utils).

Patch 5 and existing features for device element and array device elements control \
of HDDs. It is helpful to handle some HDD related fields in the kernel, as the \
kernel can generate mapping between a device to the SES device element (or array \
device element):

/sys/block/sdc/device/enclosure_deviceXXX/

With patch 5, we can easily power off a running HDD by

echo off > /sys/block/sdc/device/enclosure_deviceXXX/power_status

This is very useful for systems like Cold Storage, where HDDs are being powered \
on/off frequently


Dan Williams (4):
  ses: close potential registration race
  ses: generate KOBJ_CHANGE on enclosure attach
  ses: add enclosure logical id
  ses: add reliable slot attribute

Song Liu (1):
  ses: Add power_status to SES device slot

 drivers/misc/enclosure.c  | 106 +++++++++++++++++++++++++++++----
 drivers/scsi/ses.c        | 148 +++++++++++++++++++++++++++++++++++++++-------
 include/linux/enclosure.h |  13 +++-
 3 files changed, 232 insertions(+), 35 deletions(-)

-- 
1.8.1


^ permalink raw reply	[flat|nested] 12+ messages in thread
* [PATCH 1/5] SES: close potential registration race
@ 2014-08-25 17:34 Song Liu
       [not found] ` <540819F9.8030701@suse.de>
  0 siblings, 1 reply; 12+ messages in thread
From: Song Liu @ 2014-08-25 17:34 UTC (permalink / raw)
  To: linux-scsi@vger.kernel.org; +Cc: Dan Williams, Hannes Reinecke, Jens Axboe

From: Song Liu [mailto:songliubraving@fb.com] 
Sent: Monday, August 25, 2014 10:26 AM
To: Song Liu
Cc: Dan Williams; Hannes Reinecke
Subject: [PATCH 1/5] SES: close potential registration race

From: Dan Williams <dan.j.williams@intel.com>

The slot and address fields have a small window of instability when userspace can read them before initialization. Separate enclosure_component allocation from registration.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Reviewed-by: Jens Axboe <axboe@fb.com>
Cc: Hannes Reinecke <hare@suse.de>
---
 drivers/misc/enclosure.c  | 36 +++++++++++++++++++++++++-----------
 drivers/scsi/ses.c        | 18 +++++++++++-------
 include/linux/enclosure.h |  5 +++--
 3 files changed, 39 insertions(+), 20 deletions(-)

diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index 2cf2bbc..15faf61 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -249,27 +249,25 @@ static void enclosure_component_release(struct device *dev)  static const struct attribute_group *enclosure_component_groups[];
 
 /**
- * enclosure_component_register - add a particular component to an enclosure
+ * enclosure_component_alloc - prepare a new enclosure component
  * @edev:	the enclosure to add the component
  * @num:	the device number
  * @type:	the type of component being added
  * @name:	an optional name to appear in sysfs (leave NULL if none)
  *
- * Registers the component.  The name is optional for enclosures that
- * give their components a unique name.  If not, leave the field NULL
- * and a name will be assigned.
+ * The name is optional for enclosures that give their components a 
+ unique
+ * name.  If not, leave the field NULL and a name will be assigned.
  *
  * Returns a pointer to the enclosure component or an error.
  */
 struct enclosure_component *
-enclosure_component_register(struct enclosure_device *edev,
-			     unsigned int number,
-			     enum enclosure_component_type type,
-			     const char *name)
+enclosure_component_alloc(struct enclosure_device *edev,
+			  unsigned int number,
+			  enum enclosure_component_type type,
+			  const char *name)
 {
 	struct enclosure_component *ecomp;
 	struct device *cdev;
-	int err;
 
 	if (number >= edev->components)
 		return ERR_PTR(-EINVAL);
@@ -291,14 +289,30 @@ enclosure_component_register(struct enclosure_device *edev,
 	cdev->release = enclosure_component_release;
 	cdev->groups = enclosure_component_groups;
 
+	return ecomp;
+}
+EXPORT_SYMBOL_GPL(enclosure_component_alloc);
+
+/**
+ * enclosure_component_register - publishes an initialized enclosure component
+ * @ecomp:	component to add
+ *
+ * Returns 0 on successful registration, releases the component 
+otherwise  */ int enclosure_component_register(struct 
+enclosure_component *ecomp) {
+	struct device *cdev;
+	int err;
+
+	cdev = &ecomp->cdev;
 	err = device_register(cdev);
 	if (err) {
 		ecomp->number = -1;
 		put_device(cdev);
-		return ERR_PTR(err);
+		return err;
 	}
 
-	return ecomp;
+	return 0;
 }
 EXPORT_SYMBOL_GPL(enclosure_component_register);
 
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index 80bfece..c2e8a98 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -423,16 +423,20 @@ static void ses_enclosure_data_process(struct enclosure_device *edev,
 			    type_ptr[0] == ENCLOSURE_COMPONENT_ARRAY_DEVICE) {
 
 				if (create)
-					ecomp =	enclosure_component_register(edev,
-									     components++,
-									     type_ptr[0],
-									     name);
+					ecomp =	enclosure_component_alloc(edev,
+									  components++,
+									  type_ptr[0],
+									  name);
 				else
 					ecomp = &edev->component[components++];
 
-				if (!IS_ERR(ecomp) && addl_desc_ptr)
-					ses_process_descriptor(ecomp,
-							       addl_desc_ptr);
+				if (!IS_ERR(ecomp)) {
+					if (addl_desc_ptr)
+						ses_process_descriptor(ecomp,
+								       addl_desc_ptr);
+					if (create)
+						enclosure_component_register(ecomp);
+				}
 			}
 			if (desc_ptr)
 				desc_ptr += len;
diff --git a/include/linux/enclosure.h b/include/linux/enclosure.h index 9a33c5f..a835d33 100644
--- a/include/linux/enclosure.h
+++ b/include/linux/enclosure.h
@@ -120,8 +120,9 @@ enclosure_register(struct device *, const char *, int,
 		   struct enclosure_component_callbacks *);  void enclosure_unregister(struct enclosure_device *);  struct enclosure_component * -enclosure_component_register(struct enclosure_device *, unsigned int,
-				 enum enclosure_component_type, const char *);
+enclosure_component_alloc(struct enclosure_device *, unsigned int,
+			  enum enclosure_component_type, const char *); int 
+enclosure_component_register(struct enclosure_component *);
 int enclosure_add_device(struct enclosure_device *enclosure, int component,
 			 struct device *dev);
 int enclosure_remove_device(struct enclosure_device *, struct device *);
--
1.8.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-01-10 13:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-30 22:46 [PATCH 0/5] Feature enhancements for ses module Song Liu
2014-12-30 22:46 ` [PATCH 1/5] ses: close potential registration race Song Liu
2015-01-10 13:26   ` Hannes Reinecke
2014-12-30 22:46 ` [PATCH 2/5] ses: generate KOBJ_CHANGE on enclosure attach Song Liu
2014-12-30 22:46 ` [PATCH 3/5] ses: add enclosure logical id Song Liu
2015-01-10 13:27   ` Hannes Reinecke
2014-12-30 22:46 ` [PATCH 4/5] ses: add reliable slot attribute Song Liu
2014-12-30 22:46 ` [PATCH 5/5] ses: Add power_status to SES device slot Song Liu
2015-01-10 13:28   ` Hannes Reinecke
2015-01-05 19:26 ` [PATCH 0/5] Feature enhancements for ses module Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2014-08-25 17:34 [PATCH 1/5] SES: close potential registration race Song Liu
     [not found] ` <540819F9.8030701@suse.de>
2014-09-12 21:02   ` Song Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.