All of lore.kernel.org
 help / color / mirror / Atom feed
* Subject:[PATCH 009:013]: raid0:add hot add and hot remove
@ 2009-06-16 21:57 raz ben yehuda
  0 siblings, 0 replies; only message in thread
From: raz ben yehuda @ 2009-06-16 21:57 UTC (permalink / raw)
  To: Neil Brown, linux raid

added : raid0_hot_add and raid0_hot_remove.fix alignment of device size to chunk size.

 raid0.c |   65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

Signed-off-by: razb <raziebe@gmail.com>
---
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 1e01c61..984d603 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -619,6 +619,69 @@ static void raid0_status(struct seq_file *seq, mddev_t *mddev)
 	return;
 }
 
+
+static int raid0_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
+{
+	char b[BDEVNAME_SIZE];
+	sector_t sectors;
+
+	if (rdev->sectors < mddev->chunk_sectors) {
+		printk(KERN_INFO "raid0: device smaller than "
+			"chunk size %llusectors < %llusectors\n",
+				(unsigned long long)rdev->sectors,
+				((unsigned long long)mddev->chunk_sectors));
+		return -1;
+	}
+	if (queue_max_hw_sectors(rdev->bdev->bd_disk->queue) <
+				queue_max_hw_sectors(mddev->queue)) {
+		printk(KERN_INFO "raid0: device trasnfer"
+			" size %usectors is smaller than other"
+			"raid's components %usectors, rejecting ",
+			queue_max_hw_sectors(rdev->bdev->bd_disk->queue),
+			queue_max_hw_sectors(mddev->queue));
+		/*
+		* todo. accept the device. and only generate an error
+		*/
+		return -1;
+	}
+	/*
+	* never allow adding new disks while reshape takes place
+	*/
+	if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery)) {
+		printk(KERN_ERR "raid0: %s is in reshape\n",
+				mdname(mddev));
+		return -EBUSY;
+	}
+	sectors = rdev->sectors;
+	sector_div(sectors, mddev->chunk_sectors);
+	sectors = sectors * mddev->chunk_sectors;
+	rdev->sectors = sectors;
+	printk(KERN_INFO "raid0: hot add:reduce device "
+		" %s size: %lld --> %lld\n",
+		bdevname(rdev->bdev, b),
+		(unsigned long long)rdev->sectors,
+		(unsigned long long)sectors);
+	return 0;
+}
+
+/*
+ * we allow removal of a disk only if it is a spare.
+*/
+static int raid0_remove_disk(mddev_t *mddev, int number)
+{
+	raid0_conf_t *conf = mddev->private;
+	mdk_rdev_t *rdev = conf->devlist[number];
+	if (!rdev) {
+		printk(KERN_ERR "%s: error try to"
+				" remove disk number %d\n",
+			mdname(mddev), number);
+		return -1;
+	}
+	if (rdev->raid_disk != -1)
+		return -1;
+	return 0;
+}
+
 static struct mdk_personality raid0_personality=
 {
 	.name		= "raid0",
@@ -629,6 +692,8 @@ static struct mdk_personality raid0_personality=
 	.stop		= raid0_stop,
 	.status		= raid0_status,
 	.size		= raid0_size,
+	.hot_add_disk	= raid0_add_disk,
+	.hot_remove_disk = raid0_remove_disk,
 };
 
 static int __init raid0_init (void)





^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-06-16 21:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-16 21:57 Subject:[PATCH 009:013]: raid0:add hot add and hot remove raz ben yehuda

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.