fat: allocate persistent inode numbers
PATCH v3 2/5 fat: allocate persistent inode numbers
From: Namjae Jeon <[email protected]>
All the files on a FAT partition have an on-disk directory entry. The location of these entries, i_pos, is unique and is constructed by the fat_make_i_pos() function.We can use this as the inode number making it persistent across remounts.
--- fs/fat/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/fat/inode.c +4 -1
@@ -458,7 +458,10 @@ struct inode *fat_build_inode(struct super_block *sb, inode =ERR_PTR (-ENOMEM ); goto out; } - inode->i_ino =iunique (sb,MSDOS_ROOT_INO ); +if (MSDOS_SB (sb)->options.nfs ==FAT_NFS_LIMITED ) + inode->i_ino = i_pos; +else + inode->i_ino =iunique (sb,MSDOS_ROOT_INO ); inode->i_version =1 ; err =fat_fill_inode (inode, de);if (err) {
Signature · 1 line
1.7.9.5
OGAWA Hirofumi
maintainerfs/fat/inode.c struct inode *fat_build_inode(struct super_block *sb, · line 467
Quoted 8 lines · Namjae Jeon
fs/fat/inode.c +4
-1- inode->i_ino =iunique (sb,MSDOS_ROOT_INO ); +if (MSDOS_SB (sb)->options.nfs ==FAT_NFS_LIMITED ) + inode->i_ino = i_pos; +else + inode->i_ino =iunique (sb,MSDOS_ROOT_INO ); inode->i_version =1 ; err =fat_fill_inode (inode, de);if (err) {
I think we don't need this. Because FH and ino is not necessary to have relation.
Can we re-introduce ->encode_fh() handler, and export i_pos again? With this, I think we can get i_pos correctly. Otherwise, ino may not contain all bits of i_pos.
Signature · 1 line
OGAWA Hirofumi <[email protected]>
2012/9/22, OGAWA Hirofumi <[email protected]>:
Quoted 14 lines
fs/fat/inode.c struct inode *fat_build_inode(struct super_block *sb, · line 467
Quoted 8 lines · Namjae Jeon
fs/fat/inode.c +4
-1- inode->i_ino =iunique (sb,MSDOS_ROOT_INO ); +if (MSDOS_SB (sb)->options.nfs ==FAT_NFS_LIMITED ) + inode->i_ino = i_pos; +else + inode->i_ino =iunique (sb,MSDOS_ROOT_INO ); inode->i_version =1 ; err =fat_fill_inode (inode, de);if (err) {I think we don't need this. Because FH and ino is not necessary to have relation.
Quoted 3 lines
Can we re-introduce ->encode_fh() handler, and export
i_posagain? With this, I think we can geti_poscorrectly. Otherwise, ino may not contain all bits ofi_pos.
I already tried to fix this issue using encode_fh without stable ino before. But I reached conclusion that we should use stable inode number.
e.g. If we rebuild inode number using i_pos of fh, inode number is changed by i_unique.
And It is not match with inode number of FH on NFS client. So estale error will happen.
Thanks.
Quoted 3 lines
--
OGAWA Hirofumi <[email protected]>
OGAWA Hirofumi
maintainerQuoted 6 lines · Namjae Jeon
Quoted 6 lines
I think we don't need this. Because FH and ino is not necessary to have relation.
Can we re-introduce ->encode_fh() handler, and export
i_posagain? With this, I think we can geti_poscorrectly. Otherwise, ino may not contain all bits ofi_pos.
Quoted 7 lines
I already tried to fix this issue using
encode_fhwithout stable ino before. But I reached conclusion that we should use stable inode number.e.g. If we rebuild inode number using
i_posof fh, inode number is changed byi_unique.
And It is not match with inode number of FH on NFS client. So estale error will happen.
What is problem if i_ino + i_generation is not match? I think, even if those didn't match, i_pos in FH should resolve issue, no?
Signature · 1 line
OGAWA Hirofumi <[email protected]>
2012/9/24, OGAWA Hirofumi <[email protected]>:
Quoted 12 lines
Quoted 10 lines · Namjae Jeon
Quoted 6 lines
I think we don't need this. Because FH and ino is not necessary to have relation.
Can we re-introduce ->encode_fh() handler, and export
i_posagain? With this, I think we can geti_poscorrectly. Otherwise, ino may not contain all bits ofi_pos.I already tried to fix this issue using
encode_fhwithout stable ino before.
But I reached conclusion that we should use stable inode number.
Quoted 7 lines
Quoted 4 lines
e.g. If we rebuild inode number using
i_posof fh, inode number is changed byi_unique.
And It is not match with inode number of FH on NFS client. So estale error will happen.What is problem if
i_ino+i_generationis not match? I think, even if those didn't match,i_posin FH should resolve issue, no?
No, It can not resolve issue.
in NFS file handle, there is a reference to the current inode number. So, if by eviction that is changed - that it will results in "file id changed" error.
even though using the i_pos we can reconstruct and get the INODE on the Server, but the NFS handle is no more valid. As the inode number is also changed, iunique() for the file will result in different number this time.
Thanks.
Quoted 3 lines
--
OGAWA Hirofumi <[email protected]>
OGAWA Hirofumi
maintainerQuoted 6 lines · Namjae Jeon
Quoted 2 lines
What is problem if
i_ino+i_generationis not match? I think, even if those didn't match,i_posin FH should resolve issue, no?No, It can not resolve issue.
in NFS file handle, there is a reference to the current inode number. So, if by eviction that is changed - that it will results in "file id changed" error.
Who returns error?
Quoted 4 lines
even though using the
i_poswe can reconstruct and get the INODE on the Server, but the NFS handle is no more valid. As the inode number is also changed,iunique()for the file will result in different number this time.
Signature · 1 line
OGAWA Hirofumi <[email protected]>
OGAWA Hirofumi
maintainerQuoted 10 lines · OGAWA Hirofumi
Quoted 6 lines · Namjae Jeon
Quoted 2 lines
What is problem if
i_ino+i_generationis not match? I think, even if those didn't match,i_posin FH should resolve issue, no?No, It can not resolve issue.
in NFS file handle, there is a reference to the current inode number. So, if by eviction that is changed - that it will results in "file id changed" error.Who returns error?
This means - which code returns error?
Quoted 4 lines
Quoted 4 lines
even though using the
i_poswe can reconstruct and get the INODE on the Server, but the NFS handle is no more valid. As the inode number is also changed,iunique()for the file will result in different number this time.
Signature · 1 line
OGAWA Hirofumi <[email protected]>
2012/9/24, OGAWA Hirofumi <[email protected]>:
Quoted 6 lines
Quoted 4 lines · OGAWA Hirofumi
Quoted 2 lines · Namjae Jeon
Quoted 2 lines
What is problem if
i_ino+i_generationis not match? I think, even if those didn't match,i_posin FH should resolve issue, no?
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
No, It can not resolve issue.
in NFS file handle, there is a reference to the current inode number. So, if by eviction that is changed - that it will results in "file id changed" error.Who returns error?
This means - which code returns error?
Sorry, My explanation may be insufficient.
nfs_update_inode()-> on NFS client
if ((fattr->valid & NFS_ATTR_FATTR_FILEID) && nfsi->fileid != fattr->fileid) {
printk(KERN_ERR "NFS: server %s error: fileid changed\n"
"fsid %s: expected fileid 0x%Lx, got 0x%Lx\n",
NFS_SERVER(inode)->nfs_client->cl_hostname,
inode->i_sb->s_id, (long long)nfsi->fileid,
(long long)fattr->fileid);
goto out_err;
}that the problem in that case will occur with the file handle on NFS Client because the file handle on NFS client is still referring the old inode number even though the i-pos is same
Thanks.
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
even though using the
i_poswe can reconstruct and get the INODE on the Server, but the NFS handle is no more valid. As the inode number is also changed,iunique()for the file will result in different number this time.--
OGAWA Hirofumi <[email protected]>
OGAWA Hirofumi
maintainerQuoted 13 lines · Namjae Jeon
Quoted 1 line
This means - which code returns error?
Sorry, My explanation may be insufficient.
nfs_update_inode()-> on NFS client
if ((fattr->valid & NFS_ATTR_FATTR_FILEID) && nfsi->fileid != fattr->fileid) { printk(KERN_ERR "NFS: server %s error: fileid changed\n" "fsid %s: expected fileid 0x%Lx, got 0x%Lx\n", NFS_SERVER(inode)->nfs_client->cl_hostname, inode->i_sb->s_id, (long long)nfsi->fileid, (long long)fattr->fileid); goto out_err; }
Quoted 3 lines
that the problem in that case will occur with the file handle on NFS Client because the file handle on NFS client is still referring the old inode number even though the i-pos is same
I see. fileid seems to be stat.ino on nfsd4. inode->i_ino is actually just a hash key of inode hash (exception is only in audit, iirc).
So, what happens if we set "stat->ino = i_pos" on fat_getattr().
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 (opts->nfs == FAT_NFS_LIMITED) {
/* Use i_pos for ino. This is used as fileid of nfs. */
stat->ino = MSDOS_SB(inode->i_sb)->i_pos;
}
return 0;
}Signature · 1 line
OGAWA Hirofumi <[email protected]>
2012/9/24, OGAWA Hirofumi <[email protected]>:
Quoted 27 lines
Quoted 14 lines · Namjae Jeon
Quoted 1 line
This means - which code returns error?
Sorry, My explanation may be insufficient.
nfs_update_inode()-> on NFS client
if ((fattr->valid&NFS_ATTR_FATTR_FILEID) &&nfsi->fileid!=fattr->fileid) { printk(KERN_ERR "NFS: server %s error: fileid changed\n" "fsid %s: expected fileid 0x%Lx, got 0x%Lx\n", NFS_SERVER(inode)->nfs_client->cl_hostname, inode->i_sb->s_id, (long long)nfsi->fileid, (long long)fattr->fileid); goto out_err; }Quoted 3 lines
that the problem in that case will occur with the file handle on NFS Client because the file handle on NFS client is still referring the old inode number even though the i-pos is same
I see. fileid seems to be stat.ino on nfsd4.
inode->i_inois actually just a hash key of inode hash (exception is only in audit, iirc).So, what happens if we set "
stat->ino=i_pos" onfat_getattr().int
fat_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
Quoted 10 lines
{
struct inode *inode = dentry->d_inode;
generic_fillattr(inode, stat);
stat->blksize = MSDOS_SB(inode->i_sb)->cluster_size;
if (opts->nfs == FAT_NFS_LIMITED) {
/* Use i_pos for ino. This is used as fileid of nfs. */
stat->ino = MSDOS_SB(inode->i_sb)->i_pos;
}
return 0;
}Okay, Thanks for your help.
I will share the result after checking.
Quoted 2 lines
--
OGAWA Hirofumi <[email protected]>
OGAWA Hirofumi
maintainerQuoted 5 lines · Namjae Jeon
Quoted 5 lines
I see. fileid seems to be stat.ino on nfsd4.
inode->i_inois actually just a hash key of inode hash (exception is only in audit, iirc).So, what happens if we set "
stat->ino=i_pos" onfat_getattr().
Quoted 9 lines
Quoted 9 lines
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 (opts->nfs == FAT_NFS_LIMITED) { /* Use i_pos for ino. This is used as fileid of nfs. */ stat->ino = MSDOS_SB(inode->i_sb)->i_pos;
stat->ino = fat_i_pos_read(MSDOS_SB(inode->i_sb), inode);
Ouch, I forgot to use fat_i_pos_read().
Quoted 5 lines
Quoted 3 lines
} return 0; }Okay, Thanks for your help.
I will share the result after checking.
Signature · 1 line
OGAWA Hirofumi <[email protected]>
2012/9/24, OGAWA Hirofumi <[email protected]>:
Quoted 18 lines
Quoted 5 lines · Namjae Jeon
Quoted 5 lines
I see. fileid seems to be stat.ino on nfsd4.
inode->i_inois actually just a hash key of inode hash (exception is only in audit, iirc).So, what happens if we set "
stat->ino=i_pos" onfat_getattr().Quoted 10 lines
Quoted 10 lines
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 (opts->nfs == FAT_NFS_LIMITED) { /* Use i_pos for ino. This is used as fileid of nfs. */ stat->ino = MSDOS_SB(inode->i_sb)->i_pos;
Quoted 4 lines
stat->ino = fat_i_pos_read(MSDOS_SB(inode->i_sb), inode);Ouch, I forgot to use
fat_i_pos_read().
There is some unclear thing.
When I see first mail, I think maybe you don't want to use i_pos for inode->ino. FAT allocate inode->ino from i_unique on server side and If NFS client use i_pos for inode->ino in fat_get_attr, inode numbers on each client/server will still be mismatched.
Would you plz give me hint ?
Thanks OGAWA~.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
} return 0; }Okay, Thanks for your help.
I will share the result after checking.--
OGAWA Hirofumi <[email protected]>
OGAWA Hirofumi
maintainerQuoted 23 lines · Namjae Jeon
2012/9/24, OGAWA Hirofumi <[email protected]>:
Quoted 18 lines
Quoted 5 lines · Namjae Jeon
Quoted 5 lines
I see. fileid seems to be stat.ino on nfsd4.
inode->i_inois actually just a hash key of inode hash (exception is only in audit, iirc).So, what happens if we set "
stat->ino=i_pos" onfat_getattr().Quoted 10 lines
Quoted 10 lines
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 (opts->nfs == FAT_NFS_LIMITED) { /* Use i_pos for ino. This is used as fileid of nfs. */ stat->ino = MSDOS_SB(inode->i_sb)->i_pos;Quoted 4 lines
stat->ino = fat_i_pos_read(MSDOS_SB(inode->i_sb), inode);Ouch, I forgot to use
fat_i_pos_read().
Quoted 7 lines
There is some unclear thing.
When I see first mail, I think maybe you don't want to usei_posforinode->ino. FAT allocateinode->inofromi_uniqueon server side and If NFS client usei_posforinode->inoinfat_get_attr, inode numbers on each client/server will still be mismatched.Would you plz give me hint ?
->i_ino is long. It can't hold i_pos fully on 32bit arch, so we can't use ->i_no to store i_pos, and changing ->i_ino is unnecessary. If getattr() returned i_pos as ino, nobody see ->i_ino anymore except internal of kernel.
Furthermore I think there is no issue even if server and client didn't have same ino. Because client just uses FH (nfs4 seems to be using stat.ino though).
Signature · 1 line
OGAWA Hirofumi <[email protected]>
2012/9/24, OGAWA Hirofumi <[email protected]>:
Quoted 34 lines
Quoted 23 lines · Namjae Jeon
2012/9/24, OGAWA Hirofumi <[email protected]>:
Quoted 18 lines
Quoted 5 lines · Namjae Jeon
Quoted 5 lines
I see. fileid seems to be stat.ino on nfsd4.
inode->i_inois actually just a hash key of inode hash (exception is only in audit, iirc).So, what happens if we set "
stat->ino=i_pos" onfat_getattr().Quoted 10 lines
Quoted 10 lines
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 (opts->nfs == FAT_NFS_LIMITED) { /* Use i_pos for ino. This is used as fileid of nfs. */ stat->ino = MSDOS_SB(inode->i_sb)->i_pos;Quoted 4 lines
stat->ino = fat_i_pos_read(MSDOS_SB(inode->i_sb), inode);Ouch, I forgot to use
fat_i_pos_read().Quoted 8 lines
There is some unclear thing.
When I see first mail, I think maybe you don't want to usei_posforinode->ino.
FAT allocateinode->inofromi_uniqueon server side and If NFS client usei_posforinode->inoinfat_get_attr, inode numbers on each client/server will still be mismatched.Would you plz give me hint ?
Quoted 8 lines
->i_ino is long. It can't hold
i_posfully on 32bit arch, so we can't use ->i_no to storei_pos, and changing ->i_ino is unnecessary. Ifgetattr()returnedi_posas ino, nobody see ->i_ino anymore except internal of kernel.Furthermore I think there is no issue even if server and client didn't have same ino. Because client just uses FH (nfs4 seems to be using stat.ino though).
Okay, I will share the result after checking and testing more(nfsv3 and nfsv4). Thanks a lot!
Quoted 3 lines
--
OGAWA Hirofumi <[email protected]>
Quoted 31 lines · OGAWA Hirofumi
Quoted 29 lines · Namjae Jeon
2012/9/24, OGAWA Hirofumi <[email protected]>:
Quoted 18 lines
Quoted 5 lines · Namjae Jeon
Quoted 5 lines
I see. fileid seems to be stat.ino on nfsd4.
inode->i_inois actually just a hash key of inode hash (exception is only in audit, iirc).So, what happens if we set "
stat->ino=i_pos" onfat_getattr().Quoted 10 lines
Quoted 10 lines
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 (opts->nfs == FAT_NFS_LIMITED) { /* Use i_pos for ino. This is used as fileid of nfs. */ stat->ino = MSDOS_SB(inode->i_sb)->i_pos;Quoted 4 lines
stat->ino = fat_i_pos_read(MSDOS_SB(inode->i_sb), inode);Ouch, I forgot to use
fat_i_pos_read().There is some unclear thing.
When I see first mail, I think maybe you don't want to usei_posforinode->ino. FAT allocateinode->inofromi_uniqueon server side and If NFS client usei_posforinode->inoinfat_get_attr, inode numbers on each client/server will still be mismatched.
Quoted 6 lines
Quoted 1 line
Would you plz give me hint ?
->i_ino is long. It can't hold
i_posfully on 32bit arch, so we can't use ->i_no to storei_pos, and changing ->i_ino is unnecessary. Ifgetattr()returnedi_posas ino, nobody see ->i_ino anymore except internal of kernel.
The NFS server must always return the same inode number for the same filehandle. To do otherwise is a bug.
Quoted 3 lines
Furthermore I think there is no issue even if server and client didn't have same ino. Because client just uses FH (nfs4 seems to be using stat.ino though).
The client may expose a different inode number to userspace, but it's probably the server-provided inode number that it's checking.
(And even if the Linux client didn't currently happen to do that check, this would still be a bug.)
--b.
OGAWA Hirofumi
maintainerQuoted 20 lines · J. Bruce Fields
Quoted 6 lines
Quoted 6 lines
There is some unclear thing.
When I see first mail, I think maybe you don't want to usei_posforinode->ino. FAT allocateinode->inofromi_uniqueon server side and If NFS client usei_posforinode->inoinfat_get_attr, inode numbers on each client/server will still be mismatched.Quoted 6 lines
Quoted 1 line
Would you plz give me hint ?
->i_ino is long. It can't hold
i_posfully on 32bit arch, so we can't use ->i_no to storei_pos, and changing ->i_ino is unnecessary. Ifgetattr()returnedi_posas ino, nobody see ->i_ino anymore except internal of kernel.The NFS server must always return the same inode number for the same filehandle. To do otherwise is a bug.
Quoted 3 lines
Furthermore I think there is no issue even if server and client didn't have same ino. Because client just uses FH (nfs4 seems to be using stat.ino though).
Quoted 5 lines
The client may expose a different inode number to userspace, but it's probably the server-provided inode number that it's checking.
(And even if the Linux client didn't currently happen to do that check, this would still be a bug.)
In this context, inode number != inode->i_ino, right? It should be kstat.ino, and in FAT case, it will return i_pos always. Otherwise 64bit inode number would not work.
So, I think we are doing right thing for now.
Anyway, thanks for your review.
Signature · 1 line
OGAWA Hirofumi <[email protected]>
Quoted 25 lines · OGAWA Hirofumi
Quoted 23 lines · J. Bruce Fields
Quoted 6 lines
Quoted 6 lines
There is some unclear thing.
When I see first mail, I think maybe you don't want to usei_posforinode->ino. FAT allocateinode->inofromi_uniqueon server side and If NFS client usei_posforinode->inoinfat_get_attr, inode numbers on each client/server will still be mismatched.Quoted 6 lines
Quoted 1 line
Would you plz give me hint ?
->i_ino is long. It can't hold
i_posfully on 32bit arch, so we can't use ->i_no to storei_pos, and changing ->i_ino is unnecessary. Ifgetattr()returnedi_posas ino, nobody see ->i_ino anymore except internal of kernel.The NFS server must always return the same inode number for the same filehandle. To do otherwise is a bug.
Quoted 3 lines
Furthermore I think there is no issue even if server and client didn't have same ino. Because client just uses FH (nfs4 seems to be using stat.ino though).
The client may expose a different inode number to userspace, but it's probably the server-provided inode number that it's checking.
Quoted 8 lines
Quoted 2 lines
(And even if the Linux client didn't currently happen to do that check, this would still be a bug.)
In this context, inode number !=
inode->i_ino, right? It should be kstat.ino, and in FAT case, it will returni_posalways. Otherwise 64bit inode number would not work.So, I think we are doing right thing for now.
Oh, OK. On a quick check, yes, the numbers the server returns to clients are taken from either kstat.ino or the ino argument of the filldir function.
--b.
Hi OGAWA.
It works fine. there is no estale error while memory reclaim. I will make patchset again as review comment and your suggestion (encode_fh, fat_getattr).
Thanks!
2012/9/25, J. Bruce Fields <[email protected]>:
Quoted 43 lines · OGAWA Hirofumi
Quoted 27 lines
Quoted 25 lines · J. Bruce Fields
Quoted 8 lines
Quoted 8 lines
There is some unclear thing.
When I see first mail, I think maybe you don't want to usei_posforinode->ino.
FAT allocateinode->inofromi_uniqueon server side and If NFS client
usei_posforinode->inoinfat_get_attr, inode numbers on each client/server will still be mismatched.Quoted 6 lines
Quoted 1 line
Would you plz give me hint ?
->i_ino is long. It can't hold
i_posfully on 32bit arch, so we can't use ->i_no to storei_pos, and changing ->i_ino is unnecessary. Ifgetattr()returnedi_posas ino, nobody see ->i_ino anymore except internal of kernel.The NFS server must always return the same inode number for the same filehandle. To do otherwise is a bug.
Quoted 3 lines
Furthermore I think there is no issue even if server and client didn't have same ino. Because client just uses FH (nfs4 seems to be using stat.ino though).
The client may expose a different inode number to userspace, but it's probably the server-provided inode number that it's checking.
Quoted 8 lines
Quoted 2 lines
(And even if the Linux client didn't currently happen to do that check, this would still be a bug.)
In this context, inode number !=
inode->i_ino, right? It should be kstat.ino, and in FAT case, it will returni_posalways. Otherwise 64bit inode number would not work.So, I think we are doing right thing for now.
Oh, OK. On a quick check, yes, the numbers the server returns to clients are taken from either kstat.ino or the ino argument of the filldir function.
--b.