1 From c4647292fda0833bebe45be27f04453b736981fa Mon Sep 17 00:00:00 2001
2 From: NeilBrown <neilb@suse.de>
3 Date: Thu, 7 May 2009 12:51:06 +1000
4 Subject: [PATCH] md: remove rd%d links immediately after stopping an array.
6 md maintains link in sys/mdXX/md/ to identify which device has
7 which role in the array. e.g.
10 indicates that the device with role '2' in the array is sda.
12 These links are only present when the array is active. They are
13 created immediately after ->run is called, and so should be removed
14 immediately after ->stop is called.
15 However they are currently removed a little bit later, and it is
16 possible for ->run to be called again, thus adding these links, before
19 So move the removal earlier so they are consistently only present when
22 Signed-off-by: NeilBrown <neilb@suse.de>
24 drivers/md/md.c | 17 ++++++++---------
25 1 file changed, 8 insertions(+), 9 deletions(-)
29 @@ -3877,6 +3877,7 @@ static int do_md_stop(mddev_t * mddev, i
32 struct gendisk *disk = mddev->gendisk;
35 if (atomic_read(&mddev->openers) > is_open) {
36 printk("md: %s still in use.\n",mdname(mddev));
37 @@ -3919,6 +3920,13 @@ static int do_md_stop(mddev_t * mddev, i
38 /* tell userspace to handle 'inactive' */
39 sysfs_notify(&mddev->kobj, NULL, "array_state");
41 + list_for_each_entry(rdev, &mddev->disks, same_set)
42 + if (rdev->raid_disk >= 0) {
44 + sprintf(nm, "rd%d", rdev->raid_disk);
45 + sysfs_remove_link(&mddev->kobj, nm);
48 set_capacity(disk, 0);
51 @@ -3939,8 +3947,6 @@ static int do_md_stop(mddev_t * mddev, i
52 * Free resources if final stop
56 - struct list_head *tmp;
58 printk(KERN_INFO "md: %s stopped.\n", mdname(mddev));
60 @@ -3952,13 +3958,6 @@ static int do_md_stop(mddev_t * mddev, i
62 mddev->bitmap_offset = 0;
64 - rdev_for_each(rdev, tmp, mddev)
65 - if (rdev->raid_disk >= 0) {
67 - sprintf(nm, "rd%d", rdev->raid_disk);
68 - sysfs_remove_link(&mddev->kobj, nm);
71 /* make sure all md_delayed_delete calls have finished */
72 flush_scheduled_work();