From patchwork Fri Aug 23 03:14:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junichi Nomura X-Patchwork-Id: 2848531 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0CE799F271 for ; Fri, 23 Aug 2013 03:19:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 166DF201F6 for ; Fri, 23 Aug 2013 03:19:33 +0000 (UTC) Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mail.kernel.org (Postfix) with ESMTP id EABE4201E7 for ; Fri, 23 Aug 2013 03:19:31 +0000 (UTC) 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 r7N3FDfh012626; Thu, 22 Aug 2013 23:15:13 -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 r7N3FBAT032192 for ; Thu, 22 Aug 2013 23:15:11 -0400 Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.19]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r7N3FBZU001672; Thu, 22 Aug 2013 23:15:11 -0400 Received: from tyo202.gate.nec.co.jp (TYO202.gate.nec.co.jp [210.143.35.52]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7N3FAW7022814; Thu, 22 Aug 2013 23:15:10 -0400 Received: from mailgate3.nec.co.jp ([10.7.69.160]) by tyo202.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id r7N3F78D004738; Fri, 23 Aug 2013 12:15:07 +0900 (JST) Received: from mailsv4.nec.co.jp (imss62.nec.co.jp [10.7.69.157]) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) with ESMTP id r7N3F7919535; Fri, 23 Aug 2013 12:15:07 +0900 (JST) Received: from mail02.kamome.nec.co.jp (mail02.kamome.nec.co.jp [10.25.43.5]) by mailsv4.nec.co.jp (8.13.8/8.13.4) with ESMTP id r7N3F6Af023218; Fri, 23 Aug 2013 12:15:06 +0900 (JST) Received: from shikibu.jp.nec.com ([10.26.220.2] [10.26.220.2]) by mail01b.kamome.nec.co.jp with ESMTP id BT-MMP-1238021; Fri, 23 Aug 2013 12:14:46 +0900 Received: from xzibit.linux.bs1.fc.nec.co.jp ([10.34.125.128] [10.34.125.128]) by mail.jp.nec.com with ESMTP; Fri, 23 Aug 2013 12:14:46 +0900 Message-ID: <5216D3A2.8020209@ce.jp.nec.com> Date: Fri, 23 Aug 2013 12:14:42 +0900 From: "Jun'ichi Nomura" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 MIME-Version: 1.0 To: device-mapper development , Mike Snitzer References: <5214CC25.1070307@oracle.com> <52157C6E.6080406@oracle.com> <20130822201900.GB22556@redhat.com> <20130823001750.GA29366@redhat.com> In-Reply-To: <20130823001750.GA29366@redhat.com> X-RedHat-Spam-Score: -4.202 (BAYES_00, RCVD_IN_DNSWL_MED, SPF_HELO_PASS, SPF_PASS) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.19 X-loop: dm-devel@redhat.com Cc: Mikulas Patocka , Joe Jin , "linux-kernel@vger.kernel.org" , Alasdair Kergon Subject: Re: [dm-devel] [PATCH] dm: allow error target to replace either bio-based and request-based targets 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-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hello Mike, On 08/23/13 09:17, Mike Snitzer wrote: >> I do like the idea of a single error target that is hybrid (supports >> both bio-based and request-based) but the DM core would need to be >> updated to support this. >> >> Specifically, we'd need to check if the device (and active table) is >> already bio-based or request-based and select the appropriate type. If >> it is a new device, default to selecting bio-based. >> >> There are some wrappers and other logic thoughout DM core that will need >> auditing too. > > Here is a patch that should work for your needs (I tested it to work > with 'dmsetup wipe_table' on both request-based and bio-based devices): How about moving the default handling in dm_table_set_type() outside of the for-each-target loop, like the modified patch below? For example, if a table has 2 targets, hybrid and request_based, and live_md_type is DM_TYPE_NONE, the table should be considered as request_based, not inconsistent. Though the end result is same as such a table is rejected by other constraint anyway, I think it's good to keep the semantics clean and error messages consistent. I.e. for the above case, the error message should be "Request-based dm doesn't support multiple targets yet", not "Inconsistent table: different target types can't be mixed up". --- Jun'ichi Nomura, NEC Corporation -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index f221812..6e683c8 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -860,14 +860,16 @@ EXPORT_SYMBOL(dm_consume_args); static int dm_table_set_type(struct dm_table *t) { unsigned i; - unsigned bio_based = 0, request_based = 0; + unsigned bio_based = 0, request_based = 0, hybrid = 0; struct dm_target *tgt; struct dm_dev_internal *dd; struct list_head *devices; for (i = 0; i < t->num_targets; i++) { tgt = t->targets + i; - if (dm_target_request_based(tgt)) + if (dm_target_hybrid(tgt)) + hybrid = 1; + else if (dm_target_request_based(tgt)) request_based = 1; else bio_based = 1; @@ -879,6 +881,25 @@ static int dm_table_set_type(struct dm_table *t) } } + if (hybrid && !bio_based && !request_based) { + /* + * The targets can work either way. + * Determine the type from the live device. + */ + unsigned live_md_type; + dm_lock_md_type(t->md); + live_md_type = dm_get_md_type(t->md); + dm_unlock_md_type(t->md); + switch (live_md_type) { + case DM_TYPE_REQUEST_BASED: + request_based = 1; + break; + default: + bio_based = 1; + break; + } + } + if (bio_based) { /* We must use this table as bio-based */ t->type = DM_TYPE_BIO_BASED; diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c index 37ba5db..242e3ce 100644 --- a/drivers/md/dm-target.c +++ b/drivers/md/dm-target.c @@ -131,12 +131,19 @@ static int io_err_map(struct dm_target *tt, struct bio *bio) return -EIO; } +static int io_err_map_rq(struct dm_target *ti, struct request *clone, + union map_info *map_context) +{ + return -EIO; +} + static struct target_type error_target = { .name = "error", - .version = {1, 1, 0}, + .version = {1, 2, 0}, .ctr = io_err_ctr, .dtr = io_err_dtr, .map = io_err_map, + .map_rq = io_err_map_rq, }; int __init dm_target_init(void) diff --git a/drivers/md/dm.h b/drivers/md/dm.h index 45b97da..8b4c075 100644 --- a/drivers/md/dm.h +++ b/drivers/md/dm.h @@ -89,10 +89,21 @@ int dm_setup_md_queue(struct mapped_device *md); #define dm_target_is_valid(t) ((t)->table) /* + * To check whether the target type is bio-based or not (request-based). + */ +#define dm_target_bio_based(t) ((t)->type->map != NULL) + +/* * To check whether the target type is request-based or not (bio-based). */ #define dm_target_request_based(t) ((t)->type->map_rq != NULL) +/* + * To check whether the target type is a hybrid (capable of being + * either request-based or bio-based). + */ +#define dm_target_hybrid(t) (dm_target_bio_based(t) && dm_target_request_based(t)) + /*----------------------------------------------------------------- * A registry of target types. *---------------------------------------------------------------*/