aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fat/nfs.c
diff options
context:
space:
mode:
authorNamjae Jeon <namjae.jeon@samsung.com>2013-04-29 19:21:14 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 21:28:41 -0400
commitf1e6fb0ab451dae8523fbb8c119a653b2730e938 (patch)
treebf966c2863b2523081fb69f619b7910efd28dc6f /fs/fat/nfs.c
parent8fceb4e0171f6bf64db756c65b2ce5f15aed8b4d (diff)
fat (exportfs): rebuild directory-inode if fat_dget()
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 <namjae.jeon@samsung.com> Signed-off-by: Ravishankar N <ravi.n1@samsung.com> Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com> Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/fat/nfs.c')
-rw-r--r--fs/fat/nfs.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/fs/fat/nfs.c b/fs/fat/nfs.c
index 0748196889b2..93e14933dcb6 100644
--- a/fs/fat/nfs.c
+++ b/fs/fat/nfs.c
@@ -216,6 +216,53 @@ static struct dentry *fat_fh_to_parent_nostale(struct super_block *sb,
216} 216}
217 217
218/* 218/*
219 * Rebuild the parent for a directory that is not connected
220 * to the filesystem root
221 */
222static
223struct inode *fat_rebuild_parent(struct super_block *sb, int parent_logstart)
224{
225 int search_clus, clus_to_match;
226 struct msdos_dir_entry *de;
227 struct inode *parent = NULL;
228 struct inode *dummy_grand_parent = NULL;
229 struct fat_slot_info sinfo;
230 struct msdos_sb_info *sbi = MSDOS_SB(sb);
231 sector_t blknr = fat_clus_to_blknr(sbi, parent_logstart);
232 struct buffer_head *parent_bh = sb_bread(sb, blknr);
233 if (!parent_bh) {
234 fat_msg(sb, KERN_ERR,
235 "unable to read cluster of parent directory");
236 return NULL;
237 }
238
239 de = (struct msdos_dir_entry *) parent_bh->b_data;
240 clus_to_match = fat_get_start(sbi, &de[0]);
241 search_clus = fat_get_start(sbi, &de[1]);
242
243 dummy_grand_parent = fat_dget(sb, search_clus);
244 if (!dummy_grand_parent) {
245 dummy_grand_parent = new_inode(sb);
246 if (!dummy_grand_parent) {
247 brelse(parent_bh);
248 return parent;
249 }
250
251 dummy_grand_parent->i_ino = iunique(sb, MSDOS_ROOT_INO);
252 fat_fill_inode(dummy_grand_parent, &de[1]);
253 MSDOS_I(dummy_grand_parent)->i_pos = -1;
254 }
255
256 if (!fat_scan_logstart(dummy_grand_parent, clus_to_match, &sinfo))
257 parent = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
258
259 brelse(parent_bh);
260 iput(dummy_grand_parent);
261
262 return parent;
263}
264
265/*
219 * Find the parent for a directory that is not currently connected to 266 * Find the parent for a directory that is not currently connected to
220 * the filesystem root. 267 * the filesystem root.
221 * 268 *
@@ -227,10 +274,13 @@ static struct dentry *fat_get_parent(struct dentry *child_dir)
227 struct buffer_head *bh = NULL; 274 struct buffer_head *bh = NULL;
228 struct msdos_dir_entry *de; 275 struct msdos_dir_entry *de;
229 struct inode *parent_inode = NULL; 276 struct inode *parent_inode = NULL;
277 struct msdos_sb_info *sbi = MSDOS_SB(sb);
230 278
231 if (!fat_get_dotdot_entry(child_dir->d_inode, &bh, &de)) { 279 if (!fat_get_dotdot_entry(child_dir->d_inode, &bh, &de)) {
232 int parent_logstart = fat_get_start(MSDOS_SB(sb), de); 280 int parent_logstart = fat_get_start(sbi, de);
233 parent_inode = fat_dget(sb, parent_logstart); 281 parent_inode = fat_dget(sb, parent_logstart);
282 if (!parent_inode && sbi->options.nfs == FAT_NFS_NOSTALE_RO)
283 parent_inode = fat_rebuild_parent(sb, parent_logstart);
234 } 284 }
235 brelse(bh); 285 brelse(bh);
236 286