From dfa584f6f91586dbf7bb9f35f8bbdc06590cde1f Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 26 Aug 2021 15:55:04 +0200 Subject: dm: use fs_dax_get_by_bdev instead of dax_get_by_host There is no point in trying to finding the dax device if the DAX flag is not set on the queue as none of the users of the device mapper exported block devices could make use of the DAX capability. Signed-off-by: Christoph Hellwig Reviewed-by: Dan Williams Reviewed-by: Mike Snitzer Link: https://lore.kernel.org/r/20210826135510.6293-4-hch@lst.de Signed-off-by: Dan Williams --- drivers/md/dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/md') diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 2c5f9e585211..465714341300 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -650,7 +650,7 @@ static int open_table_device(struct table_device *td, dev_t dev, } td->dm_dev.bdev = bdev; - td->dm_dev.dax_dev = dax_get_by_host(bdev->bd_disk->disk_name); + td->dm_dev.dax_dev = fs_dax_get_by_bdev(bdev); return 0; } -- cgit v1.2.3 From 673a0658f6ac359131a881c0dcf1b91c2500ab9c Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 26 Aug 2021 15:55:06 +0200 Subject: dax: move the dax_read_lock() locking into dax_supported 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 Link: https://lore.kernel.org/r/20210826135510.6293-6-hch@lst.de Signed-off-by: Dan Williams --- drivers/dax/super.c | 16 +++++++++------- drivers/md/dm-table.c | 9 ++------- 2 files changed, 11 insertions(+), 14 deletions(-) (limited to 'drivers/md') 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 */ -- cgit v1.2.3