Skip to content

Commit 673a065

Browse files
Christoph Hellwigdjbw
authored andcommitted
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 <[email protected]> Reviewed-by: Dan Williams <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent 1b76460 commit 673a065

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

drivers/dax/super.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize)
219219
struct request_queue *q;
220220
char buf[BDEVNAME_SIZE];
221221
bool ret;
222-
int id;
223222

224223
q = bdev_get_queue(bdev);
225224
if (!q || !blk_queue_dax(q)) {
@@ -235,10 +234,8 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize)
235234
return false;
236235
}
237236

238-
id = dax_read_lock();
239237
ret = dax_supported(dax_dev, bdev, blocksize, 0,
240238
i_size_read(bdev->bd_inode) / 512);
241-
dax_read_unlock(id);
242239

243240
put_dax(dax_dev);
244241

@@ -356,13 +353,18 @@ EXPORT_SYMBOL_GPL(dax_direct_access);
356353
bool dax_supported(struct dax_device *dax_dev, struct block_device *bdev,
357354
int blocksize, sector_t start, sector_t len)
358355
{
359-
if (!dax_dev)
360-
return false;
356+
bool ret = false;
357+
int id;
361358

362-
if (!dax_alive(dax_dev))
359+
if (!dax_dev)
363360
return false;
364361

365-
return dax_dev->ops->dax_supported(dax_dev, bdev, blocksize, start, len);
362+
id = dax_read_lock();
363+
if (dax_alive(dax_dev))
364+
ret = dax_dev->ops->dax_supported(dax_dev, bdev, blocksize,
365+
start, len);
366+
dax_read_unlock(id);
367+
return ret;
366368
}
367369
EXPORT_SYMBOL_GPL(dax_supported);
368370

drivers/md/dm-table.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -809,14 +809,9 @@ EXPORT_SYMBOL_GPL(dm_table_set_type);
809809
int device_not_dax_capable(struct dm_target *ti, struct dm_dev *dev,
810810
sector_t start, sector_t len, void *data)
811811
{
812-
int blocksize = *(int *) data, id;
813-
bool rc;
812+
int blocksize = *(int *) data;
814813

815-
id = dax_read_lock();
816-
rc = !dax_supported(dev->dax_dev, dev->bdev, blocksize, start, len);
817-
dax_read_unlock(id);
818-
819-
return rc;
814+
return !dax_supported(dev->dax_dev, dev->bdev, blocksize, start, len);
820815
}
821816

822817
/* Check devices support synchronous DAX */

0 commit comments

Comments
 (0)