aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@notabene.brown>2008-06-27 18:31:31 -0400
committerNeil Brown <neilb@notabene.brown>2008-06-27 18:31:31 -0400
commit6c2fce2ef6b4821c21b5c42c7207cb9cf8c87eda (patch)
tree726b16f46c039df387f7cdfe0d195821d8955532 /drivers/md/md.c
parent8ed0a5216a0238f53b482ec88ce4aeed4b9f0da1 (diff)
Support adding a spare to a live md array with external metadata.
i.e. extend the 'md/dev-XXX/slot' attribute so that you can tell a device to fill an vacant slot in an and md array. Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 3b5cd4ef54f1..5d6fac1fd39e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1932,7 +1932,7 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1932 slot = -1; 1932 slot = -1;
1933 else if (e==buf || (*e && *e!= '\n')) 1933 else if (e==buf || (*e && *e!= '\n'))
1934 return -EINVAL; 1934 return -EINVAL;
1935 if (rdev->mddev->pers) { 1935 if (rdev->mddev->pers && slot == -1) {
1936 /* Setting 'slot' on an active array requires also 1936 /* Setting 'slot' on an active array requires also
1937 * updating the 'rd%d' link, and communicating 1937 * updating the 'rd%d' link, and communicating
1938 * with the personality with ->hot_*_disk. 1938 * with the personality with ->hot_*_disk.
@@ -1940,8 +1940,6 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1940 * failed/spare devices. This normally happens automatically, 1940 * failed/spare devices. This normally happens automatically,
1941 * but not when the metadata is externally managed. 1941 * but not when the metadata is externally managed.
1942 */ 1942 */
1943 if (slot != -1)
1944 return -EBUSY;
1945 if (rdev->raid_disk == -1) 1943 if (rdev->raid_disk == -1)
1946 return -EEXIST; 1944 return -EEXIST;
1947 /* personality does all needed checks */ 1945 /* personality does all needed checks */
@@ -1955,6 +1953,44 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1955 sysfs_remove_link(&rdev->mddev->kobj, nm); 1953 sysfs_remove_link(&rdev->mddev->kobj, nm);
1956 set_bit(MD_RECOVERY_NEEDED, &rdev->mddev->recovery); 1954 set_bit(MD_RECOVERY_NEEDED, &rdev->mddev->recovery);
1957 md_wakeup_thread(rdev->mddev->thread); 1955 md_wakeup_thread(rdev->mddev->thread);
1956 } else if (rdev->mddev->pers) {
1957 mdk_rdev_t *rdev2;
1958 struct list_head *tmp;
1959 /* Activating a spare .. or possibly reactivating
1960 * if we every get bitmaps working here.
1961 */
1962
1963 if (rdev->raid_disk != -1)
1964 return -EBUSY;
1965
1966 if (rdev->mddev->pers->hot_add_disk == NULL)
1967 return -EINVAL;
1968
1969 rdev_for_each(rdev2, tmp, rdev->mddev)
1970 if (rdev2->raid_disk == slot)
1971 return -EEXIST;
1972
1973 rdev->raid_disk = slot;
1974 if (test_bit(In_sync, &rdev->flags))
1975 rdev->saved_raid_disk = slot;
1976 else
1977 rdev->saved_raid_disk = -1;
1978 err = rdev->mddev->pers->
1979 hot_add_disk(rdev->mddev, rdev);
1980 if (err != 1) {
1981 rdev->raid_disk = -1;
1982 if (err == 0)
1983 return -EEXIST;
1984 return err;
1985 }
1986 sprintf(nm, "rd%d", rdev->raid_disk);
1987 if (sysfs_create_link(&rdev->mddev->kobj, &rdev->kobj, nm))
1988 printk(KERN_WARNING
1989 "md: cannot register "
1990 "%s for %s\n",
1991 nm, mdname(rdev->mddev));
1992
1993 /* don't wakeup anyone, leave that to userspace. */
1958 } else { 1994 } else {
1959 if (slot >= rdev->mddev->raid_disks) 1995 if (slot >= rdev->mddev->raid_disks)
1960 return -ENOSPC; 1996 return -ENOSPC;