Skip to content

Commit

Permalink
dax: move the dax_read_lock() locking into dax_supported
Browse files Browse the repository at this point in the history
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>
Link: https://lore.kernel.org/r/20210826135510.6293-6-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
  • Loading branch information
Christoph Hellwig authored and djbw committed Aug 26, 2021
1 parent 1b76460 commit 673a065
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
16 changes: 9 additions & 7 deletions drivers/dax/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
9 changes: 2 additions & 7 deletions drivers/md/dm-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 673a065

Please sign in to comment.