From c7e7c90ce625db7d937dbfa87a10003514a7ebfd Mon Sep 17 00:00:00 2001 From: Doug Ledford Date: Fri, 16 Apr 2010 13:09:41 -0400 Subject: Add some helper functions to make code cleaner looking Signed-off-by: Doug Ledford --- Incremental.c | 17 +++-------------- mdadm.h | 3 +++ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Incremental.c b/Incremental.c index ace80c4..5fdf509 100644 --- a/Incremental.c +++ b/Incremental.c @@ -909,7 +909,7 @@ int IncrementalNewDisk(char *devname, int verbose, int export) domain = conf_get_domain(devname); if (!domain) return 0; - if ((domain->action & action_mask) <= incremental) + if (action(domain) <= incremental) /* Nothing to do. We only get called in the case that there * is no current superblock on the device in question, and * since our matching domain says we should either ignore or @@ -917,19 +917,8 @@ int IncrementalNewDisk(char *devname, int verbose, int export) * superblock. Since we don't, we're done. */ return 0; - if (domain->action == partition) { - /* Special case. Basically, we can only put this action on - * whole disk devices, and since we are partitioning them, - * the whole device necessarily won't ever be part of an - * array, so we will never have any arrays in our domain, ever. - * As such, we have to figure out what to do from other - * hints. - */ - /* We haven't filled this out yet */ - return 0; - } - mdstat = arrays_in_domain(devname, domain); - if (!mdstat) { + if (action(domain) != partition && + (mdstat = arrays_in_domain(devname, domain)) == NULL) { /* As a technical design decision, we *must* have at least one * array in our domain that we can add this device to or else * we simply can't do anything with this device. diff --git a/mdadm.h b/mdadm.h index 8eb7bc7..a020ad9 100644 --- a/mdadm.h +++ b/mdadm.h @@ -292,6 +292,9 @@ enum domain_actions { other metadata on them */ }; +#define action(domain) ((domain)->action & action_mask) +#define force(domain) ((domain)->action & force) + struct domain_ent { char *spare_group; /* only set this in monitor mode when we know what arrays we -- cgit