md: expose uuid and degraded attributes in sysfs

Started by Iustin Pop on Jan 27, 2007 · 3 messages from 2 authors · Last reply Feb 10, 2007

STALE7224d

open the first message on its own page

Message details and related content
From: Iustin Pop <redacted>

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 <redacted>
---
--- 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 = {
Message details and related content
On Sat, Jan 27, 2007 at 02:59:48AM +0100, Iustin Pop wrote:
From: Iustin Pop <redacted>

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

Sorry to ask, this was my first patch and I'm not sure what is the
procedure to get it considered for merging... I was under the impression
that just sending it to this list is enough. What do I have to do?

Thanks,
Iustin
Message details and related content
Iustin Pop wrote:
On Sat, Jan 27, 2007 at 02:59:48AM +0100, Iustin Pop wrote:
  
quoted
From: Iustin Pop <redacted>

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

Sorry to ask, this was my first patch and I'm not sure what is the
procedure to get it considered for merging... I was under the impression
that just sending it to this list is enough. What do I have to do?
Normally I would expect Neil to pick it up and forward it, but I would have expected an ack from him. He's been busy with other problems, NFS as I recall, and may have missed it, so I cc'd him this time.

Neil, I would think this is 2.6.21 material unless you see a problem I missed.

-- 
bill davidsen [off-list ref]
 CTO TMR Associates, Inc
 Doing interesting things with small computers since 1979
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help