fat (exportfs): rebuild directory-inode if fat_dget()
Subsystems (2)
PATCH v7 6/7 fat (exportfs): rebuild directory-inode if fat_dget()
From: Namjae Jeon <[email protected]>
This patch enables rebuilding of directory inodes which are not present in the cache.This is done by traversing the disk clusters to find the directory entry of the parent directory and using its i_pos to build the inode.
The traversal is done by fat_scan_logstart() which is similar to fat_scan() but matches i_pos values instead of names.fat_scan_logstart() needs an inode parameter to work, for which a dummy inode is created by it's caller fat_rebuild_parent(). This dummy inode is destroyed after the traversal completes.
All this is done only if the nostale_ro nfs mount option is specified.
Signed-off-by Namjae Jeon <[email protected]>
Signed-off-by Ravishankar N <[email protected]>
Signed-off-by Amit Sahrawat <[email protected]>
--- fs/fat/dir.c | 23 +++++++++++++++++++++++ fs/fat/fat.h | 3 +++ fs/fat/inode.c | 2 +- fs/fat/nfs.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 78 insertions(+), 2 deletions(-)
fs/fat/dir.c +23 -0
@@ -964,6 +964,29 @@ int fat_scan(struct inode *dir, const unsigned char *name, }EXPORT_SYMBOL_GPL (fat_scan); +/* +* Scans a directory for a given logstart. +* Returns an error code or zero. +*/ +int fat_scan_logstart (struct inode *dir,int i_logstart, +struct fat_slot_info *sinfo) +{ +struct super_block *sb = dir->i_sb; + + sinfo->slot_off =0 ; + sinfo->bh =NULL ; +while (fat_get_short_entry (dir, &sinfo->slot_off, &sinfo->bh, + &sinfo->de) >=0 ) { +if (fat_get_start (MSDOS_SB (sb), sinfo->de) == i_logstart) { + sinfo->slot_off -=sizeof (*sinfo->de); + sinfo->nr_slots =1 ; + sinfo->i_pos =fat_make_i_pos (sb, sinfo->bh, sinfo->de); +return 0 ; + } + } +return -ENOENT ; +} +static int __fat_remove_entries (struct inode *dir,loff_t pos,int nr_slots) {struct super_block *sb = dir->i_sb;
fs/fat/fat.h +3 -0
@@ -296,6 +296,8 @@ extern int fat_dir_empty(struct inode *dir);extern int fat_subdirs (struct inode *dir);extern int fat_scan (struct inode *dir,const unsigned char *name,struct fat_slot_info *sinfo); +extern int fat_scan_logstart (struct inode *dir,int i_logstart, +struct fat_slot_info *sinfo);extern int fat_get_dotdot_entry (struct inode *dir,struct buffer_head **bh,struct msdos_dir_entry **de);extern int fat_alloc_new_dir (struct inode *dir,struct timespec *ts);
@@ -373,6 +375,7 @@ extern struct inode *fat_build_inode(struct super_block *sb,extern int fat_sync_inode (struct inode *inode);extern int fat_fill_super (struct super_block *sb,void *data,int silent,int isvfat,void (*setup)(struct super_block *)); +extern int fat_fill_inode (struct inode *inode,struct msdos_dir_entry *de);extern int fat_flush_inodes (struct super_block *sb,struct inode *i1,struct inode *i2);
fs/fat/inode.c +1 -1
@@ -385,7 +385,7 @@ static int fat_calc_dir_size(struct inode *inode) }/* doesn't deal with root inode */ -static int fat_fill_inode (struct inode *inode,struct msdos_dir_entry *de) +int fat_fill_inode (struct inode *inode,struct msdos_dir_entry *de) {struct msdos_sb_info *sbi =MSDOS_SB (inode->i_sb);int error;
fs/fat/nfs.c +51 -1
67 lines not on this page · raw message
Signature · 1 line
1.7.9.5