Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp457882pxb; Thu, 26 Aug 2021 07:04:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmscU9b9QwQCmVOLtTExUVfqRWn+A3KKHZqsr6mLbSfgsYI2/6+rvM4seuifNeL91COG9h X-Received: by 2002:a05:6602:2219:: with SMTP id n25mr3096942ion.185.1629986668013; Thu, 26 Aug 2021 07:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629986668; cv=none; d=google.com; s=arc-20160816; b=Rf/RC/4POLPlz06UqFsgGWVgXh5kOkWxUCoTEZH0fNZSUdB0ODytzZl6Rf4KzsQBBV bbJBTfSUMCvJsBkOiQuEFKf/ysVNYzMqsnXC4eY/+Ia7J8oHc54RV9cD/3S9ugP3d7gr Ph/kvWUY0aNLg8NAZnghzOu8MqjuLnYqJfEzplXQILQGGBZsI/SebpN3PzRJJLgX9EK/ QOmnBcs52XCP4YdU97aburucY0l/xMlUysK9qPJkb1TwgOGDqB9Dz8zcp1ajO5y9LOYh eleELGJpFkbQ25pz7JdGZh8BxutmRW/p7ye7lE23l4QIfXK4S4Ep8V2Pdo8xCcQPStO9 OF3A== 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=Z9CHVYQyeiZP1zGiHqM8jPmt7R5TRlqGY7aMignBaKI=; b=jrSnrvdBsS/ttNB9ri/ZsKyYej+7Ji1WRHfr+thsA0tZca0QmI0HRj0SIs4nRDsCmT b8bdBQr//fMbzX/3HyQcahcEEK9xvNTEirXT5Av8mxCFbHp3lu7RMGE982k7YEIDh4mL 7U1HLJJhKBXzMBecBgC6dgsCDfx3Sl9l9MvjtKXmkKIBMfd4g0maq0G4vWPWuz3D2hgF kW3wqfgLp950tYBtgSfW5eroR2pXD9e7bnTEY/9splPbCDTEXxu6c59N1enjZaMyUMki NvCih4erIKmKKpPDdR1r69HMXxkTNUhZSPrgbbRQcnc/VrVfpdajOQ+LG0+mweuRa+Ue 96jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=quuk5ch5; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j19si3236686jat.113.2021.08.26.07.04.14; Thu, 26 Aug 2021 07:04:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=quuk5ch5; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242730AbhHZODq (ORCPT + 99 others); Thu, 26 Aug 2021 10:03:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229793AbhHZODq (ORCPT ); Thu, 26 Aug 2021 10:03:46 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00980C061757; Thu, 26 Aug 2021 07:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=Z9CHVYQyeiZP1zGiHqM8jPmt7R5TRlqGY7aMignBaKI=; b=quuk5ch5SO25TnJLxmqcTU5Vr1 cOJZUkQvQ922q531qpgQUuFCe5KKbONQYxNhnFPn9wg5vuTnf/42UnvzkYp132B6Hf5T43vQ5Vwvr dRgGdxqJNTkrhJqLqii/az9dRycmq/Wqzro+8Fowj36mHxNZ5eufvjP95jHH8fYoStteUPjAT+T3C g4giQAClaIRWsVJE2llF11wp3dWject9JglIplTQ0P7ljenmXbxrN3e1mDDQEzJ/WWeqbQxRFYJA4 G8XtFSF4jXlBtDVwtO9q+6BNRg0i/TVt9idq/B7i/AMabAio4ayb9mYRMvCuhDQ54a/3Tytfnlyol JgeTvkOQ==; Received: from [2001:4bb8:193:fd10:d9d9:6c15:481b:99c4] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJFvU-00DMKD-T1; Thu, 26 Aug 2021 14:00:37 +0000 From: Christoph Hellwig To: Dan Williams , Vishal Verma , Dave Jiang Cc: Mike Snitzer , Matthew Wilcox , linux-xfs@vger.kernel.org, nvdimm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org Subject: [PATCH 5/9] dax: move the dax_read_lock() locking into dax_supported Date: Thu, 26 Aug 2021 15:55:06 +0200 Message-Id: <20210826135510.6293-6-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210826135510.6293-1-hch@lst.de> References: <20210826135510.6293-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Move the dax_read_lock/dax_read_unlock pair from the callers into dax_supported to make it a little easier to use. Signed-off-by: Christoph Hellwig Reviewed-by: Dan Williams --- drivers/dax/super.c | 16 +++++++++------- drivers/md/dm-table.c | 9 ++------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index e13fde57c33e..0f74f83101ab 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -219,7 +219,6 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize) struct request_queue *q; char buf[BDEVNAME_SIZE]; bool ret; - int id; q = bdev_get_queue(bdev); if (!q || !blk_queue_dax(q)) { @@ -235,10 +234,8 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize) return false; } - id = dax_read_lock(); ret = dax_supported(dax_dev, bdev, blocksize, 0, i_size_read(bdev->bd_inode) / 512); - dax_read_unlock(id); put_dax(dax_dev); @@ -356,13 +353,18 @@ EXPORT_SYMBOL_GPL(dax_direct_access); bool dax_supported(struct dax_device *dax_dev, struct block_device *bdev, int blocksize, sector_t start, sector_t len) { - if (!dax_dev) - return false; + bool ret = false; + int id; - if (!dax_alive(dax_dev)) + if (!dax_dev) return false; - return dax_dev->ops->dax_supported(dax_dev, bdev, blocksize, start, len); + id = dax_read_lock(); + if (dax_alive(dax_dev)) + ret = dax_dev->ops->dax_supported(dax_dev, bdev, blocksize, + start, len); + dax_read_unlock(id); + return ret; } EXPORT_SYMBOL_GPL(dax_supported); diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 0543cdf89e92..b53acca37581 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -809,14 +809,9 @@ EXPORT_SYMBOL_GPL(dm_table_set_type); int device_not_dax_capable(struct dm_target *ti, struct dm_dev *dev, sector_t start, sector_t len, void *data) { - int blocksize = *(int *) data, id; - bool rc; + int blocksize = *(int *) data; - id = dax_read_lock(); - rc = !dax_supported(dev->dax_dev, dev->bdev, blocksize, start, len); - dax_read_unlock(id); - - return rc; + return !dax_supported(dev->dax_dev, dev->bdev, blocksize, start, len); } /* Check devices support synchronous DAX */ -- 2.30.2