* [PATCH v3 3/5] fat (exportfs): rebuild inode if ilookup() fails
@ 2012-09-16 12:22 Namjae Jeon
2012-09-22 11:41 ` OGAWA Hirofumi
0 siblings, 1 reply; 3+ messages in thread
From: Namjae Jeon @ 2012-09-16 12:22 UTC (permalink / raw)
To: hirofumi, akpm
Cc: bfields, viro, linux-kernel, Namjae Jeon, Namjae Jeon,
Ravishankar N, Amit Sahrawat
From: Namjae Jeon <namjae.jeon@samsung.com>
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.
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>
---
fs/fat/nfs.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/fs/fat/nfs.c b/fs/fat/nfs.c
index ef4b5fa..3cf5412 100644
--- a/fs/fat/nfs.c
+++ b/fs/fat/nfs.c
@@ -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;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3 3/5] fat (exportfs): rebuild inode if ilookup() fails
2012-09-16 12:22 [PATCH v3 3/5] fat (exportfs): rebuild inode if ilookup() fails Namjae Jeon
@ 2012-09-22 11:41 ` OGAWA Hirofumi
2012-09-24 4:13 ` Namjae Jeon
0 siblings, 1 reply; 3+ messages in thread
From: OGAWA Hirofumi @ 2012-09-22 11:41 UTC (permalink / raw)
To: Namjae Jeon
Cc: akpm, bfields, viro, linux-kernel, Namjae Jeon, Ravishankar N,
Amit Sahrawat
Namjae Jeon <linkinjeon@gmail.com> writes:
> + 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)
IS_FREE() would be better.
> +
> + 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.
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3 3/5] fat (exportfs): rebuild inode if ilookup() fails
2012-09-22 11:41 ` OGAWA Hirofumi
@ 2012-09-24 4:13 ` Namjae Jeon
0 siblings, 0 replies; 3+ messages in thread
From: Namjae Jeon @ 2012-09-24 4:13 UTC (permalink / raw)
To: OGAWA Hirofumi
Cc: akpm, bfields, viro, linux-kernel, Namjae Jeon, Ravishankar N,
Amit Sahrawat
2012/9/22, OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>:
> Namjae Jeon <linkinjeon@gmail.com> writes:
>
>> + 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)
>
> IS_FREE() would be better.
Okay~ I will change.
>
>> +
>> + 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.
Okay, I will change.
Thanks.
> --
> OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-09-24 4:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-16 12:22 [PATCH v3 3/5] fat (exportfs): rebuild inode if ilookup() fails Namjae Jeon
2012-09-22 11:41 ` OGAWA Hirofumi
2012-09-24 4:13 ` Namjae Jeon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).