From a569425512253992cc64ebf8b6d00a62f986db3e Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 17 Jul 2007 04:04:28 -0700 Subject: [PATCH] knfsd: exportfs: add exportfs.h header currently the export_operation structure and helpers related to it are in fs.h. fs.h is already far too large and there are very few places needing the export bits, so split them off into a separate header. [akpm@linux-foundation.org: fix cifs build] Signed-off-by: Christoph Hellwig Signed-off-by: Neil Brown Cc: Steven French Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/cifs/export.c | 1 + fs/efs/super.c | 1 + fs/exportfs/expfs.c | 1 + fs/ext2/super.c | 1 + fs/ext3/super.c | 1 + fs/ext4/super.c | 1 + fs/fat/inode.c | 1 + fs/gfs2/ops_export.c | 1 + fs/isofs/isofs.h | 1 + fs/jfs/super.c | 1 + fs/nfsd/export.c | 1 + fs/nfsd/nfsfh.c | 1 + fs/ntfs/namei.c | 1 + fs/ocfs2/export.h | 2 + fs/reiserfs/inode.c | 1 + fs/reiserfs/super.c | 1 + fs/xfs/linux-2.6/xfs_super.h | 2 + include/linux/exportfs.h | 119 +++++++++++++++++++++++++++++++++++ include/linux/fs.h | 114 +-------------------------------- mm/shmem.c | 1 + 20 files changed, 140 insertions(+), 113 deletions(-) create mode 100644 include/linux/exportfs.h diff --git a/fs/cifs/export.c b/fs/cifs/export.c index 1d716392c3..96df1d51fd 100644 --- a/fs/cifs/export.c +++ b/fs/cifs/export.c @@ -29,6 +29,7 @@ */ #include +#include #ifdef CONFIG_CIFS_EXPERIMENTAL diff --git a/fs/efs/super.c b/fs/efs/super.c index e0a6839e68..67338d622f 100644 --- a/fs/efs/super.c +++ b/fs/efs/super.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c index e98f6cd720..16287af348 100644 --- a/fs/exportfs/expfs.c +++ b/fs/exportfs/expfs.c @@ -1,4 +1,5 @@ +#include #include #include #include diff --git a/fs/ext2/super.c b/fs/ext2/super.c index b2efd9083b..3eefa97fe2 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 51d1c456cd..4f84dc8662 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/fs/ext4/super.c b/fs/ext4/super.c index d0d8c76c7e..b806e689c4 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/fs/fat/inode.c b/fs/fat/inode.c index cfaf5877d9..0a7ddb39a5 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c index 99ea5659bc..b8312edee0 100644 --- a/fs/gfs2/ops_export.c +++ b/fs/gfs2/ops_export.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h index efe2872cd4..a07e67b1ea 100644 --- a/fs/isofs/isofs.h +++ b/fs/isofs/isofs.h @@ -1,5 +1,6 @@ #include #include +#include #include #include diff --git a/fs/jfs/super.c b/fs/jfs/super.c index 20e4ac1c79..49b652bd96 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 79bd03b8bb..c518421a93 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index 6ca2d24fc2..0108d3ec1c 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c index bff01a5467..e93c6142b2 100644 --- a/fs/ntfs/namei.c +++ b/fs/ntfs/namei.c @@ -21,6 +21,7 @@ */ #include +#include #include #include "attrib.h" diff --git a/fs/ocfs2/export.h b/fs/ocfs2/export.h index 5b77ee7866..e08bed9e45 100644 --- a/fs/ocfs2/export.h +++ b/fs/ocfs2/export.h @@ -26,6 +26,8 @@ #ifndef OCFS2_EXPORT_H #define OCFS2_EXPORT_H +#include + extern struct export_operations ocfs2_export_ops; #endif /* OCFS2_EXPORT_H */ diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index 1272d11399..ddde489f1c 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index b4ac911920..5a93cfe1a0 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/fs/xfs/linux-2.6/xfs_super.h b/fs/xfs/linux-2.6/xfs_super.h index 33dd1ca132..201cc3273c 100644 --- a/fs/xfs/linux-2.6/xfs_super.h +++ b/fs/xfs/linux-2.6/xfs_super.h @@ -18,6 +18,8 @@ #ifndef __XFS_SUPER_H__ #define __XFS_SUPER_H__ +#include + #ifdef CONFIG_XFS_DMAPI # define vfs_insertdmapi(vfs) vfs_insertops(vfsp, &xfs_dmops) # define vfs_initdmapi() dmapi_init() diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h new file mode 100644 index 0000000000..fdc306fbba --- /dev/null +++ b/include/linux/exportfs.h @@ -0,0 +1,119 @@ +#ifndef LINUX_EXPORTFS_H +#define LINUX_EXPORTFS_H 1 + +#include + +struct dentry; +struct super_block; + + +/** + * struct export_operations - for nfsd to communicate with file systems + * @decode_fh: decode a file handle fragment and return a &struct dentry + * @encode_fh: encode a file handle fragment from a dentry + * @get_name: find the name for a given inode in a given directory + * @get_parent: find the parent of a given directory + * @get_dentry: find a dentry for the inode given a file handle sub-fragment + * @find_exported_dentry: + * set by the exporting module to a standard helper function. + * + * Description: + * The export_operations structure provides a means for nfsd to communicate + * with a particular exported file system - particularly enabling nfsd and + * the filesystem to co-operate when dealing with file handles. + * + * export_operations contains two basic operation for dealing with file + * handles, decode_fh() and encode_fh(), and allows for some other + * operations to be defined which standard helper routines use to get + * specific information from the filesystem. + * + * nfsd encodes information use to determine which filesystem a filehandle + * applies to in the initial part of the file handle. The remainder, termed + * a file handle fragment, is controlled completely by the filesystem. The + * standard helper routines assume that this fragment will contain one or + * two sub-fragments, one which identifies the file, and one which may be + * used to identify the (a) directory containing the file. + * + * In some situations, nfsd needs to get a dentry which is connected into a + * specific part of the file tree. To allow for this, it passes the + * function acceptable() together with a @context which can be used to see + * if the dentry is acceptable. As there can be multiple dentrys for a + * given file, the filesystem should check each one for acceptability before + * looking for the next. As soon as an acceptable one is found, it should + * be returned. + * + * decode_fh: + * @decode_fh is given a &struct super_block (@sb), a file handle fragment + * (@fh, @fh_len) and an acceptability testing function (@acceptable, + * @context). It should return a &struct dentry which refers to the same + * file that the file handle fragment refers to, and which passes the + * acceptability test. If it cannot, it should return a %NULL pointer if + * the file was found but no acceptable &dentries were available, or a + * %ERR_PTR error code indicating why it couldn't be found (e.g. %ENOENT or + * %ENOMEM). + * + * encode_fh: + * @encode_fh should store in the file handle fragment @fh (using at most + * @max_len bytes) information that can be used by @decode_fh to recover the + * file refered to by the &struct dentry @de. If the @connectable flag is + * set, the encode_fh() should store sufficient information so that a good + * attempt can be made to find not only the file but also it's place in the + * filesystem. This typically means storing a reference to de->d_parent in + * the filehandle fragment. encode_fh() should return the number of bytes + * stored or a negative error code such as %-ENOSPC + * + * get_name: + * @get_name should find a name for the given @child in the given @parent + * directory. The name should be stored in the @name (with the + * understanding that it is already pointing to a a %NAME_MAX+1 sized + * buffer. get_name() should return %0 on success, a negative error code + * or error. @get_name will be called without @parent->i_mutex held. + * + * get_parent: + * @get_parent should find the parent directory for the given @child which + * is also a directory. In the event that it cannot be found, or storage + * space cannot be allocated, a %ERR_PTR should be returned. + * + * get_dentry: + * Given a &super_block (@sb) and a pointer to a file-system specific inode + * identifier, possibly an inode number, (@inump) get_dentry() should find + * the identified inode and return a dentry for that inode. Any suitable + * dentry can be returned including, if necessary, a new dentry created with + * d_alloc_root. The caller can then find any other extant dentrys by + * following the d_alias links. If a new dentry was created using + * d_alloc_root, DCACHE_NFSD_DISCONNECTED should be set, and the dentry + * should be d_rehash()ed. + * + * If the inode cannot be found, either a %NULL pointer or an %ERR_PTR code + * can be returned. The @inump will be whatever was passed to + * nfsd_find_fh_dentry() in either the @obj or @parent parameters. + * + * Locking rules: + * get_parent is called with child->d_inode->i_mutex down + * get_name is not (which is possibly inconsistent) + */ + +struct export_operations { + struct dentry *(*decode_fh)(struct super_block *sb, __u32 *fh, + int fh_len, int fh_type, + int (*acceptable)(void *context, struct dentry *de), + void *context); + int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len, + int connectable); + int (*get_name)(struct dentry *parent, char *name, + struct dentry *child); + struct dentry * (*get_parent)(struct dentry *child); + struct dentry * (*get_dentry)(struct super_block *sb, void *inump); + + /* This is set by the exporting module to a standard helper */ + struct dentry * (*find_exported_dentry)( + struct super_block *sb, void *obj, void *parent, + int (*acceptable)(void *context, struct dentry *de), + void *context); +}; + +extern struct dentry *find_exported_dentry(struct super_block *sb, void *obj, + void *parent, int (*acceptable)(void *context, struct dentry *de), + void *context); + +#endif /* LINUX_EXPORTFS_H */ diff --git a/include/linux/fs.h b/include/linux/fs.h index aa74f7de9d..58ce336d4a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -289,6 +289,7 @@ extern int dir_notify_enable; #include #include +struct export_operations; struct hd_geometry; struct iovec; struct nameidata; @@ -1278,119 +1279,6 @@ static inline void file_accessed(struct file *file) int sync_inode(struct inode *inode, struct writeback_control *wbc); -/** - * struct export_operations - for nfsd to communicate with file systems - * @decode_fh: decode a file handle fragment and return a &struct dentry - * @encode_fh: encode a file handle fragment from a dentry - * @get_name: find the name for a given inode in a given directory - * @get_parent: find the parent of a given directory - * @get_dentry: find a dentry for the inode given a file handle sub-fragment - * @find_exported_dentry: - * set by the exporting module to a standard helper function. - * - * Description: - * The export_operations structure provides a means for nfsd to communicate - * with a particular exported file system - particularly enabling nfsd and - * the filesystem to co-operate when dealing with file handles. - * - * export_operations contains two basic operation for dealing with file - * handles, decode_fh() and encode_fh(), and allows for some other - * operations to be defined which standard helper routines use to get - * specific information from the filesystem. - * - * nfsd encodes information use to determine which filesystem a filehandle - * applies to in the initial part of the file handle. The remainder, termed - * a file handle fragment, is controlled completely by the filesystem. The - * standard helper routines assume that this fragment will contain one or - * two sub-fragments, one which identifies the file, and one which may be - * used to identify the (a) directory containing the file. - * - * In some situations, nfsd needs to get a dentry which is connected into a - * specific part of the file tree. To allow for this, it passes the - * function acceptable() together with a @context which can be used to see - * if the dentry is acceptable. As there can be multiple dentrys for a - * given file, the filesystem should check each one for acceptability before - * looking for the next. As soon as an acceptable one is found, it should - * be returned. - * - * decode_fh: - * @decode_fh is given a &struct super_block (@sb), a file handle fragment - * (@fh, @fh_len) and an acceptability testing function (@acceptable, - * @context). It should return a &struct dentry which refers to the same - * file that the file handle fragment refers to, and which passes the - * acceptability test. If it cannot, it should return a %NULL pointer if - * the file was found but no acceptable &dentries were available, or a - * %ERR_PTR error code indicating why it couldn't be found (e.g. %ENOENT or - * %ENOMEM). - * - * encode_fh: - * @encode_fh should store in the file handle fragment @fh (using at most - * @max_len bytes) information that can be used by @decode_fh to recover the - * file refered to by the &struct dentry @de. If the @connectable flag is - * set, the encode_fh() should store sufficient information so that a good - * attempt can be made to find not only the file but also it's place in the - * filesystem. This typically means storing a reference to de->d_parent in - * the filehandle fragment. encode_fh() should return the number of bytes - * stored or a negative error code such as %-ENOSPC - * - * get_name: - * @get_name should find a name for the given @child in the given @parent - * directory. The name should be stored in the @name (with the - * understanding that it is already pointing to a a %NAME_MAX+1 sized - * buffer. get_name() should return %0 on success, a negative error code - * or error. @get_name will be called without @parent->i_mutex held. - * - * get_parent: - * @get_parent should find the parent directory for the given @child which - * is also a directory. In the event that it cannot be found, or storage - * space cannot be allocated, a %ERR_PTR should be returned. - * - * get_dentry: - * Given a &super_block (@sb) and a pointer to a file-system specific inode - * identifier, possibly an inode number, (@inump) get_dentry() should find - * the identified inode and return a dentry for that inode. Any suitable - * dentry can be returned including, if necessary, a new dentry created with - * d_alloc_root. The caller can then find any other extant dentrys by - * following the d_alias links. If a new dentry was created using - * d_alloc_root, DCACHE_NFSD_DISCONNECTED should be set, and the dentry - * should be d_rehash()ed. - * - * If the inode cannot be found, either a %NULL pointer or an %ERR_PTR code - * can be returned. The @inump will be whatever was passed to - * nfsd_find_fh_dentry() in either the @obj or @parent parameters. - * - * Locking rules: - * get_parent is called with child->d_inode->i_mutex down - * get_name is not (which is possibly inconsistent) - */ - -struct export_operations { - struct dentry *(*decode_fh)(struct super_block *sb, __u32 *fh, int fh_len, int fh_type, - int (*acceptable)(void *context, struct dentry *de), - void *context); - int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len, - int connectable); - - /* the following are only called from the filesystem itself */ - int (*get_name)(struct dentry *parent, char *name, - struct dentry *child); - struct dentry * (*get_parent)(struct dentry *child); - struct dentry * (*get_dentry)(struct super_block *sb, void *inump); - - /* This is set by the exporting module to a standard helper */ - struct dentry * (*find_exported_dentry)( - struct super_block *sb, void *obj, void *parent, - int (*acceptable)(void *context, struct dentry *de), - void *context); - - -}; - -extern struct dentry * -find_exported_dentry(struct super_block *sb, void *obj, void *parent, - int (*acceptable)(void *context, struct dentry *de), - void *context); - struct file_system_type { const char *name; int fs_flags; diff --git a/mm/shmem.c b/mm/shmem.c index e49181d9d8..96fa79fb6a 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include -- 2.39.5