From patchwork Tue May 24 19:31:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonthan Brassow X-Patchwork-Id: 813542 Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4OK1C2x015378 for ; Tue, 24 May 2011 20:01:35 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4OJwF3G027600; Tue, 24 May 2011 15:58:23 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4OJwEdg022185 for ; Tue, 24 May 2011 15:58:14 -0400 Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.17]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4OJw9pQ007822 for ; Tue, 24 May 2011 15:58:09 -0400 Received: from localhost6.localdomain6 ([75.72.197.0]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4OJw8TB017442 for ; Tue, 24 May 2011 15:58:09 -0400 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by localhost6.localdomain6 (8.14.4/8.14.4) with ESMTP id p4OJVZZJ006338 for ; Tue, 24 May 2011 14:31:35 -0500 Received: (from jbrassow@localhost) by localhost6.localdomain6 (8.14.4/8.14.4/Submit) id p4OJVZWJ006336 for dm-devel@redhat.com; Tue, 24 May 2011 14:31:35 -0500 From: Jonathan Brassow Message-Id: <201105241931.p4OJVZWJ006336@localhost6.localdomain6> Date: Tue, 24 May 2011 14:31:34 -0500 To: dm-devel@redhat.com User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 X-RedHat-Blacklist-Warning: Relay 75.72.197.0 is blacklisted by a RBL system X-RedHat-NoPTR: 75.72.197.0 has sent a message and has no valid PTR record X-RedHat-Spam-Score: 5.212 ***** (NO_DNS_FOR_FROM, RCVD_IN_PBL, RCVD_IN_SORBS_DUL, RDNS_NONE) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.17 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH] DM RAID: add RAID1 support X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 24 May 2011 20:01:35 +0000 (UTC) Patch name: dm-raid-add-RAID1-support.patch Add support to access the MD RAID1 personality through dm-raid. Signed-off-by: Jonathan Brassow --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6/drivers/md/dm-raid.c =================================================================== --- linux-2.6.orig/drivers/md/dm-raid.c +++ linux-2.6/drivers/md/dm-raid.c @@ -8,6 +8,7 @@ #include #include "md.h" +#include "raid1.h" #include "raid5.h" #include "dm.h" #include "bitmap.h" @@ -73,6 +74,7 @@ static struct raid_type { const unsigned level; /* RAID level. */ const unsigned algorithm; /* RAID algorithm. */ } raid_types[] = { + {"raid1", "RAID1 (mirroring)", 0, 2, 1, 0 /* NONE */}, {"raid4", "RAID4 (dedicated parity disk)", 1, 2, 5, ALGORITHM_PARITY_0}, {"raid5_la", "RAID5 (left asymmetric)", 1, 2, 5, ALGORITHM_LEFT_ASYMMETRIC}, {"raid5_ra", "RAID5 (right asymmetric)", 1, 2, 5, ALGORITHM_RIGHT_ASYMMETRIC}, @@ -106,7 +108,8 @@ static struct raid_set *context_alloc(st } sectors_per_dev = ti->len; - if (sector_div(sectors_per_dev, (raid_devs - raid_type->parity_devs))) { + if ((raid_type->level > 1) && + sector_div(sectors_per_dev, (raid_devs - raid_type->parity_devs))) { ti->error = "Target length not divisible by number of data devices"; return ERR_PTR(-EINVAL); } @@ -318,10 +321,14 @@ static int validate_region_size(struct r /* * Possible arguments are... + * RAID1: + * [optional_args] * RAID456: * [optional_args] * - * Optional args: + * Argument definitions + * Specific to raid456, the number of sectors per + * disk that will form the "stripe" * [[no]sync] Force or prevent recovery of the entire array * [rebuild ] Rebuild the drive indicated by the index * [daemon_sleep ] Time between bitmap daemon work to clear bits @@ -341,16 +348,20 @@ static int parse_raid_params(struct raid /* * First, parse the in-order required arguments + * "chunk_sectors" is the only argument of this type and + * is only required by raid456 */ - if ((strict_strtoul(argv[0], 10, &value) < 0) || - !is_power_of_2(value) || (value < 8)) { - rs->ti->error = "Bad chunk size"; - return -EINVAL; - } + if (rs->raid_type->level != 1) { + if ((strict_strtoul(argv[0], 10, &value) < 0) || + !is_power_of_2(value) || (value < 8)) { + rs->ti->error = "Bad chunk size"; + return -EINVAL; + } - rs->md.new_chunk_sectors = rs->md.chunk_sectors = value; - argv++; - num_raid_params--; + rs->md.new_chunk_sectors = rs->md.chunk_sectors = value; + argv++; + num_raid_params--; + } for (i = 0; i < rs->md.raid_disks; i++) { /* @@ -515,6 +526,11 @@ static int raid_is_congested(struct dm_t { struct raid_set *rs = container_of(cb, struct raid_set, callbacks); +#ifdef md_raid1_congested + if (rs->raid_type->level == 1) + return md_raid1_congested(&rs->md, bits); +#endif + return md_raid5_congested(&rs->md, bits); } @@ -549,6 +565,13 @@ static int raid_ctr(struct dm_target *ti argc--; argv++; +#ifndef md_raid1_congested + if (rt->level == 1) { + ti->error = "RAID 1 is not yet supported"; + return -EINVAL; + } +#endif + /* number of RAID parameters */ if (strict_strtoul(argv[0], 10, &num_raid_params) < 0) { ti->error = "Cannot understand number of RAID parameters"; @@ -608,6 +631,7 @@ static int raid_ctr(struct dm_target *ti rs->callbacks.congested_fn = raid_is_congested; dm_table_add_target_callbacks(ti->table, &rs->callbacks); + mddev_suspend(&rs->md); return 0; bad: @@ -681,8 +705,11 @@ static int raid_status(struct dm_target if (rs->print_flags & (DMPF_SYNC | DMPF_NOSYNC)) raid_param_cnt--; - DMEMIT("%s %u %u", rs->raid_type->name, - raid_param_cnt, rs->md.chunk_sectors); + if (rs->raid_type->level != 1) + DMEMIT("%s %u %u", rs->raid_type->name, + raid_param_cnt, rs->md.chunk_sectors); + else + DMEMIT("%s %u", rs->raid_type->name, raid_param_cnt - 1); if ((rs->print_flags & DMPF_SYNC) && (rs->md.recovery_cp == MaxSector))