aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid0.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2009-03-17 21:10:40 -0400
committerDan Williams <dan.j.williams@intel.com>2009-03-30 23:57:49 -0400
commit80c3a6ce4ba4470379b9e6a4d9bcd9d2ee26ae03 (patch)
treede88622f05a7e681ac7bff7714e8f2d8953b66ac /drivers/md/raid0.c
parent93ed05e2a56b5ee06c0100a169433b11c4aa5d0b (diff)
md: add 'size' as a personality method
In preparation for giving userspace control over ->array_sectors we need to be able to retrieve the 'default' size, and the 'anticipated' size when a reshape is requested. For personalities that do not reshape emit a warning if anything but the default size is requested. In the raid5 case we need to update ->previous_raid_disks to make the new 'default' size available. Reviewed-by: Andre Noll <maan@systemlinux.org> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/md/raid0.c')
-rw-r--r--drivers/md/raid0.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 9aebb4c93b60..bb0df6a18443 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -263,12 +263,25 @@ static int raid0_mergeable_bvec(struct request_queue *q,
263 return max; 263 return max;
264} 264}
265 265
266static sector_t raid0_size(mddev_t *mddev, sector_t sectors, int raid_disks)
267{
268 sector_t array_sectors = 0;
269 mdk_rdev_t *rdev;
270
271 WARN_ONCE(sectors || raid_disks,
272 "%s does not support generic reshape\n", __func__);
273
274 list_for_each_entry(rdev, &mddev->disks, same_set)
275 array_sectors += rdev->sectors;
276
277 return array_sectors;
278}
279
266static int raid0_run (mddev_t *mddev) 280static int raid0_run (mddev_t *mddev)
267{ 281{
268 unsigned cur=0, i=0, nb_zone; 282 unsigned cur=0, i=0, nb_zone;
269 s64 sectors; 283 s64 sectors;
270 raid0_conf_t *conf; 284 raid0_conf_t *conf;
271 mdk_rdev_t *rdev;
272 285
273 if (mddev->chunk_size == 0) { 286 if (mddev->chunk_size == 0) {
274 printk(KERN_ERR "md/raid0: non-zero chunk size required.\n"); 287 printk(KERN_ERR "md/raid0: non-zero chunk size required.\n");
@@ -293,9 +306,7 @@ static int raid0_run (mddev_t *mddev)
293 goto out_free_conf; 306 goto out_free_conf;
294 307
295 /* calculate array device size */ 308 /* calculate array device size */
296 mddev->array_sectors = 0; 309 mddev->array_sectors = raid0_size(mddev, 0, 0);
297 list_for_each_entry(rdev, &mddev->disks, same_set)
298 mddev->array_sectors += rdev->sectors;
299 310
300 printk(KERN_INFO "raid0 : md_size is %llu sectors.\n", 311 printk(KERN_INFO "raid0 : md_size is %llu sectors.\n",
301 (unsigned long long)mddev->array_sectors); 312 (unsigned long long)mddev->array_sectors);
@@ -511,6 +522,7 @@ static struct mdk_personality raid0_personality=
511 .run = raid0_run, 522 .run = raid0_run,
512 .stop = raid0_stop, 523 .stop = raid0_stop,
513 .status = raid0_status, 524 .status = raid0_status,
525 .size = raid0_size,
514}; 526};
515 527
516static int __init raid0_init (void) 528static int __init raid0_init (void)