Skip to content

Commit f5705aa

Browse files
committed
dax, xfs, ext4: compile out iomap-dax paths in the FS_DAX=n case
Tetsuo reports: fs/built-in.o: In function `xfs_file_iomap_end': xfs_iomap.c:(.text+0xe0ef9): undefined reference to `put_dax' fs/built-in.o: In function `xfs_file_iomap_begin': xfs_iomap.c:(.text+0xe1a7f): undefined reference to `dax_get_by_host' make: *** [vmlinux] Error 1 $ grep DAX .config CONFIG_DAX=m # CONFIG_DEV_DAX is not set # CONFIG_FS_DAX is not set When FS_DAX=n we can/must throw away the dax code in filesystems. Implement 'fs_' versions of dax_get_by_host() and put_dax() that are nops in the FS_DAX=n case. Cc: <linux-xfs@vger.kernel.org> Cc: <linux-ext4@vger.kernel.org> Cc: Jan Kara <jack@suse.com> Cc: "Theodore Ts'o" <tytso@mit.edu> Cc: "Darrick J. Wong" <darrick.wong@oracle.com> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Tested-by: Tony Luck <tony.luck@intel.com> Fixes: ef51042 ("block, dax: move 'select DAX' from BLOCK to FS_DAX") Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 9d10908 commit f5705aa

4 files changed

Lines changed: 33 additions & 13 deletions

File tree

‎fs/ext2/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
817817
iomap->bdev = bdev;
818818
iomap->offset = (u64)first_block << blkbits;
819819
if (blk_queue_dax(bdev->bd_queue))
820-
iomap->dax_dev = dax_get_by_host(bdev->bd_disk->disk_name);
820+
iomap->dax_dev = fs_dax_get_by_host(bdev->bd_disk->disk_name);
821821
else
822822
iomap->dax_dev = NULL;
823823

@@ -841,7 +841,7 @@ static int
841841
ext2_iomap_end(struct inode *inode, loff_t offset, loff_t length,
842842
ssize_t written, unsigned flags, struct iomap *iomap)
843843
{
844-
put_dax(iomap->dax_dev);
844+
fs_put_dax(iomap->dax_dev);
845845
if (iomap->type == IOMAP_MAPPED &&
846846
written < length &&
847847
(flags & IOMAP_WRITE))

‎fs/ext4/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3412,7 +3412,7 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
34123412
bdev = inode->i_sb->s_bdev;
34133413
iomap->bdev = bdev;
34143414
if (blk_queue_dax(bdev->bd_queue))
3415-
iomap->dax_dev = dax_get_by_host(bdev->bd_disk->disk_name);
3415+
iomap->dax_dev = fs_dax_get_by_host(bdev->bd_disk->disk_name);
34163416
else
34173417
iomap->dax_dev = NULL;
34183418
iomap->offset = first_block << blkbits;
@@ -3447,7 +3447,7 @@ static int ext4_iomap_end(struct inode *inode, loff_t offset, loff_t length,
34473447
int blkbits = inode->i_blkbits;
34483448
bool truncate = false;
34493449

3450-
put_dax(iomap->dax_dev);
3450+
fs_put_dax(iomap->dax_dev);
34513451
if (!(flags & IOMAP_WRITE) || (flags & IOMAP_FAULT))
34523452
return 0;
34533453

‎fs/xfs/xfs_iomap.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ xfs_file_iomap_begin(
10681068
/* optionally associate a dax device with the iomap bdev */
10691069
bdev = iomap->bdev;
10701070
if (blk_queue_dax(bdev->bd_queue))
1071-
iomap->dax_dev = dax_get_by_host(bdev->bd_disk->disk_name);
1071+
iomap->dax_dev = fs_dax_get_by_host(bdev->bd_disk->disk_name);
10721072
else
10731073
iomap->dax_dev = NULL;
10741074

@@ -1149,7 +1149,7 @@ xfs_file_iomap_end(
11491149
unsigned flags,
11501150
struct iomap *iomap)
11511151
{
1152-
put_dax(iomap->dax_dev);
1152+
fs_put_dax(iomap->dax_dev);
11531153
if ((flags & IOMAP_WRITE) && iomap->type == IOMAP_DELALLOC)
11541154
return xfs_file_iomap_end_delalloc(XFS_I(inode), offset,
11551155
length, written, iomap);

‎include/linux/dax.h‎

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,50 @@ struct dax_operations {
1818
void **, pfn_t *);
1919
};
2020

21+
#if IS_ENABLED(CONFIG_DAX)
22+
struct dax_device *dax_get_by_host(const char *host);
23+
void put_dax(struct dax_device *dax_dev);
24+
#else
25+
static inline struct dax_device *dax_get_by_host(const char *host)
26+
{
27+
return NULL;
28+
}
29+
30+
static inline void put_dax(struct dax_device *dax_dev)
31+
{
32+
}
33+
#endif
34+
2135
int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff);
2236
#if IS_ENABLED(CONFIG_FS_DAX)
2337
int __bdev_dax_supported(struct super_block *sb, int blocksize);
2438
static inline int bdev_dax_supported(struct super_block *sb, int blocksize)
2539
{
2640
return __bdev_dax_supported(sb, blocksize);
2741
}
42+
43+
static inline struct dax_device *fs_dax_get_by_host(const char *host)
44+
{
45+
return dax_get_by_host(host);
46+
}
47+
48+
static inline void fs_put_dax(struct dax_device *dax_dev)
49+
{
50+
put_dax(dax_dev);
51+
}
52+
2853
#else
2954
static inline int bdev_dax_supported(struct super_block *sb, int blocksize)
3055
{
3156
return -EOPNOTSUPP;
3257
}
33-
#endif
3458

35-
#if IS_ENABLED(CONFIG_DAX)
36-
struct dax_device *dax_get_by_host(const char *host);
37-
void put_dax(struct dax_device *dax_dev);
38-
#else
39-
static inline struct dax_device *dax_get_by_host(const char *host)
59+
static inline struct dax_device *fs_dax_get_by_host(const char *host)
4060
{
4161
return NULL;
4262
}
4363

44-
static inline void put_dax(struct dax_device *dax_dev)
64+
static inline void fs_put_dax(struct dax_device *dax_dev)
4565
{
4666
}
4767
#endif

0 commit comments

Comments
 (0)