All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6.20-rc6] md: expose uuid and degraded attributes in sysfs
@ 2007-01-27  1:59 Iustin Pop
  2007-02-10 11:18 ` Iustin Pop
  0 siblings, 1 reply; 8+ messages in thread
From: Iustin Pop @ 2007-01-27  1:59 UTC (permalink / raw)
  To: linux-raid

From: Iustin Pop <iusty@k1024.org>

This patch exposes the uuid and the degraded status of an assembled
array through sysfs.

The uuid is useful in the case when multiple arrays exist on a system
and userspace needs to identify them; currently, the only portable way
that I know of is using 'mdadm -D' on each device until the desired uuid
is found. Having the uuid visible in sysfs is much more cleaner, IMHO.
Note on the method to format the uuid: I'm not sure if this is the best
way, I've copied and transformed the one in print_sb.

The 'degraded' attribute is also useful to quickly determine if the
array is degraded, instead of, again, parsing 'mdadm -D' output or
relying on the other techniques (number of working devices against
number of defined devices, etc.). The md code already keeps track of
this attribute, so it's useful to export it.

Signed-off-by: Iustin Pop <iusty@k1024.org>
---

--- linux-2.6.20-rc6/drivers/md/md.c.orig	2007-01-27 02:31:11.496575360 +0100
+++ linux-2.6.20-rc6/drivers/md/md.c	2007-01-27 02:32:51.746741201 +0100
@@ -2856,6 +2856,22 @@
 static struct md_sysfs_entry md_suspend_hi =
 __ATTR(suspend_hi, S_IRUGO|S_IWUSR, suspend_hi_show, suspend_hi_store);
 
+static ssize_t
+uuid_show(mddev_t *mddev, char *page)
+{
+	__u32 *p = (__u32*)mddev->uuid;
+	return sprintf(page, "%08x:%08x:%08x:%08x\n", p[0], p[1], p[2], p[3]);
+}
+static struct md_sysfs_entry md_uuid =
+__ATTR_RO(uuid);
+
+static ssize_t
+degraded_show(mddev_t *mddev, char *page)
+{
+	return sprintf(page, "%i\n", mddev->degraded);
+}
+static struct md_sysfs_entry md_degraded =
+__ATTR_RO(degraded);
 
 static struct attribute *md_default_attrs[] = {
 	&md_level.attr,
@@ -2881,6 +2897,8 @@
 	&md_suspend_lo.attr,
 	&md_suspend_hi.attr,
 	&md_bitmap.attr,
+	&md_uuid.attr,
+	&md_degraded.attr,
 	NULL,
 };
 static struct attribute_group md_redundancy_group = {

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

end of thread, other threads:[~2007-02-12 22:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-27  1:59 [PATCH 2.6.20-rc6] md: expose uuid and degraded attributes in sysfs Iustin Pop
2007-02-10 11:18 ` Iustin Pop
2007-02-10 18:09   ` Bill Davidsen
2007-02-10 21:15     ` Neil Brown
2007-02-10 21:50       ` Iustin Pop
2007-02-12  4:51       ` Bill Davidsen
2007-02-12  5:05         ` Neil Brown
2007-02-12 22:10           ` Bill Davidsen

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.