]> git.ipfire.org Git - thirdparty/mdadm.git/blob - kernel-patch-2.6.25
Don't close fds in write_init_super
[thirdparty/mdadm.git] / kernel-patch-2.6.25
1 Status: ok
2
3 Support adding a spare to a live md array with external metadata.
4
5 i.e. extend the 'md/dev-XXX/slot' attribute so that you can
6 tell a device to fill an vacant slot in an and md array.
7
8
9 Signed-off-by: Neil Brown <neilb@suse.de>
10
11 ### Diffstat output
12 ./drivers/md/md.c | 44 ++++++++++++++++++++++++++++++++++++++++----
13 ./drivers/md/multipath.c | 7 ++++++-
14 ./drivers/md/raid1.c | 7 ++++++-
15 ./drivers/md/raid10.c | 10 ++++++++--
16 ./drivers/md/raid5.c | 10 ++++++++--
17 5 files changed, 68 insertions(+), 10 deletions(-)
18
19 diff .prev/drivers/md/md.c ./drivers/md/md.c
20 --- .prev/drivers/md/md.c 2008-06-05 09:19:56.000000000 +1000
21 +++ ./drivers/md/md.c 2008-06-10 10:41:21.000000000 +1000
22 @@ -1932,7 +1932,7 @@ slot_store(mdk_rdev_t *rdev, const char
23 slot = -1;
24 else if (e==buf || (*e && *e!= '\n'))
25 return -EINVAL;
26 - if (rdev->mddev->pers) {
27 + if (rdev->mddev->pers && slot == -1) {
28 /* Setting 'slot' on an active array requires also
29 * updating the 'rd%d' link, and communicating
30 * with the personality with ->hot_*_disk.
31 @@ -1940,8 +1940,6 @@ slot_store(mdk_rdev_t *rdev, const char
32 * failed/spare devices. This normally happens automatically,
33 * but not when the metadata is externally managed.
34 */
35 - if (slot != -1)
36 - return -EBUSY;
37 if (rdev->raid_disk == -1)
38 return -EEXIST;
39 /* personality does all needed checks */
40 @@ -1955,6 +1953,44 @@ slot_store(mdk_rdev_t *rdev, const char
41 sysfs_remove_link(&rdev->mddev->kobj, nm);
42 set_bit(MD_RECOVERY_NEEDED, &rdev->mddev->recovery);
43 md_wakeup_thread(rdev->mddev->thread);
44 + } else if (rdev->mddev->pers) {
45 + mdk_rdev_t *rdev2;
46 + struct list_head *tmp;
47 + /* Activating a spare .. or possibly reactivating
48 + * if we every get bitmaps working here.
49 + */
50 +
51 + if (rdev->raid_disk != -1)
52 + return -EBUSY;
53 +
54 + if (rdev->mddev->pers->hot_add_disk == NULL)
55 + return -EINVAL;
56 +
57 + rdev_for_each(rdev2, tmp, rdev->mddev)
58 + if (rdev2->raid_disk == slot)
59 + return -EEXIST;
60 +
61 + rdev->raid_disk = slot;
62 + if (test_bit(In_sync, &rdev->flags))
63 + rdev->saved_raid_disk = slot;
64 + else
65 + rdev->saved_raid_disk = -1;
66 + err = rdev->mddev->pers->
67 + hot_add_disk(rdev->mddev, rdev);
68 + if (err != 1) {
69 + rdev->raid_disk = -1;
70 + if (err == 0)
71 + return -EEXIST;
72 + return err;
73 + }
74 + sprintf(nm, "rd%d", rdev->raid_disk);
75 + if (sysfs_create_link(&rdev->mddev->kobj, &rdev->kobj, nm))
76 + printk(KERN_WARNING
77 + "md: cannot register "
78 + "%s for %s\n",
79 + nm, mdname(rdev->mddev));
80 +
81 + /* don't wakeup anyone, leave that to userspace. */
82 } else {
83 if (slot >= rdev->mddev->raid_disks)
84 return -ENOSPC;
85 @@ -4205,7 +4241,7 @@ static int add_new_disk(mddev_t * mddev,
86 super_types[mddev->major_version].
87 validate_super(mddev, rdev);
88 err = mddev->pers->hot_add_disk(mddev, rdev);
89 - if (err)
90 + if (err < 0)
91 unbind_rdev_from_array(rdev);
92 }
93 if (err)
94
95 diff .prev/drivers/md/multipath.c ./drivers/md/multipath.c
96 --- .prev/drivers/md/multipath.c 2008-05-30 14:49:31.000000000 +1000
97 +++ ./drivers/md/multipath.c 2008-06-10 10:35:03.000000000 +1000
98 @@ -284,10 +284,15 @@ static int multipath_add_disk(mddev_t *m
99 int found = 0;
100 int path;
101 struct multipath_info *p;
102 + int first = 0;
103 + int last = mddev->raid_disks - 1;
104 +
105 + if (rdev->raid_disk >= 0)
106 + first = last = rdev->raid_disk;
107
108 print_multipath_conf(conf);
109
110 - for (path=0; path<mddev->raid_disks; path++)
111 + for (path = first; path <= last; path++)
112 if ((p=conf->multipaths+path)->rdev == NULL) {
113 q = rdev->bdev->bd_disk->queue;
114 blk_queue_stack_limits(mddev->queue, q);
115
116 diff .prev/drivers/md/raid10.c ./drivers/md/raid10.c
117 --- .prev/drivers/md/raid10.c 2008-05-30 14:49:31.000000000 +1000
118 +++ ./drivers/md/raid10.c 2008-06-10 10:28:53.000000000 +1000
119 @@ -1116,6 +1116,8 @@ static int raid10_add_disk(mddev_t *mdde
120 int found = 0;
121 int mirror;
122 mirror_info_t *p;
123 + int first = 0;
124 + int last = mddev->raid_disks - 1;
125
126 if (mddev->recovery_cp < MaxSector)
127 /* only hot-add to in-sync arrays, as recovery is
128 @@ -1125,12 +1127,16 @@ static int raid10_add_disk(mddev_t *mdde
129 if (!enough(conf))
130 return 0;
131
132 + if (rdev->raid_disk)
133 + first = last = rdev->raid_disk;
134 +
135 if (rdev->saved_raid_disk >= 0 &&
136 + rdev->saved_raid_disk >= first &&
137 conf->mirrors[rdev->saved_raid_disk].rdev == NULL)
138 mirror = rdev->saved_raid_disk;
139 else
140 - mirror = 0;
141 - for ( ; mirror < mddev->raid_disks; mirror++)
142 + mirror = first;
143 + for ( ; mirror <= last ; mirror++)
144 if ( !(p=conf->mirrors+mirror)->rdev) {
145
146 blk_queue_stack_limits(mddev->queue,
147
148 diff .prev/drivers/md/raid1.c ./drivers/md/raid1.c
149 --- .prev/drivers/md/raid1.c 2008-05-30 14:49:31.000000000 +1000
150 +++ ./drivers/md/raid1.c 2008-06-10 10:41:00.000000000 +1000
151 @@ -1103,8 +1103,13 @@ static int raid1_add_disk(mddev_t *mddev
152 int found = 0;
153 int mirror = 0;
154 mirror_info_t *p;
155 + int first = 0;
156 + int last = mddev->raid_disks - 1;
157
158 - for (mirror=0; mirror < mddev->raid_disks; mirror++)
159 + if (rdev->raid_disk >= 0)
160 + first = last = rdev->raid_disk;
161 +
162 + for (mirror = first; mirror <= last; mirror++)
163 if ( !(p=conf->mirrors+mirror)->rdev) {
164
165 blk_queue_stack_limits(mddev->queue,
166
167 diff .prev/drivers/md/raid5.c ./drivers/md/raid5.c
168 --- .prev/drivers/md/raid5.c 2008-05-30 14:49:35.000000000 +1000
169 +++ ./drivers/md/raid5.c 2008-06-10 10:27:51.000000000 +1000
170 @@ -4399,21 +4399,27 @@ static int raid5_add_disk(mddev_t *mddev
171 int found = 0;
172 int disk;
173 struct disk_info *p;
174 + int first = 0;
175 + int last = conf->raid_disks - 1;
176
177 if (mddev->degraded > conf->max_degraded)
178 /* no point adding a device */
179 return 0;
180
181 + if (rdev->raid_disk >= 0)
182 + first = last = rdev->raid_disk;
183 +
184 /*
185 * find the disk ... but prefer rdev->saved_raid_disk
186 * if possible.
187 */
188 if (rdev->saved_raid_disk >= 0 &&
189 + rdev->saved_raid_disk >= first &&
190 conf->disks[rdev->saved_raid_disk].rdev == NULL)
191 disk = rdev->saved_raid_disk;
192 else
193 - disk = 0;
194 - for ( ; disk < conf->raid_disks; disk++)
195 + disk = first;
196 + for ( ; disk <= last ; disk++)
197 if ((p=conf->disks + disk)->rdev == NULL) {
198 clear_bit(In_sync, &rdev->flags);
199 rdev->raid_disk = disk;