Skip to content

Commit 7b0800d

Browse files
Christoph Hellwigdjbw
authored andcommitted
dax: remove dax_capable
Just open code the block size and dax_dev == NULL checks in the callers. Signed-off-by: Christoph Hellwig <[email protected]> Acked-by: Mike Snitzer <[email protected]> Reviewed-by: Gao Xiang <[email protected]> [erofs] Reviewed-by: Dan Williams <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent 679a994 commit 7b0800d

File tree

11 files changed

+36
-110
lines changed

11 files changed

+36
-110
lines changed

drivers/dax/super.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -107,42 +107,6 @@ struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev)
107107
return dax_dev;
108108
}
109109
EXPORT_SYMBOL_GPL(fs_dax_get_by_bdev);
110-
111-
bool generic_fsdax_supported(struct dax_device *dax_dev,
112-
struct block_device *bdev, int blocksize, sector_t start,
113-
sector_t sectors)
114-
{
115-
if (blocksize != PAGE_SIZE) {
116-
pr_info("%pg: error: unsupported blocksize for dax\n", bdev);
117-
return false;
118-
}
119-
120-
if (!dax_dev) {
121-
pr_debug("%pg: error: dax unsupported by block device\n", bdev);
122-
return false;
123-
}
124-
125-
return true;
126-
}
127-
EXPORT_SYMBOL_GPL(generic_fsdax_supported);
128-
129-
bool dax_supported(struct dax_device *dax_dev, struct block_device *bdev,
130-
int blocksize, sector_t start, sector_t len)
131-
{
132-
bool ret = false;
133-
int id;
134-
135-
if (!dax_dev)
136-
return false;
137-
138-
id = dax_read_lock();
139-
if (dax_alive(dax_dev) && dax_dev->ops->dax_supported)
140-
ret = dax_dev->ops->dax_supported(dax_dev, bdev, blocksize,
141-
start, len);
142-
dax_read_unlock(id);
143-
return ret;
144-
}
145-
EXPORT_SYMBOL_GPL(dax_supported);
146110
#endif /* CONFIG_BLOCK && CONFIG_FS_DAX */
147111

148112
enum dax_device_flags {

drivers/md/dm-table.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -806,12 +806,14 @@ void dm_table_set_type(struct dm_table *t, enum dm_queue_mode type)
806806
EXPORT_SYMBOL_GPL(dm_table_set_type);
807807

808808
/* validate the dax capability of the target device span */
809-
int device_not_dax_capable(struct dm_target *ti, struct dm_dev *dev,
809+
static 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;
812+
if (dev->dax_dev)
813+
return false;
813814

814-
return !dax_supported(dev->dax_dev, dev->bdev, blocksize, start, len);
815+
DMDEBUG("%pg: error: dax unsupported by block device", dev->bdev);
816+
return true;
815817
}
816818

817819
/* Check devices support synchronous DAX */
@@ -821,8 +823,8 @@ static int device_not_dax_synchronous_capable(struct dm_target *ti, struct dm_de
821823
return !dev->dax_dev || !dax_synchronous(dev->dax_dev);
822824
}
823825

824-
bool dm_table_supports_dax(struct dm_table *t,
825-
iterate_devices_callout_fn iterate_fn, int *blocksize)
826+
static bool dm_table_supports_dax(struct dm_table *t,
827+
iterate_devices_callout_fn iterate_fn)
826828
{
827829
struct dm_target *ti;
828830
unsigned i;
@@ -835,7 +837,7 @@ bool dm_table_supports_dax(struct dm_table *t,
835837
return false;
836838

837839
if (!ti->type->iterate_devices ||
838-
ti->type->iterate_devices(ti, iterate_fn, blocksize))
840+
ti->type->iterate_devices(ti, iterate_fn, NULL))
839841
return false;
840842
}
841843

@@ -862,7 +864,6 @@ static int dm_table_determine_type(struct dm_table *t)
862864
struct dm_target *tgt;
863865
struct list_head *devices = dm_table_get_devices(t);
864866
enum dm_queue_mode live_md_type = dm_get_md_type(t->md);
865-
int page_size = PAGE_SIZE;
866867

867868
if (t->type != DM_TYPE_NONE) {
868869
/* target already set the table's type */
@@ -906,7 +907,7 @@ static int dm_table_determine_type(struct dm_table *t)
906907
verify_bio_based:
907908
/* We must use this table as bio-based */
908909
t->type = DM_TYPE_BIO_BASED;
909-
if (dm_table_supports_dax(t, device_not_dax_capable, &page_size) ||
910+
if (dm_table_supports_dax(t, device_not_dax_capable) ||
910911
(list_empty(devices) && live_md_type == DM_TYPE_DAX_BIO_BASED)) {
911912
t->type = DM_TYPE_DAX_BIO_BASED;
912913
}
@@ -1976,7 +1977,6 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
19761977
struct queue_limits *limits)
19771978
{
19781979
bool wc = false, fua = false;
1979-
int page_size = PAGE_SIZE;
19801980
int r;
19811981

19821982
/*
@@ -2010,9 +2010,9 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
20102010
}
20112011
blk_queue_write_cache(q, wc, fua);
20122012

2013-
if (dm_table_supports_dax(t, device_not_dax_capable, &page_size)) {
2013+
if (dm_table_supports_dax(t, device_not_dax_capable)) {
20142014
blk_queue_flag_set(QUEUE_FLAG_DAX, q);
2015-
if (dm_table_supports_dax(t, device_not_dax_synchronous_capable, NULL))
2015+
if (dm_table_supports_dax(t, device_not_dax_synchronous_capable))
20162016
set_dax_synchronous(t->md->dax_dev);
20172017
}
20182018
else

drivers/md/dm.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,26 +1027,6 @@ static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff,
10271027
return ret;
10281028
}
10291029

1030-
static bool dm_dax_supported(struct dax_device *dax_dev, struct block_device *bdev,
1031-
int blocksize, sector_t start, sector_t len)
1032-
{
1033-
struct mapped_device *md = dax_get_private(dax_dev);
1034-
struct dm_table *map;
1035-
bool ret = false;
1036-
int srcu_idx;
1037-
1038-
map = dm_get_live_table(md, &srcu_idx);
1039-
if (!map)
1040-
goto out;
1041-
1042-
ret = dm_table_supports_dax(map, device_not_dax_capable, &blocksize);
1043-
1044-
out:
1045-
dm_put_live_table(md, srcu_idx);
1046-
1047-
return ret;
1048-
}
1049-
10501030
static size_t dm_dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff,
10511031
void *addr, size_t bytes, struct iov_iter *i)
10521032
{
@@ -3044,7 +3024,6 @@ static const struct block_device_operations dm_rq_blk_dops = {
30443024

30453025
static const struct dax_operations dm_dax_ops = {
30463026
.direct_access = dm_dax_direct_access,
3047-
.dax_supported = dm_dax_supported,
30483027
.copy_from_iter = dm_dax_copy_from_iter,
30493028
.copy_to_iter = dm_dax_copy_to_iter,
30503029
.zero_page_range = dm_dax_zero_page_range,

drivers/md/dm.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ bool dm_table_bio_based(struct dm_table *t);
7373
bool dm_table_request_based(struct dm_table *t);
7474
void dm_table_free_md_mempools(struct dm_table *t);
7575
struct dm_md_mempools *dm_table_get_md_mempools(struct dm_table *t);
76-
bool dm_table_supports_dax(struct dm_table *t, iterate_devices_callout_fn fn,
77-
int *blocksize);
78-
int device_not_dax_capable(struct dm_target *ti, struct dm_dev *dev,
79-
sector_t start, sector_t len, void *data);
8076

8177
void dm_lock_md_type(struct mapped_device *md);
8278
void dm_unlock_md_type(struct mapped_device *md);

drivers/nvdimm/pmem.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ static size_t pmem_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff,
321321

322322
static const struct dax_operations pmem_dax_ops = {
323323
.direct_access = pmem_dax_direct_access,
324-
.dax_supported = generic_fsdax_supported,
325324
.copy_from_iter = pmem_copy_from_iter,
326325
.copy_to_iter = pmem_copy_to_iter,
327326
.zero_page_range = pmem_dax_zero_page_range,

drivers/s390/block/dcssblk.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ static int dcssblk_dax_zero_page_range(struct dax_device *dax_dev,
7272

7373
static const struct dax_operations dcssblk_dax_ops = {
7474
.direct_access = dcssblk_dax_direct_access,
75-
.dax_supported = generic_fsdax_supported,
7675
.copy_from_iter = dcssblk_dax_copy_from_iter,
7776
.copy_to_iter = dcssblk_dax_copy_to_iter,
7877
.zero_page_range = dcssblk_dax_zero_page_range,

fs/erofs/super.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -652,10 +652,13 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
652652
if (err)
653653
return err;
654654

655-
if (test_opt(&sbi->opt, DAX_ALWAYS) &&
656-
!dax_supported(sbi->dax_dev, sb->s_bdev, EROFS_BLKSIZ, 0, bdev_nr_sectors(sb->s_bdev))) {
657-
errorfc(fc, "DAX unsupported by block device. Turning off DAX.");
658-
clear_opt(&sbi->opt, DAX_ALWAYS);
655+
if (test_opt(&sbi->opt, DAX_ALWAYS)) {
656+
BUILD_BUG_ON(EROFS_BLKSIZ != PAGE_SIZE);
657+
658+
if (!sbi->dax_dev) {
659+
errorfc(fc, "DAX unsupported by block device. Turning off DAX.");
660+
clear_opt(&sbi->opt, DAX_ALWAYS);
661+
}
659662
}
660663
sb->s_flags |= SB_RDONLY | SB_NOATIME;
661664
sb->s_maxbytes = MAX_LFS_FILESIZE;

fs/ext2/super.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,11 +946,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
946946
blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
947947

948948
if (test_opt(sb, DAX)) {
949-
if (!dax_supported(dax_dev, sb->s_bdev, blocksize, 0,
950-
bdev_nr_sectors(sb->s_bdev))) {
949+
if (!dax_dev) {
951950
ext2_msg(sb, KERN_ERR,
952951
"DAX unsupported by block device. Turning off DAX.");
953952
clear_opt(sbi->s_mount_opt, DAX);
953+
} else if (blocksize != PAGE_SIZE) {
954+
ext2_msg(sb, KERN_ERR, "unsupported blocksize for DAX\n");
955+
clear_opt(sbi->s_mount_opt, DAX);
954956
}
955957
}
956958

fs/ext4/super.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4299,9 +4299,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
42994299
goto failed_mount;
43004300
}
43014301

4302-
if (dax_supported(dax_dev, sb->s_bdev, blocksize, 0,
4303-
bdev_nr_sectors(sb->s_bdev)))
4304-
set_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags);
4302+
if (dax_dev) {
4303+
if (blocksize == PAGE_SIZE)
4304+
set_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags);
4305+
else
4306+
ext4_msg(sb, KERN_ERR, "unsupported blocksize for DAX\n");
4307+
}
43054308

43064309
if (sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) {
43074310
if (ext4_has_feature_inline_data(sb)) {

fs/xfs/xfs_super.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -331,28 +331,23 @@ xfs_set_inode_alloc(
331331
return xfs_is_inode32(mp) ? maxagi : agcount;
332332
}
333333

334-
static bool
335-
xfs_buftarg_is_dax(
336-
struct super_block *sb,
337-
struct xfs_buftarg *bt)
338-
{
339-
return dax_supported(bt->bt_daxdev, bt->bt_bdev, sb->s_blocksize, 0,
340-
bdev_nr_sectors(bt->bt_bdev));
341-
}
342-
343334
static int
344335
xfs_setup_dax_always(
345336
struct xfs_mount *mp)
346337
{
347-
struct super_block *sb = mp->m_super;
348-
349-
if (!xfs_buftarg_is_dax(sb, mp->m_ddev_targp) &&
350-
(!mp->m_rtdev_targp || !xfs_buftarg_is_dax(sb, mp->m_rtdev_targp))) {
338+
if (!mp->m_ddev_targp->bt_daxdev &&
339+
(!mp->m_rtdev_targp || !mp->m_rtdev_targp->bt_daxdev)) {
351340
xfs_alert(mp,
352341
"DAX unsupported by block device. Turning off DAX.");
353342
goto disable_dax;
354343
}
355344

345+
if (mp->m_super->s_blocksize != PAGE_SIZE) {
346+
xfs_alert(mp,
347+
"DAX not supported for blocksize. Turning off DAX.");
348+
goto disable_dax;
349+
}
350+
356351
if (xfs_has_reflink(mp)) {
357352
xfs_alert(mp, "DAX and reflink cannot be used together!");
358353
return -EINVAL;

include/linux/dax.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,6 @@ int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff);
111111
#if IS_ENABLED(CONFIG_FS_DAX)
112112
int dax_add_host(struct dax_device *dax_dev, struct gendisk *disk);
113113
void dax_remove_host(struct gendisk *disk);
114-
bool generic_fsdax_supported(struct dax_device *dax_dev,
115-
struct block_device *bdev, int blocksize, sector_t start,
116-
sector_t sectors);
117-
118-
bool dax_supported(struct dax_device *dax_dev, struct block_device *bdev,
119-
int blocksize, sector_t start, sector_t len);
120114

121115
static inline void fs_put_dax(struct dax_device *dax_dev)
122116
{
@@ -139,14 +133,6 @@ static inline int dax_add_host(struct dax_device *dax_dev, struct gendisk *disk)
139133
static inline void dax_remove_host(struct gendisk *disk)
140134
{
141135
}
142-
#define generic_fsdax_supported NULL
143-
144-
static inline bool dax_supported(struct dax_device *dax_dev,
145-
struct block_device *bdev, int blocksize, sector_t start,
146-
sector_t len)
147-
{
148-
return false;
149-
}
150136

151137
static inline void fs_put_dax(struct dax_device *dax_dev)
152138
{

0 commit comments

Comments
 (0)