Skip to content

Commit d9e5d92

Browse files
amir73ilbrauner
authored andcommitted
fs: fix build error with CONFIG_EXPORTFS=m or not defined
Many of the filesystems that call the generic exportfs helpers do not select the EXPORTFS config. Move generic_encode_ino32_fh() to libfs.c, same as generic_fh_to_*() to avoid having to fix all those config dependencies. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202310262151.renqMvme-lkp@intel.com/ Fixes: dfaf653 ("exportfs: make ->encode_fh() a mandatory method for NFS export") Suggested-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Amir Goldstein <amir73il@gmail.com> Link: https://lore.kernel.org/r/20231026204540.143217-1-amir73il@gmail.com Tested-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent ceb3388 commit d9e5d92

File tree

3 files changed

+43
-48
lines changed

3 files changed

+43
-48
lines changed

fs/exportfs/expfs.c

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -342,47 +342,6 @@ static int get_name(const struct path *path, char *name, struct dentry *child)
342342
return error;
343343
}
344344

345-
/**
346-
* generic_encode_ino32_fh - generic export_operations->encode_fh function
347-
* @inode: the object to encode
348-
* @fh: where to store the file handle fragment
349-
* @max_len: maximum length to store there (in 4 byte units)
350-
* @parent: parent directory inode, if wanted
351-
*
352-
* This generic encode_fh function assumes that the 32 inode number
353-
* is suitable for locating an inode, and that the generation number
354-
* can be used to check that it is still valid. It places them in the
355-
* filehandle fragment where export_decode_fh expects to find them.
356-
*/
357-
int generic_encode_ino32_fh(struct inode *inode, __u32 *fh, int *max_len,
358-
struct inode *parent)
359-
{
360-
struct fid *fid = (void *)fh;
361-
int len = *max_len;
362-
int type = FILEID_INO32_GEN;
363-
364-
if (parent && (len < 4)) {
365-
*max_len = 4;
366-
return FILEID_INVALID;
367-
} else if (len < 2) {
368-
*max_len = 2;
369-
return FILEID_INVALID;
370-
}
371-
372-
len = 2;
373-
fid->i32.ino = inode->i_ino;
374-
fid->i32.gen = inode->i_generation;
375-
if (parent) {
376-
fid->i32.parent_ino = parent->i_ino;
377-
fid->i32.parent_gen = parent->i_generation;
378-
len = 4;
379-
type = FILEID_INO32_GEN_PARENT;
380-
}
381-
*max_len = len;
382-
return type;
383-
}
384-
EXPORT_SYMBOL_GPL(generic_encode_ino32_fh);
385-
386345
#define FILEID_INO64_GEN_LEN 3
387346

388347
/**

fs/libfs.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,47 @@ ssize_t simple_attr_write_signed(struct file *file, const char __user *buf,
13101310
}
13111311
EXPORT_SYMBOL_GPL(simple_attr_write_signed);
13121312

1313+
/**
1314+
* generic_encode_ino32_fh - generic export_operations->encode_fh function
1315+
* @inode: the object to encode
1316+
* @fh: where to store the file handle fragment
1317+
* @max_len: maximum length to store there (in 4 byte units)
1318+
* @parent: parent directory inode, if wanted
1319+
*
1320+
* This generic encode_fh function assumes that the 32 inode number
1321+
* is suitable for locating an inode, and that the generation number
1322+
* can be used to check that it is still valid. It places them in the
1323+
* filehandle fragment where export_decode_fh expects to find them.
1324+
*/
1325+
int generic_encode_ino32_fh(struct inode *inode, __u32 *fh, int *max_len,
1326+
struct inode *parent)
1327+
{
1328+
struct fid *fid = (void *)fh;
1329+
int len = *max_len;
1330+
int type = FILEID_INO32_GEN;
1331+
1332+
if (parent && (len < 4)) {
1333+
*max_len = 4;
1334+
return FILEID_INVALID;
1335+
} else if (len < 2) {
1336+
*max_len = 2;
1337+
return FILEID_INVALID;
1338+
}
1339+
1340+
len = 2;
1341+
fid->i32.ino = inode->i_ino;
1342+
fid->i32.gen = inode->i_generation;
1343+
if (parent) {
1344+
fid->i32.parent_ino = parent->i_ino;
1345+
fid->i32.parent_gen = parent->i_generation;
1346+
len = 4;
1347+
type = FILEID_INO32_GEN_PARENT;
1348+
}
1349+
*max_len = len;
1350+
return type;
1351+
}
1352+
EXPORT_SYMBOL_GPL(generic_encode_ino32_fh);
1353+
13131354
/**
13141355
* generic_fh_to_dentry - generic helper for the fh_to_dentry export operation
13151356
* @sb: filesystem to do the file handle conversion on

include/linux/exportfs.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,17 +294,12 @@ extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,
294294
/*
295295
* Generic helpers for filesystems.
296296
*/
297-
#ifdef CONFIG_EXPORTFS
298297
int generic_encode_ino32_fh(struct inode *inode, __u32 *fh, int *max_len,
299298
struct inode *parent);
300-
#else
301-
#define generic_encode_ino32_fh NULL
302-
#endif
303-
304-
extern struct dentry *generic_fh_to_dentry(struct super_block *sb,
299+
struct dentry *generic_fh_to_dentry(struct super_block *sb,
305300
struct fid *fid, int fh_len, int fh_type,
306301
struct inode *(*get_inode) (struct super_block *sb, u64 ino, u32 gen));
307-
extern struct dentry *generic_fh_to_parent(struct super_block *sb,
302+
struct dentry *generic_fh_to_parent(struct super_block *sb,
308303
struct fid *fid, int fh_len, int fh_type,
309304
struct inode *(*get_inode) (struct super_block *sb, u64 ino, u32 gen));
310305

0 commit comments

Comments
 (0)