Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3969256rwd; Tue, 23 May 2023 00:48:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4H3V0NS9pvAu8NVU3OuTihdnbNgaY5DaUY5joYnZjkYjYF111pB7SzHlB70hY9QvWBHhBN X-Received: by 2002:a05:6a20:a10c:b0:105:23cf:747d with SMTP id q12-20020a056a20a10c00b0010523cf747dmr13257225pzk.5.1684828131792; Tue, 23 May 2023 00:48:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684828131; cv=none; d=google.com; s=arc-20160816; b=BOob5ujKFd3hd9CwY8hmATyemOw+dp9HxS7xxdkB5cYO40rFvsxfAcn6knhZfD55Fz STPQ+Tayio/JSLOoiJyXpq1/HmsvwXuYic6WPGMKMtoibNaZl1C4Vgw5oSepAPfBni3j HMwiioTTW7wYSMcdwedx++RZsplcOKPg+lZbz16AmFhezBfO/rEELeDimATEVEi1dHsd rCvA57sb5t+clUChGevol+MOl9SzyuYfBOoW3X7BlGnXl4aUGN0/dKhKudsyBXNxslsl ag6sj3OKPIVc3CDwy0OlOTjFs4ae1IUmad6bXAdyq2NUW2kDLP7UiVI69g398Qhnyx7N r24A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1j9PBfjt7C2OyHwYLb5o3ix4kUllkeK0wk1Jd5LdU0M=; b=SriqTc38BqfHExwc9W5BVvGA8qGxRqejosEosogrlOhMAOytPEa+HKHKNqzk/BGN0K HepeiOsjMBIuvs+pacmQifdU1zvL4S/dEwmH9ieSGzbr00pvM95vJOvyynpWUX/o/zzZ W2f99LaR4w02htjjjbJuJIMbIl/1elXV1JGWOfWN8lrW8e4zhXMxHFMPXgm1xfb+pAOY kayMjr1BxySInlzogAvLwjGOKg60+akNX5FYqbVKlkhArE7L13Qk0HdppcLcQ/a20hQk 9L9Tk+57+B1cMeegSu9CMuPlliED6lZ0ENmJRz1HnFN1JqBn6vDOKL8wSNmsGQ6SFQFz 2lDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=bANGpmMP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q1-20020a656a81000000b00513522599casi6068969pgu.831.2023.05.23.00.48.29; Tue, 23 May 2023 00:48:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=bANGpmMP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235628AbjEWHrR (ORCPT + 99 others); Tue, 23 May 2023 03:47:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235766AbjEWHqm (ORCPT ); Tue, 23 May 2023 03:46:42 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5135F196; Tue, 23 May 2023 00:46:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=1j9PBfjt7C2OyHwYLb5o3ix4kUllkeK0wk1Jd5LdU0M=; b=bANGpmMPSjXPMHstCgaRRkjVxe bc1gOv4QuRafF7E+izc51x/WzpLGtmhh9y7Qyh7DOTVJFsd+MU5GKquOFAWgLV+px2CQrgGL6TZbo lobwzr4zeypkc0IByP4jhVev+D2cLRl88de8olNUn55W6+8voZzakshGeKbji4NTocT+fcr7kyAO2 SHgTdyIVWPm+R0KcuPAztO91gZnzTTs0K9dxNMCkiiE7OXsIj4YXHxtzkPCv+9mzlB9mUrsHwTfMT qVNY1OZt+2atpAsjDzDPxoQz7gmkHx8yTNiZITXxZi6ycXLfe4VbUXwV4PpGbr6jM1LCVD6Kmu/Bq WXq1qvNA==; Received: from [2001:4bb8:188:23b2:6ade:85c9:530f:6eb0] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q1Miu-009H5F-2p; Tue, 23 May 2023 07:46:26 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Mike Snitzer , Joern Engel , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Pavel Machek , dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-mtd@lists.infradead.org, linux-pm@vger.kernel.org Subject: [PATCH 17/24] dm-snap: simplify the origin_dev == cow_dev check in snapshot_ctr Date: Tue, 23 May 2023 09:45:28 +0200 Message-Id: <20230523074535.249802-18-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230523074535.249802-1-hch@lst.de> References: <20230523074535.249802-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the block_device acquired in dm_get_device for the check instead of doing an extra lookup. Signed-off-by: Christoph Hellwig --- drivers/md/dm-snap.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index 9c49f53760d066..7832974b73eb03 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c @@ -1241,7 +1241,6 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) int i; int r = -EINVAL; char *origin_path, *cow_path; - dev_t origin_dev, cow_dev; unsigned int args_used, num_flush_bios = 1; fmode_t origin_mode = FMODE_READ; @@ -1279,24 +1278,21 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) ti->error = "Cannot get origin device"; goto bad_origin; } - origin_dev = s->origin->bdev->bd_dev; cow_path = argv[0]; argv++; argc--; - cow_dev = dm_get_dev_t(cow_path); - if (cow_dev && cow_dev == origin_dev) { - ti->error = "COW device cannot be the same as origin device"; - r = -EINVAL; - goto bad_cow; - } - r = dm_get_device(ti, cow_path, dm_table_get_mode(ti->table), &s->cow); if (r) { ti->error = "Cannot get COW device"; goto bad_cow; } + if (s->cow->bdev && s->cow->bdev == s->origin->bdev) { + ti->error = "COW device cannot be the same as origin device"; + r = -EINVAL; + goto bad_store; + } r = dm_exception_store_create(ti, argc, argv, s, &args_used, &s->store); if (r) { -- 2.39.2