fat (exportfs): rebuild inode if ilookup() fails
PATCH v3 3/5 fat (exportfs): rebuild inode if ilookup() fails
From: Namjae Jeon <[email protected]>
Since the previous patch in this patch-set uses i_pos as the inode number, we can use it to find the directory entry of the inode and subsequently rebuild the inode if the cache lookups fail.
Since this involves accessing the FAT media,it is better to do this only if the 'nfs' mount option is enabled with limited_stable.
--- fs/fat/nfs.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
fs/fat/nfs.c +25 -0
@@ -52,6 +52,31 @@ static struct inode *fat_nfs_get_inode(struct super_block *sb,iput (inode); inode =NULL ; } +if (inode ==NULL &&MSDOS_SB (sb)->options.nfs ==FAT_NFS_LIMITED ) { +struct buffer_head *bh =NULL ; +struct msdos_dir_entry *de ; +loff_t i_pos = (loff_t )ino; +int bits =MSDOS_SB (sb)->dir_per_block_bits; +loff_t blocknr = i_pos >> bits; + bh =sb_bread (sb, blocknr); +if (!bh) { +fat_msg (sb,KERN_ERR , +"unable to read block(%llu) for building NFS inode" , + (llu )blocknr); +return inode; + } + de = (struct msdos_dir_entry *)bh->b_data; +/* If a file is deleted on server and client is not updated +* yet, we must not build the inode upon a lookup call. +*/ +if (de[i_pos&((1 <<bits)-1 )].name[0 ] ==DELETED_FLAG ) + + inode =NULL ; +else + inode =fat_build_inode (sb, &de[i_pos&((1 <<bits)-1 )], + i_pos); +brelse (bh); + }return inode; }
Signature · 1 line
1.7.9.5
OGAWA Hirofumi
maintainerQuoted 8 lines · Namjae Jeon
fs/fat/nfs.c +8
-0+if (inode ==NULL &&MSDOS_SB (sb)->options.nfs ==FAT_NFS_LIMITED ) { +struct buffer_head *bh =NULL ; +struct msdos_dir_entry *de ; +loff_t i_pos = (loff_t )ino; +int bits =MSDOS_SB (sb)->dir_per_block_bits; +loff_t blocknr = i_pos >> bits; + bh =sb_bread (sb, blocknr); +if (!bh) {
fs/fat/nfs.c static struct inode *fat_nfs_get_inode(struct super_block *sb, · line 72
Quoted 10 lines
fs/fat/nfs.c +10
-0+fat_msg (sb,KERN_ERR , +"unable to read block(%llu) for building NFS inode" , + (llu )blocknr); +return inode; + } + de = (struct msdos_dir_entry *)bh->b_data; +/* If a file is deleted on server and client is not updated +* yet, we must not build the inode upon a lookup call. +*/ +if (de[i_pos&((1 <<bits)-1 )].name[0 ] ==DELETED_FLAG )
IS_FREE() would be better.
fs/fat/nfs.c static struct inode *fat_nfs_get_inode(struct super_block *sb, · line 82
Quoted 10 lines
fs/fat/nfs.c +7
-0+ + inode =NULL ; + else + inode =fat_build_inode (sb, &de[i_pos&((1 <<bits)-1 )], + i_pos); +brelse (bh); + }return inode; }
1 << bits == sbi->dir_per_block
It would be better to add helper to decode i_pos to blocknr and offset. And it should be shared on fat_write_inode and this.
Signature · 1 line
OGAWA Hirofumi <[email protected]>
2012/9/22, OGAWA Hirofumi <[email protected]>:
Quoted 14 lines
Quoted 12 lines · Namjae Jeon
fs/fat/nfs.c +12
-0+if (inode ==NULL &&MSDOS_SB (sb)->options.nfs ==FAT_NFS_LIMITED ) { +struct buffer_head *bh =NULL ; +struct msdos_dir_entry *de ; +loff_t i_pos = (loff_t )ino; +int bits =MSDOS_SB (sb)->dir_per_block_bits; +loff_t blocknr = i_pos >> bits; + bh =sb_bread (sb, blocknr); +if (!bh) { +fat_msg (sb,KERN_ERR , +"unable to read block(%llu) for building NFS inode" , + (llu )blocknr); +return inode;
Quoted 8 lines
fs/fat/nfs.c static struct inode *fat_nfs_get_inode(struct super_block *sb, · line 72
Quoted 6 lines
fs/fat/nfs.c +6
-0+ } + de = (struct msdos_dir_entry *)bh->b_data; +/* If a file is deleted on server and client is not updated +* yet, we must not build the inode upon a lookup call. +*/ +if (de[i_pos&((1 <<bits)-1 )].name[0 ] ==DELETED_FLAG )
IS_FREE()would be better.
Okay~ I will change.
Quoted 9 lines
Quoted 9 lines
fs/fat/nfs.c +7
-0+ + inode =NULL ; + else + inode =fat_build_inode (sb, &de[i_pos&((1 <<bits)-1 )], + i_pos); +brelse (bh); + }
Quoted 7 lines
Quoted 2 lines
return inode;
}1 << bits ==
sbi->dir_per_blockIt would be better to add helper to decode
i_posto blocknr and offset. And it should be shared onfat_write_inodeand this.
Okay, I will change.
Thanks.
Quoted 3 lines
--
OGAWA Hirofumi <[email protected]>