tmpfs: allow decoding a file handle of an unlinked file
Subsystems (3)
PATCH v2 1/1 tmpfs: allow decoding a file handle of an unlinked file
tmpfs uses the helper d_find_alias() to find a dentry from a decoded inode, but d_find_alias() skips unhashed dentries, so unlinked files cannot be decoded from a file handle.
This can be reproduced using xfstests test program open_by_handle:
$ open_by handle -c /tmp/testdir $ open_by_handle -dk /tmp/testdir open_by_handle(/tmp/testdir/file000000) returned 116 incorrectly on an unlinked open file!
To fix this, if d_find_alias() can't find a hashed alias, call d_find_any_alias() to return an unhashed one.
---
Al, Miklos,
Can either of you take this patch through your tree?
Thanks,
Amir.
Changes since v1:
- Prefer a hashed alias (James)
- Use existing d_find_any_alias() helper
mm/shmem.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
mm/shmem.c +10 -1
@@ -3404,6 +3404,15 @@ static int shmem_match(struct inode *ino, void *vfh)return ino->i_ino == inum && fh[0 ] == ino->i_generation; } +/* Find any alias of inode, but prefer a hashed alias */ +static struct dentry *shmem_find_alias (struct inode *inode) +{ +struct dentry *alias =d_find_alias (inode); + +return alias ?:d_find_any_alias (inode); +} + +static struct dentry *shmem_fh_to_dentry (struct super_block *sb,struct fid *fid,int fh_len,int fh_type) {
@@ -3420,7 +3429,7 @@ static struct dentry *shmem_fh_to_dentry(struct super_block *sb, inode =ilookup5 (sb, (unsigned long )(inum + fid->raw[0 ]), shmem_match, fid->raw);if (inode) { - dentry =d_find_alias (inode); + dentry =shmem_find_alias (inode);iput (inode); }
Signature · 1 line
2.7.4
Quoted 53 lines · Amir Goldstein
tmpfs uses the helper
d_find_alias()to find a dentry from a decoded inode, butd_find_alias()skips unhashed dentries, so unlinked files cannot be decoded from a file handle.This can be reproduced using xfstests test program
open_by_handle:$ open_by handle -c /tmp/testdir $ open_by_handle -dk /tmp/testdir open_by_handle(/tmp/testdir/file000000) returned 116 incorrectly on an unlinked open file!To fix this, if
d_find_alias()can't find a hashed alias, calld_find_any_alias()to return an unhashed one.Cc Hugh Dickins <[email protected]>Cc Al Viro <[email protected]>Signed-off-by Amir Goldstein <[email protected]>---
Al, Miklos,
Can either of you take this patch through your tree?
Thanks,
Amir.Changes since v1:
- Prefer a hashed alias (James)
- Use existingd_find_any_alias()helpermm/shmem.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)mm/shmem.c +9
-0@@ -3404,6 +3404,15 @@ static int shmem_match(struct inode *ino, void *vfh)return ino->i_ino == inum && fh[0 ] == ino->i_generation; } +/* Find any alias of inode, but prefer a hashed alias */ +static struct dentry *shmem_find_alias (struct inode *inode) +{ +struct dentry *alias =d_find_alias (inode); + +return alias ?:d_find_any_alias (inode); +} + +static struct dentry *shmem_fh_to_dentry (struct super_block *sb,struct fid *fid,int fh_len,int fh_type) {
mm/shmem.c static struct dentry *shmem_fh_to_dentry(struct super_block *sb,
Quoted 9 lines
mm/shmem.c +1
-2@@ -3420,7 +3429,7 @@ static struct dentry *shmem_fh_to_dentry(struct super_block *sb, inode =ilookup5 (sb, (unsigned long )(inum + fid->raw[0 ]), shmem_match, fid->raw);if (inode) { - dentry =d_find_alias (inode); + dentry =shmem_find_alias (inode);iput (inode); } --
Hugh,
Did you get a chance to look at this patch?
The test for decoding a file handle of an unlinked file has already been merged to xfstest generic/467 and the test is failing on tmpfs without this change.
Can you please take or ACK this patch?
Thanks,
Amir.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 66 lines · Amir Goldstein
Quoted 53 lines · Amir Goldstein
tmpfs uses the helper
d_find_alias()to find a dentry from a decoded inode, butd_find_alias()skips unhashed dentries, so unlinked files cannot be decoded from a file handle.This can be reproduced using xfstests test program
open_by_handle:$ open_by handle -c /tmp/testdir $ open_by_handle -dk /tmp/testdir open_by_handle(/tmp/testdir/file000000) returned 116 incorrectly on an unlinked open file!To fix this, if
d_find_alias()can't find a hashed alias, calld_find_any_alias()to return an unhashed one.Cc Hugh Dickins <[email protected]>Cc Al Viro <[email protected]>Signed-off-by Amir Goldstein <[email protected]>---
Al, Miklos,
Can either of you take this patch through your tree?
Thanks,
Amir.Changes since v1:
- Prefer a hashed alias (James)
- Use existingd_find_any_alias()helpermm/shmem.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)mm/shmem.c +9
-0@@ -3404,6 +3404,15 @@ static int shmem_match(struct inode *ino, void *vfh)return ino->i_ino == inum && fh[0 ] == ino->i_generation; } +/* Find any alias of inode, but prefer a hashed alias */ +static struct dentry *shmem_find_alias (struct inode *inode) +{ +struct dentry *alias =d_find_alias (inode); + +return alias ?:d_find_any_alias (inode); +} + +static struct dentry *shmem_fh_to_dentry (struct super_block *sb,struct fid *fid,int fh_len,int fh_type) {mm/shmem.c static struct dentry *shmem_fh_to_dentry(struct super_block *sb,
Quoted 9 lines
mm/shmem.c +1
-2@@ -3420,7 +3429,7 @@ static struct dentry *shmem_fh_to_dentry(struct super_block *sb, inode =ilookup5 (sb, (unsigned long )(inum + fid->raw[0 ]), shmem_match, fid->raw);if (inode) { - dentry =d_find_alias (inode); + dentry =shmem_find_alias (inode);iput (inode); } --Hugh,
Quoted 8 lines
Did you get a chance to look at this patch?
The test for decoding a file handle of an unlinked file has already been merged to xfstest generic/467 and the test is failing on tmpfs without this change.
Can you please take or ACK this patch?
Ping.
Real problem.
Trivial fix.
Al, Can you take this patch?
Thanks,
Amir.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 69 lines · Amir Goldstein
Quoted 68 lines · Amir Goldstein
Quoted 53 lines · Amir Goldstein
tmpfs uses the helper
d_find_alias()to find a dentry from a decoded inode, butd_find_alias()skips unhashed dentries, so unlinked files cannot be decoded from a file handle.This can be reproduced using xfstests test program
open_by_handle:$ open_by handle -c /tmp/testdir $ open_by_handle -dk /tmp/testdir open_by_handle(/tmp/testdir/file000000) returned 116 incorrectly on an unlinked open file!To fix this, if
d_find_alias()can't find a hashed alias, calld_find_any_alias()to return an unhashed one.Cc Hugh Dickins <[email protected]>Cc Al Viro <[email protected]>Signed-off-by Amir Goldstein <[email protected]>---
Al, Miklos,
Can either of you take this patch through your tree?
Thanks,
Amir.Changes since v1:
- Prefer a hashed alias (James)
- Use existingd_find_any_alias()helpermm/shmem.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)mm/shmem.c +9
-0@@ -3404,6 +3404,15 @@ static int shmem_match(struct inode *ino, void *vfh)return ino->i_ino == inum && fh[0 ] == ino->i_generation; } +/* Find any alias of inode, but prefer a hashed alias */ +static struct dentry *shmem_find_alias (struct inode *inode) +{ +struct dentry *alias =d_find_alias (inode); + +return alias ?:d_find_any_alias (inode); +} + +static struct dentry *shmem_fh_to_dentry (struct super_block *sb,struct fid *fid,int fh_len,int fh_type) {mm/shmem.c static struct dentry *shmem_fh_to_dentry(struct super_block *sb,
Quoted 9 lines
mm/shmem.c +1
-2@@ -3420,7 +3429,7 @@ static struct dentry *shmem_fh_to_dentry(struct super_block *sb, inode =ilookup5 (sb, (unsigned long )(inum + fid->raw[0 ]), shmem_match, fid->raw);if (inode) { - dentry =d_find_alias (inode); + dentry =shmem_find_alias (inode);iput (inode); } --Hugh,
Did you get a chance to look at this patch?
Quoted 9 lines
Quoted 6 lines
The test for decoding a file handle of an unlinked file has already been merged to xfstest generic/467 and the test is failing on tmpfs without this change.
Can you please take or ACK this patch?
Ping.
Ping^2