linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Subject : PATCH [001:001]: raid0 devices size should be aligned to chunk size
@ 2009-06-01 18:55 raz ben yehuda
  2009-06-04  5:27 ` Neil Brown
  0 siblings, 1 reply; 2+ messages in thread
From: raz ben yehuda @ 2009-06-01 18:55 UTC (permalink / raw)
  To: Neil Brown; +Cc: linux raid

raid devices should be aligned to a chunk size 
(when this feature will be enabled)  because zones 
will become un-aligned to chunks and we will traverse
between zones in a single IO access. 

 raid0.c |   22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
Signed-off-by: raziebe@gmail.com
---
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 0fcd9b5..987a926 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -302,6 +302,26 @@ static sector_t raid0_size(mddev_t *mddev, sector_t sectors, int raid_disks)
 	return array_sectors;
 }
 
+/*
+ *	Align devices to a chunk size, else zones will not be aligned
+*/
+static void align_devices_to_chunk_size(struct list_head *disks,
+					int chunk_sects)
+{
+	sector_t sectors;
+	mdk_rdev_t *rdev;
+
+	list_for_each_entry(rdev, disks, same_set) {
+		sectors = rdev->sectors;
+		sector_div(sectors, chunk_sects);
+		sectors = sectors * chunk_sects;
+		printk(KERN_INFO "raid0: reduce device size: %lld --> %lld\n",
+				(unsigned long long)rdev->sectors,
+				(unsigned long long)sectors);
+		rdev->sectors = sectors;
+	}
+}
+
 static int raid0_run(mddev_t *mddev)
 {
 	int ret;
@@ -313,7 +333,7 @@ static int raid0_run(mddev_t *mddev)
 	}
 	blk_queue_max_sectors(mddev->queue, mddev->chunk_sectors);
 	mddev->queue->queue_lock = &mddev->queue->__queue_lock;
-
+	align_devices_to_chunk_size(&mddev->disks, mddev->chunk_sectors);
 	ret = create_strip_zones(mddev);
 	if (ret < 0)
 		return ret;



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-06-04  5:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-01 18:55 Subject : PATCH [001:001]: raid0 devices size should be aligned to chunk size raz ben yehuda
2009-06-04  5:27 ` Neil Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).