diff options
author | Dan Williams <dan.j.williams@intel.com> | 2010-05-02 13:04:16 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-05-18 01:27:58 -0400 |
commit | f2859af6716ce99cac7f35c5a0c6b7fed346312f (patch) | |
tree | 37d1af49ce710098bc35d45c7a9aec6e6f8eb5d9 /drivers/md/md.c | |
parent | bb7f8d2217d8753ab5008c78f16697d9e697d570 (diff) |
md: allow integers to be passed to md/level
e.g. allow md to interpret 'echo 4 > md/level' as a request for raid4.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 69f659e46aa6..b8a0fcfb1de1 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -2934,9 +2934,10 @@ level_show(mddev_t *mddev, char *page) | |||
2934 | static ssize_t | 2934 | static ssize_t |
2935 | level_store(mddev_t *mddev, const char *buf, size_t len) | 2935 | level_store(mddev_t *mddev, const char *buf, size_t len) |
2936 | { | 2936 | { |
2937 | char level[16]; | 2937 | char clevel[16]; |
2938 | ssize_t rv = len; | 2938 | ssize_t rv = len; |
2939 | struct mdk_personality *pers; | 2939 | struct mdk_personality *pers; |
2940 | long level; | ||
2940 | void *priv; | 2941 | void *priv; |
2941 | mdk_rdev_t *rdev; | 2942 | mdk_rdev_t *rdev; |
2942 | 2943 | ||
@@ -2969,19 +2970,22 @@ level_store(mddev_t *mddev, const char *buf, size_t len) | |||
2969 | } | 2970 | } |
2970 | 2971 | ||
2971 | /* Now find the new personality */ | 2972 | /* Now find the new personality */ |
2972 | if (len == 0 || len >= sizeof(level)) | 2973 | if (len == 0 || len >= sizeof(clevel)) |
2973 | return -EINVAL; | 2974 | return -EINVAL; |
2974 | strncpy(level, buf, len); | 2975 | strncpy(clevel, buf, len); |
2975 | if (level[len-1] == '\n') | 2976 | if (clevel[len-1] == '\n') |
2976 | len--; | 2977 | len--; |
2977 | level[len] = 0; | 2978 | clevel[len] = 0; |
2979 | if (strict_strtol(clevel, 10, &level)) | ||
2980 | level = LEVEL_NONE; | ||
2978 | 2981 | ||
2979 | request_module("md-%s", level); | 2982 | if (request_module("md-%s", clevel) != 0) |
2983 | request_module("md-level-%s", clevel); | ||
2980 | spin_lock(&pers_lock); | 2984 | spin_lock(&pers_lock); |
2981 | pers = find_pers(LEVEL_NONE, level); | 2985 | pers = find_pers(level, clevel); |
2982 | if (!pers || !try_module_get(pers->owner)) { | 2986 | if (!pers || !try_module_get(pers->owner)) { |
2983 | spin_unlock(&pers_lock); | 2987 | spin_unlock(&pers_lock); |
2984 | printk(KERN_WARNING "md: personality %s not loaded\n", level); | 2988 | printk(KERN_WARNING "md: personality %s not loaded\n", clevel); |
2985 | return -EINVAL; | 2989 | return -EINVAL; |
2986 | } | 2990 | } |
2987 | spin_unlock(&pers_lock); | 2991 | spin_unlock(&pers_lock); |
@@ -2994,7 +2998,7 @@ level_store(mddev_t *mddev, const char *buf, size_t len) | |||
2994 | if (!pers->takeover) { | 2998 | if (!pers->takeover) { |
2995 | module_put(pers->owner); | 2999 | module_put(pers->owner); |
2996 | printk(KERN_WARNING "md: %s: %s does not support personality takeover\n", | 3000 | printk(KERN_WARNING "md: %s: %s does not support personality takeover\n", |
2997 | mdname(mddev), level); | 3001 | mdname(mddev), clevel); |
2998 | return -EINVAL; | 3002 | return -EINVAL; |
2999 | } | 3003 | } |
3000 | 3004 | ||
@@ -3010,7 +3014,7 @@ level_store(mddev_t *mddev, const char *buf, size_t len) | |||
3010 | mddev->delta_disks = 0; | 3014 | mddev->delta_disks = 0; |
3011 | module_put(pers->owner); | 3015 | module_put(pers->owner); |
3012 | printk(KERN_WARNING "md: %s: %s would not accept array\n", | 3016 | printk(KERN_WARNING "md: %s: %s would not accept array\n", |
3013 | mdname(mddev), level); | 3017 | mdname(mddev), clevel); |
3014 | return PTR_ERR(priv); | 3018 | return PTR_ERR(priv); |
3015 | } | 3019 | } |
3016 | 3020 | ||