diff options
author | Adam Kwolek <adam.kwolek@intel.com> | 2011-10-03 10:32:02 +1100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-10-03 10:32:02 +1100 |
commit | 7aa437c2d8f0efb6554bfee9e26082874d98a9d9 (patch) | |
tree | 0e7a64dde0eaf8ca167ef7291f60802c90a061cb /msg.c | |
parent | b91726651d9a22c1f015817dd01efba932ac3bc7 (diff) |
Move code to check_mdmon_version() function
Move code to function for code reuse.
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'msg.c')
-rw-r--r-- | msg.c | 59 |
1 files changed, 36 insertions, 23 deletions
@@ -281,6 +281,40 @@ int block_subarray(struct mdinfo *sra) return rc; } + +/* check mdmon version if it supports + * array blocking mechanism + */ +int check_mdmon_version(char *container) +{ + char *version = NULL; + int devnum = devname2devnum(container); + + if (!mdmon_running(devnum)) { + /* if mdmon is not active we assume that any instance that is + * later started will match the current mdadm version, if this + * assumption is violated we may inadvertantly rebuild an array + * that was meant for reshape, or start rebuild on a spare that + * was to be moved to another container + */ + /* pass */; + } else { + int ver; + + version = ping_monitor_version(container); + ver = version ? mdadm_version(version) : -1; + free(version); + if (ver < 3002000) { + fprintf(stderr, Name + ": mdmon instance for %s cannot be disabled\n", + container); + return -1; + } + } + + return 0; +} + /** * block_monitor - prevent mdmon spare assignment * @container - container to block @@ -302,34 +336,13 @@ int block_subarray(struct mdinfo *sra) */ int block_monitor(char *container, const int freeze) { - int devnum = devname2devnum(container); struct mdstat_ent *ent, *e, *e2; struct mdinfo *sra = NULL; - char *version = NULL; char buf[64]; int rv = 0; - if (!mdmon_running(devnum)) { - /* if mdmon is not active we assume that any instance that is - * later started will match the current mdadm version, if this - * assumption is violated we may inadvertantly rebuild an array - * that was meant for reshape, or start rebuild on a spare that - * was to be moved to another container - */ - /* pass */; - } else { - int ver; - - version = ping_monitor_version(container); - ver = version ? mdadm_version(version) : -1; - free(version); - if (ver < 3002000) { - fprintf(stderr, Name - ": mdmon instance for %s cannot be disabled\n", - container); - return -1; - } - } + if (check_mdmon_version(container)) + return -1; ent = mdstat_read(0, 0); if (!ent) { |