linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] 64-md-raid.rules fixes
@ 2009-03-15  0:17 Michal Soltys
  2009-03-15 20:33 ` Kay Sievers
  2009-03-15 21:21 ` Michal Soltys
  0 siblings, 2 replies; 3+ messages in thread
From: Michal Soltys @ 2009-03-15  0:17 UTC (permalink / raw)
  To: linux-hotplug

Few small things:

1) introduced in commit b822542608326092e177fd1707ca7fb53b2846c4

md/array_state in case of partition doesn't exists, so all uevents
for partitions didn't execute any further SYMLINK rules

2) mdadm exports MD_NAME, not MD_DEVNAME - replaced

3) 0.9x superblocks don't support name at all, but it can be easily
emulated from kernel name. It simply cuts md and _ in front, and
p[0-9]* at the end of the kernel name. Following SYMLINK rules need
no alteration (tests for MD_NAME are superfluous then though). If
it's really necessary is another thing (and it depends on sh after
all)

Signed-off-by: Michal Soltys <soltys@ziu.info>
---
 rules/packages/64-md-raid.rules |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/rules/packages/64-md-raid.rules b/rules/packages/64-md-raid.rules
index abb029c..5906ab0 100644
--- a/rules/packages/64-md-raid.rules
+++ b/rules/packages/64-md-raid.rules
@@ -8,21 +8,29 @@ ACTION!="add|change", GOTO="md_end"
 # import data from a raid set
 KERNEL!="md*", GOTO="md_end"
 
+# partitions have no md/{array_state,metadata_version}
+ENV{DEVTYPE}="partition", GOTO="md_ignore_state"
+
 # container devices have a metadata version of e.g. 'external:ddf' and
 # never leave state 'inactive'
 ATTR{md/metadata_version}="external:[A-Za-z]*", ATTR{md/array_state}="inactive", GOTO="md_ignore_state"
 TEST!="md/array_state", GOTO="md_end"
 ATTR{md/array_state}="|clear|inactive", GOTO="md_end"
+
 LABEL="md_ignore_state"
 
 IMPORT{program}="/sbin/mdadm --detail --export $tempnode"
+
+# emulate MD_NAME for 0.9x superblocks
+ENV{MD_NAME}!="?*", PROGRAM="/bin/sh -c 'K=%k ; K=$${K#md}; K=$${K#_}; echo $${K%%p*}'", ENV{MD_NAME}="%c"
+
 ENV{DEVTYPE}="disk", ENV{MD_NAME}="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}", OPTIONS+="string_escape=replace"
 ENV{DEVTYPE}="disk", ENV{MD_UUID}="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}"
-ENV{DEVTYPE}="disk", ENV{MD_DEVNAME}="?*", SYMLINK+="md/$env{MD_DEVNAME}"
+ENV{DEVTYPE}="disk", ENV{MD_NAME}="?*", SYMLINK+="md/$env{MD_NAME}"
 ENV{DEVTYPE}="partition", ENV{MD_NAME}="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}-part%n", OPTIONS+="string_escape=replace"
 ENV{DEVTYPE}="partition", ENV{MD_UUID}="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}-part%n"
-ENV{DEVTYPE}="partition", ENV{MD_DEVNAME}="*[^0-9]", SYMLINK+="md/$env{MD_DEVNAME}%n"
-ENV{DEVTYPE}="partition", ENV{MD_DEVNAME}="*[0-9]", SYMLINK+="md/$env{MD_DEVNAME}p%n"
+ENV{DEVTYPE}="partition", ENV{MD_NAME}="*[^0-9]", SYMLINK+="md/$env{MD_NAME}%n"
+ENV{DEVTYPE}="partition", ENV{MD_NAME}="*[0-9]", SYMLINK+="md/$env{MD_NAME}p%n"
 
 IMPORT{program}="vol_id --export $tempnode"
 OPTIONS+="link_priority\x100"
-- 
1.6.2


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

* Re: [PATCH] 64-md-raid.rules fixes
  2009-03-15  0:17 [PATCH] 64-md-raid.rules fixes Michal Soltys
@ 2009-03-15 20:33 ` Kay Sievers
  2009-03-15 21:21 ` Michal Soltys
  1 sibling, 0 replies; 3+ messages in thread
From: Kay Sievers @ 2009-03-15 20:33 UTC (permalink / raw)
  To: linux-hotplug

On Sun, Mar 15, 2009 at 01:17, Michal Soltys <soltys@ziu.info> wrote:
> Few small things:
>
> 1) introduced in commit b822542608326092e177fd1707ca7fb53b2846c4
>
> md/array_state in case of partition doesn't exists, so all uevents
> for partitions didn't execute any further SYMLINK rules

Yep, that needs a fix.

> 2) mdadm exports MD_NAME, not MD_DEVNAME - replaced

It does exist. See here:
  http://neil.brown.name/git?p=mdadm;a=blob;fÞtail.c;hb=mdadm-3.0-devel3#l183

> 3) 0.9x superblocks don't support name at all, but it can be easily
> emulated from kernel name. It simply cuts md and _ in front, and
> p[0-9]* at the end of the kernel name. Following SYMLINK rules need
> no alteration (tests for MD_NAME are superfluous then though). If
> it's really necessary is another thing (and it depends on sh after
> all)

We usually do not want to add new shell scripts for new stuff. It
belongs into mdadm I guess, if we want that.

Thanks,
Kay

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

* Re: [PATCH] 64-md-raid.rules fixes
  2009-03-15  0:17 [PATCH] 64-md-raid.rules fixes Michal Soltys
  2009-03-15 20:33 ` Kay Sievers
@ 2009-03-15 21:21 ` Michal Soltys
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Soltys @ 2009-03-15 21:21 UTC (permalink / raw)
  To: linux-hotplug

Kay Sievers wrote:
> 
> It does exist. See here:
>   http://neil.brown.name/git?p=mdadm;a=blob;fÞtail.c;hb=mdadm-3.0-devel3#l183
> 

Thanks for pointing that out.

Maybe a rule(s) then, that would work both for versions 2.9 and 3.0 ?

Michal Soltys (1):
  64-md-raid.rules fixes v2

 rules/packages/64-md-raid.rules |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)


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

end of thread, other threads:[~2009-03-15 21:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-15  0:17 [PATCH] 64-md-raid.rules fixes Michal Soltys
2009-03-15 20:33 ` Kay Sievers
2009-03-15 21:21 ` Michal Soltys

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).