diff options
author | NeilBrown <neilb@suse.de> | 2006-12-22 04:11:41 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-22 11:55:51 -0500 |
commit | 3f9d7b0d810f9fe3dc670901b694a9632b8d62b3 (patch) | |
tree | fd130bc302aa1f982deecaa3e602872c44a4d2e7 /drivers/md/md.c | |
parent | fe0e5c4d947d34f10002b4cf272f0ebf110305b7 (diff) |
[PATCH] md: fix a few problems with the interface (sysfs and ioctl) to md
While developing more functionality in mdadm I found some bugs in md...
- When we remove a device from an inactive array (write 'remove' to
the 'state' sysfs file - see 'state_store') would should not
update the superblock information - as we may not have
read and processed it all properly yet.
- initialise all raid_disk entries to '-1' else the 'slot sysfs file
will claim '0' for all devices in an array before the array is
started.
- all '\n' not to be present at the end of words written to
sysfs files
- when we use SET_ARRAY_INFO to set the md metadata version,
set the flag to say that there is persistant metadata.
- allow GET_BITMAP_FILE to be called on an array that hasn't
been started yet.
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 21e2a7b08841..d1cb45f6d6a9 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1792,7 +1792,8 @@ state_store(mdk_rdev_t *rdev, const char *buf, size_t len) | |||
1792 | else { | 1792 | else { |
1793 | mddev_t *mddev = rdev->mddev; | 1793 | mddev_t *mddev = rdev->mddev; |
1794 | kick_rdev_from_array(rdev); | 1794 | kick_rdev_from_array(rdev); |
1795 | md_update_sb(mddev, 1); | 1795 | if (mddev->pers) |
1796 | md_update_sb(mddev, 1); | ||
1796 | md_new_event(mddev); | 1797 | md_new_event(mddev); |
1797 | err = 0; | 1798 | err = 0; |
1798 | } | 1799 | } |
@@ -2004,6 +2005,7 @@ static mdk_rdev_t *md_import_device(dev_t newdev, int super_format, int super_mi | |||
2004 | 2005 | ||
2005 | rdev->desc_nr = -1; | 2006 | rdev->desc_nr = -1; |
2006 | rdev->saved_raid_disk = -1; | 2007 | rdev->saved_raid_disk = -1; |
2008 | rdev->raid_disk = -1; | ||
2007 | rdev->flags = 0; | 2009 | rdev->flags = 0; |
2008 | rdev->data_offset = 0; | 2010 | rdev->data_offset = 0; |
2009 | rdev->sb_events = 0; | 2011 | rdev->sb_events = 0; |
@@ -2233,7 +2235,6 @@ static int update_raid_disks(mddev_t *mddev, int raid_disks); | |||
2233 | static ssize_t | 2235 | static ssize_t |
2234 | raid_disks_store(mddev_t *mddev, const char *buf, size_t len) | 2236 | raid_disks_store(mddev_t *mddev, const char *buf, size_t len) |
2235 | { | 2237 | { |
2236 | /* can only set raid_disks if array is not yet active */ | ||
2237 | char *e; | 2238 | char *e; |
2238 | int rv = 0; | 2239 | int rv = 0; |
2239 | unsigned long n = simple_strtoul(buf, &e, 10); | 2240 | unsigned long n = simple_strtoul(buf, &e, 10); |
@@ -2631,7 +2632,7 @@ metadata_store(mddev_t *mddev, const char *buf, size_t len) | |||
2631 | return -EINVAL; | 2632 | return -EINVAL; |
2632 | buf = e+1; | 2633 | buf = e+1; |
2633 | minor = simple_strtoul(buf, &e, 10); | 2634 | minor = simple_strtoul(buf, &e, 10); |
2634 | if (e==buf || *e != '\n') | 2635 | if (e==buf || (*e && *e != '\n') ) |
2635 | return -EINVAL; | 2636 | return -EINVAL; |
2636 | if (major >= sizeof(super_types)/sizeof(super_types[0]) || | 2637 | if (major >= sizeof(super_types)/sizeof(super_types[0]) || |
2637 | super_types[major].name == NULL) | 2638 | super_types[major].name == NULL) |
@@ -3980,6 +3981,7 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info) | |||
3980 | mddev->major_version = info->major_version; | 3981 | mddev->major_version = info->major_version; |
3981 | mddev->minor_version = info->minor_version; | 3982 | mddev->minor_version = info->minor_version; |
3982 | mddev->patch_version = info->patch_version; | 3983 | mddev->patch_version = info->patch_version; |
3984 | mddev->persistent = !info->not_persistent; | ||
3983 | return 0; | 3985 | return 0; |
3984 | } | 3986 | } |
3985 | mddev->major_version = MD_MAJOR_VERSION; | 3987 | mddev->major_version = MD_MAJOR_VERSION; |
@@ -4304,9 +4306,10 @@ static int md_ioctl(struct inode *inode, struct file *file, | |||
4304 | * Commands querying/configuring an existing array: | 4306 | * Commands querying/configuring an existing array: |
4305 | */ | 4307 | */ |
4306 | /* if we are not initialised yet, only ADD_NEW_DISK, STOP_ARRAY, | 4308 | /* if we are not initialised yet, only ADD_NEW_DISK, STOP_ARRAY, |
4307 | * RUN_ARRAY, and SET_BITMAP_FILE are allowed */ | 4309 | * RUN_ARRAY, and GET_ and SET_BITMAP_FILE are allowed */ |
4308 | if (!mddev->raid_disks && cmd != ADD_NEW_DISK && cmd != STOP_ARRAY | 4310 | if (!mddev->raid_disks && cmd != ADD_NEW_DISK && cmd != STOP_ARRAY |
4309 | && cmd != RUN_ARRAY && cmd != SET_BITMAP_FILE) { | 4311 | && cmd != RUN_ARRAY && cmd != SET_BITMAP_FILE |
4312 | && cmd != GET_BITMAP_FILE) { | ||
4310 | err = -ENODEV; | 4313 | err = -ENODEV; |
4311 | goto abort_unlock; | 4314 | goto abort_unlock; |
4312 | } | 4315 | } |