summaryrefslogtreecommitdiff
path: root/sysfs.c
diff options
context:
space:
mode:
authorAdam Kwolek <adam.kwolek@intel.com>2011-09-21 11:55:08 +1000
committerNeilBrown <neilb@suse.de>2011-09-21 11:55:08 +1000
commitddb12f6ca6c1b04fcc79f114f5d47d6c268ed37a (patch)
treee26a0c0aacc4ff233bf94cbafeceada88b5fbc95 /sysfs.c
parent7050aa3f6b45352539413492cafc1d26b2972e47 (diff)
FIX: Do not unblock array accidentally
When sysfs_set_array() function is called, it tests if array can be configured using sysfs. Setting metadata_version entry can accidentally unblock mdmon when array is under reshape. To avoid this, blocking character '-' is checked and if is is set, it is used for array test. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'sysfs.c')
-rw-r--r--sysfs.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sysfs.c b/sysfs.c
index 21462642..e1aaf4d9 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -541,8 +541,21 @@ int sysfs_set_array(struct mdinfo *info, int vers)
ver[0] = 0;
if (info->array.major_version == -1 &&
info->array.minor_version == -2) {
+ char buf[1024];
+
strcat(strcpy(ver, "external:"), info->text_version);
+ /* meta version might already be set if we are setting
+ * new geometry for a reshape. In that case we don't
+ * want to over-write the 'readonly' flag that is
+ * stored in the metadata version. So read the current
+ * version first, and preserve the flag
+ */
+ if (sysfs_get_str(info, NULL, "metadata_version",
+ buf, 1024) > 0)
+ if (strlen(buf) >= 9 && buf[9] == '-')
+ ver[9] = '-';
+
if ((vers % 100) < 2 ||
sysfs_set_str(info, NULL, "metadata_version",
ver) < 0) {