Subject : PATCH [001:001]: raid0 devices size should be aligned to chunk size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx
---
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;


--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux