nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Dan Williams <dan.j.williams@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Dave Jiang <dave.jiang@intel.com>
Cc: Mike Snitzer <snitzer@redhat.com>,
	Matthew Wilcox <willy@infradead.org>,
	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	[thread overview]
Message-ID: <20210826135510.6293-6-hch@lst.de> (raw)
In-Reply-To: <20210826135510.6293-1-hch@lst.de>

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 <hch@lst.de>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
---
 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


  parent reply	other threads:[~2021-08-26 14:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26 13:55 dax_supported() related cleanups v2 Christoph Hellwig
2021-08-26 13:55 ` [PATCH 1/9] fsdax: improve the FS_DAX Kconfig description and help text Christoph Hellwig
2021-08-26 13:55 ` [PATCH 2/9] dax: stop using bdevname Christoph Hellwig
2021-08-26 13:55 ` [PATCH 3/9] dm: use fs_dax_get_by_bdev instead of dax_get_by_host Christoph Hellwig
2021-08-26 14:42   ` Dan Williams
2021-08-26 16:19     ` Mike Snitzer
2021-08-26 13:55 ` [PATCH 4/9] dax: mark dax_get_by_host static Christoph Hellwig
2021-08-26 13:55 ` Christoph Hellwig [this message]
2021-08-26 13:55 ` [PATCH 6/9] dax: remove __generic_fsdax_supported Christoph Hellwig
2021-08-26 13:55 ` [PATCH 7/9] dax: stub out dax_supported for !CONFIG_FS_DAX Christoph Hellwig
2021-08-26 13:55 ` [PATCH 8/9] xfs: factor out a xfs_buftarg_is_dax helper Christoph Hellwig
2021-08-26 14:37   ` Dan Williams
2021-08-26 15:11     ` Darrick J. Wong
2021-08-26 13:55 ` [PATCH 9/9] dax: remove bdev_dax_supported Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2021-08-23 12:35 dax_supported() related cleanups Christoph Hellwig
2021-08-23 12:35 ` [PATCH 5/9] dax: move the dax_read_lock() locking into dax_supported Christoph Hellwig
2021-08-23 20:57   ` Dan Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210826135510.6293-6-hch@lst.de \
    --to=hch@lst.de \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=snitzer@redhat.com \
    --cc=vishal.l.verma@intel.com \
    --cc=willy@infradead.org \
    --subject='Re: [PATCH 5/9] dax: move the dax_read_lock() locking into dax_supported' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).