Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp96907imm; Thu, 21 Jun 2018 14:37:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLA2hjAgKb9gceGFadmzYn1BQYPnwvpthLWVzAc8TxAvPHFEidCISIjJGPr7FaoWaOjeHqT X-Received: by 2002:a63:985:: with SMTP id 127-v6mr7467222pgj.52.1529617064052; Thu, 21 Jun 2018 14:37:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529617064; cv=none; d=google.com; s=arc-20160816; b=jf+gv2G1Lab3v2rbzkfbjLTGiM8Qpn/+zZBlv11x3eyDRIRMdLx/Rrc/0FD3clX3eW Gg86FANGU6a4Y0KYYfZ+HPLXhbIoV5CRwIHyYdwcMWQf8cR03St84R2+3yAmbPr3JXxl 6u3wOGwKCF9zGUUEDFyap5/Lv0qhP+fRgM1ij5ZRb9yV8ZpwgUxJ6OM7W5hihH87B78e eSWDu9ZUoR5yZGCTz/12znoTCaebtIXOw2/id5ZDA9RsN5+QMcJYFzZ8eW0rYVQC0mmL tZ1FdNhukVME+Kh1B+b8JAixJG/4M4QeDQEyYQQHytJsT2kRJ5cOtjiI1TPqL67OO3r+ Pj7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=3v5cb3ungbn+3WhVqlYPxkaORf+/gaUplqO6OFgHmAQ=; b=tX3nipHI6kWb4jelo/uVNiQ64iTMO6og4p7Z/lD139QNhEawarq4GhwAirbZdNqXkt m9dIyWN03jP38tUfH/EWpjRYQCCP0XnRXlLFWzZrPgt2pTASD5WGZOdKLcSyJh5QdFUh vXhKg8BtxfNY7zkDa8CAyvRyVK1muHLRzJ28RMOO25BTIO4CwKD/bgmigB4Q0uEp7vaC xYsUcHx5ENPqvXOjDFh2x/lh2lhCtc6IQ4KfdRvh3S5++YxdwbqHrh/g3/CY+Cp7xZsS OyWAtO0QoSoaAroeuYtyFlWkbGQ9PVr3kQASYMKyy8U6t9WHEjdoVENa+lrmNGFLwU/s ssMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1-v6si5933746plf.453.2018.06.21.14.37.28; Thu, 21 Jun 2018 14:37:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933998AbeFUVfm (ORCPT + 99 others); Thu, 21 Jun 2018 17:35:42 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59564 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933670AbeFUVfj (ORCPT ); Thu, 21 Jun 2018 17:35:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7EE1DFC159 for ; Thu, 21 Jun 2018 21:35:39 +0000 (UTC) Received: from dhcp145-120.rdu.redhat.com (ovpn-122-47.rdu2.redhat.com [10.10.122.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A92681117650; Thu, 21 Jun 2018 21:35:36 +0000 (UTC) From: John Pittman To: snitzer@redhat.com Cc: dm-devel@redhat.com, linux-kernel@vger.kernel.org, loberman@redhat.com, John Pittman Subject: [PATCH] dm cache: require io_mode cache feature selection to be mutually exclusive Date: Thu, 21 Jun 2018 17:35:33 -0400 Message-Id: <1529616933-11644-1-git-send-email-jpittman@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 21 Jun 2018 21:35:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 21 Jun 2018 21:35:39 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jpittman@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Due to commit 629d0a8a1a10 ("dm cache metadata: add "metadata2" feature"), when creating a dm cache device, more than one io_mode can be selected. As the io_mode selections are incompatible with one another, we should force them to be selected exclusively. Add simple ctr to check for more than one io_mode selection. Signed-off-by: John Pittman --- drivers/md/dm-cache-target.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c index ce14a3d..45e3bed 100644 --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c @@ -2250,7 +2250,7 @@ static int parse_features(struct cache_args *ca, struct dm_arg_set *as, {0, 2, "Invalid number of cache feature arguments"}, }; - int r; + int r, mode_ctr = 0; unsigned argc; const char *arg; struct cache_features *cf = &ca->features; @@ -2264,14 +2264,20 @@ static int parse_features(struct cache_args *ca, struct dm_arg_set *as, while (argc--) { arg = dm_shift_arg(as); - if (!strcasecmp(arg, "writeback")) + if (!strcasecmp(arg, "writeback")) { cf->io_mode = CM_IO_WRITEBACK; + mode_ctr++; + } - else if (!strcasecmp(arg, "writethrough")) + else if (!strcasecmp(arg, "writethrough")) { cf->io_mode = CM_IO_WRITETHROUGH; + mode_ctr++; + } - else if (!strcasecmp(arg, "passthrough")) + else if (!strcasecmp(arg, "passthrough")) { cf->io_mode = CM_IO_PASSTHROUGH; + mode_ctr++; + } else if (!strcasecmp(arg, "metadata2")) cf->metadata_version = 2; @@ -2282,6 +2288,11 @@ static int parse_features(struct cache_args *ca, struct dm_arg_set *as, } } + if (mode_ctr > 1) { + *error = "Invalid number of cache io_mode features requested"; + return -EINVAL; + } + return 0; } -- 2.7.5