fat: restructure export_operations
Subsystems (3)
PATCH v7 4/7 fat: restructure export_operations
From: Namjae Jeon <[email protected]>
Define two nfs export_operation structures,one for 'stale_rw' mounts and the other for 'nostale_ro'. The latter uses i_pos as a basis for encoding and decoding file handles.
Also, assign i_pos to kstat->ino. The logic for rebuilding the inode is added in the subsequent patches.
Signed-off-by Namjae Jeon <[email protected]>
Signed-off-by Ravishankar N <[email protected]>
Signed-off-by Amit Sahrawat <[email protected]>
--- fs/fat/fat.h | 8 +-- fs/fat/file.c | 5 ++ fs/fat/inode.c | 13 ++--- fs/fat/nfs.c | 130 ++++++++++++++++++++++++++++++++++++++++++++-- include/linux/exportfs.h | 11 ++++ 5 files changed, 147 insertions(+), 20 deletions(-)
fs/fat/fat.h +2 -6
@@ -406,12 +406,8 @@ int fat_cache_init(void);void fat_cache_destroy (void );/* fat/nfs.c */ -struct fid ; -extern struct dentry *fat_fh_to_dentry (struct super_block *sb,struct fid *fid, -int fh_len,int fh_type); -extern struct dentry *fat_fh_to_parent (struct super_block *sb,struct fid *fid, -int fh_len,int fh_type); -extern struct dentry *fat_get_parent (struct dentry *child_dir); +extern const struct export_operations fat_export_ops; +extern const struct export_operations fat_export_ops_nostale;/* helper for printk */ typedef unsigned long long llu ;
fs/fat/file.c +5 -0
@@ -306,6 +306,11 @@ int fat_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)struct inode *inode = dentry->d_inode;generic_fillattr (inode, stat); stat->blksize =MSDOS_SB (inode->i_sb)->cluster_size; + +if (MSDOS_SB (inode->i_sb)->options.nfs ==FAT_NFS_NOSTALE_RO ) { +/* Use i_pos for ino. This is used as fileid of nfs. */ + stat->ino =fat_i_pos_read (MSDOS_SB (inode->i_sb), inode); + }return 0 ; }EXPORT_SYMBOL_GPL (fat_getattr);
fs/fat/inode.c +4 -9
@@ -18,7 +18,6 @@#include <linux/pagemap.h> #include <linux/mpage.h> #include <linux/buffer_head.h> -#include <linux/exportfs.h> #include <linux/mount.h> #include <linux/aio.h> #include <linux/vfs.h>
@@ -749,12 +748,6 @@ static const struct super_operations fat_sops = { .show_options = fat_show_options, }; -static const struct export_operations fat_export_ops = { - .fh_to_dentry = fat_fh_to_dentry, - .fh_to_parent = fat_fh_to_parent, - .get_parent = fat_get_parent, -}; -static int fat_show_options (struct seq_file *m,struct dentry *root) {struct msdos_sb_info *sbi =MSDOS_SB (root->d_sb);
@@ -1178,8 +1171,10 @@ out: opts->allow_utime = ~opts->fs_dmask & (S_IWGRP |S_IWOTH );if (opts->unicode_xlate) opts->utf8 =0 ; -if (opts->nfs ==FAT_NFS_NOSTALE_RO ) +if (opts->nfs ==FAT_NFS_NOSTALE_RO ) { sb->s_flags |=MS_RDONLY ; + sb->s_export_op = &fat_export_ops_nostale; + }return 0 ; }
@@ -1190,7 +1185,7 @@ static int fat_read_root(struct inode *inode)struct msdos_sb_info *sbi =MSDOS_SB (sb);int error; -MSDOS_I (inode)->i_pos =0 ; +MSDOS_I (inode)->i_pos =MSDOS_ROOT_INO ; inode->i_uid = sbi->options.fs_uid; inode->i_gid = sbi->options.fs_gid; inode->i_version++;
fs/fat/nfs.c +125 -5
177 lines not on this page · raw message
include/linux/exportfs.h +11 -0
@@ -85,6 +85,17 @@ enum fid_type {FILEID_NILFS_WITH_PARENT =0x62 ,/* +* 32 bit generation number, 40 bit i_pos. +*/ +FILEID_FAT_WITHOUT_PARENT =0x71 , + +/* +* 32 bit generation number, 40 bit i_pos, +* 32 bit parent generation number, 40 bit parent i_pos +*/ +FILEID_FAT_WITH_PARENT =0x72 , + +/* * Filesystems must not use 0xff file ID. */ FILEID_INVALID = 0xff,
Signature · 1 line
1.7.9.5