From patchwork Thu Apr 28 19:10:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonthan Brassow X-Patchwork-Id: 739561 X-Patchwork-Delegate: agk@redhat.com Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3SJDMc6022772 for ; Thu, 28 Apr 2011 19:13:43 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p3SJAdSB018575; Thu, 28 Apr 2011 15:10:40 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p3SJAcAh024262 for ; Thu, 28 Apr 2011 15:10:38 -0400 Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.19]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p3SJAXg0031128 for ; Thu, 28 Apr 2011 15:10:33 -0400 Received: from localhost6.localdomain6 ([75.72.197.0]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3SJAT9J022280 for ; Thu, 28 Apr 2011 15:10:29 -0400 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by localhost6.localdomain6 (8.14.4/8.14.4) with ESMTP id p3SJASTQ029775 for ; Thu, 28 Apr 2011 14:10:29 -0500 Received: (from jbrassow@localhost) by localhost6.localdomain6 (8.14.4/8.14.4/Submit) id p3SJASjp029774 for dm-devel@redhat.com; Thu, 28 Apr 2011 14:10:28 -0500 From: Jonathan Brassow Message-Id: <201104281910.p3SJASjp029774@localhost6.localdomain6> Date: Thu, 28 Apr 2011 14:10:28 -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.68 on 10.5.11.23 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.19 Subject: [dm-devel] [PATCH] DM RAID: add write_mostly param 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]); Thu, 28 Apr 2011 19:13:43 +0000 (UTC) Patch name: dm-raid-add-write_mostly-param.patch Add the write_mostly parameter to the dm-raid table constructor. This allows the user to set the WriteMostly flag on a RAID1 device, so that it is normally avoided where read I/O is concerned. 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 @@ -296,6 +296,7 @@ static int validate_region_size(struct r * [daemon_sleep ] Time between bitmap daemon work to clear bits * [min_recovery_rate ] Throttle RAID initialization * [max_recovery_rate ] Throttle RAID initialization + * [write_mostly ] Indicate a write mostly drive via index * [max_write_behind ] See '-write-behind=' (man mdadm) * [stripe_cache ] Stripe cache size for higher RAIDs * [region_size ] Defines granularity of bitmap @@ -363,7 +364,21 @@ static int parse_raid_params(struct raid } clear_bit(In_sync, &rs->dev[value].rdev.flags); rs->dev[value].rdev.recovery_offset = 0; + } else if (!strcmp(key, "write_mostly")) { + if (rs->raid_type->level != 1) { + rs->ti->error = "write_mostly option is only valid for RAID1"; + return -EINVAL; + } + if (value > rs->md.raid_disks) { + rs->ti->error = "Invalid write_mostly index given"; + return -EINVAL; + } + set_bit(WriteMostly, &rs->dev[value].rdev.flags); } else if (!strcmp(key, "max_write_behind")) { + if (rs->raid_type->level != 1) { + rs->ti->error = "max_write_behind option is only valid for RAID1"; + return -EINVAL; + } rs->print_flags |= DMPF_MAX_WRITE_BEHIND; /* @@ -616,11 +631,14 @@ static int raid_status(struct dm_target break; case STATUSTYPE_TABLE: /* The string you would use to construct this array */ - for (i = 0; i < rs->md.raid_disks; i++) + for (i = 0; i < rs->md.raid_disks; i++) { if (rs->dev[i].data_dev && !test_bit(In_sync, &rs->dev[i].rdev.flags)) - raid_param_cnt++; /* for rebuilds */ - + raid_param_cnt += 2; /* for rebuilds */ + if (rs->dev[i].data_dev && + test_bit(WriteMostly, &rs->dev[i].rdev.flags)) + raid_param_cnt += 2; + } raid_param_cnt += (hweight64(rs->print_flags) * 2); if (rs->print_flags & (DMPF_SYNC | DMPF_NOSYNC)) raid_param_cnt--; @@ -633,10 +651,14 @@ static int raid_status(struct dm_target DMEMIT(" sync"); if (rs->print_flags & DMPF_NOSYNC) DMEMIT(" nosync"); - for (i = 0; i < rs->md.raid_disks; i++) + for (i = 0; i < rs->md.raid_disks; i++) { if (rs->dev[i].data_dev && !test_bit(In_sync, &rs->dev[i].rdev.flags)) DMEMIT(" rebuild %u", i); + if (rs->dev[i].data_dev && + test_bit(WriteMostly, &rs->dev[i].rdev.flags)) + DMEMIT(" write_mostly %u", i); + } if (rs->print_flags & DMPF_DAEMON_SLEEP) DMEMIT(" daemon_sleep %lu",