hostfs: fix opening file with overlayfs
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Richard Weinberger
maintainerCC'ing VFS folks
Am 01.05.2016 um 11:02 schrieb Toshikuni Fukaya:
Quoted 10 lines
If a file on overlayfs using hostfs as a lowerdir is opened, it would be failed by ENOENT because hostfs resolves a host path by a host root path stored on the hostfs superblock referred by
file->f_path.dentry, but it is replaced with overlayfs's one starting from the commit4bacc9c9234c("overlayfs: Makef_pathalways point to the overlay andf_inodeto the underlay").We replace using
file->f_path.dentrydirectly with calling "file_dentry" from a commitd101a125954e("fs: addfile_dentry()") to fix the issue.
Is there a reason why not all instances of file->f_path.dentry have been replaced by file_dentry()?
I smell more fallout...
Thanks,
//richard
Quoted 28 lines
Signed-off-by Toshikuni Fukaya <[email protected]>--- fs/hostfs/hostfs_kern.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/hostfs/hostfs_kern.c +2
-2@@ -284,7 +284,7 @@ static int hostfs_readdir(struct file *file, struct dir_context *ctx)int error, len;unsigned int type; - name =dentry_name (file->f_path.dentry); + name =dentry_name (file_dentry (file));if (name ==NULL )return -ENOMEM ; dir =open_dir (name, &error);@@ -323,7 +323,7 @@ retry:if (mode &FMODE_WRITE ) r = w =1 ; - name =dentry_name (file->f_path.dentry); + name =dentry_name (file_dentry (file));if (name ==NULL )return -ENOMEM ;
Miklos Szeredi
Acked-byQuoted 10 lines · Richard Weinberger
CC'ing VFS folks
Am 01.05.2016 um 11:02 schrieb Toshikuni Fukaya:
Quoted 7 lines
If a file on overlayfs using hostfs as a lowerdir is opened, it would be failed by ENOENT because hostfs resolves a host path by a host root path stored on the hostfs superblock referred by
file->f_path.dentry, but it is replaced with overlayfs's one starting from the commit4bacc9c9234c("overlayfs: Makef_pathalways point to the overlay andf_inodeto the underlay").
Quoted 7 lines
Quoted 3 lines
We replace using
file->f_path.dentrydirectly with calling "file_dentry" from a commitd101a125954e("fs: addfile_dentry()") to fix the issue.Is there a reason why not all instances of
file->f_path.dentryhave been replaced byfile_dentry()?
I smell more fallout...
It's perfectly safe to do. But automatic conversion is not advised, as there are cases where using f_path.dentry is just hiding bugs. Each case should be thought about separately, and preferably converted to file_inode() if possible.
The hostfs patch looks good, though.
Thanks,
Miklos
Quoted 32 lines
Thanks,
//richardQuoted 28 lines
Signed-off-by Toshikuni Fukaya <[email protected]>--- fs/hostfs/hostfs_kern.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/hostfs/hostfs_kern.c +2
-2@@ -284,7 +284,7 @@ static int hostfs_readdir(struct file *file, struct dir_context *ctx)int error, len;unsigned int type; - name =dentry_name (file->f_path.dentry); + name =dentry_name (file_dentry (file));if (name ==NULL )return -ENOMEM ; dir =open_dir (name, &error);@@ -323,7 +323,7 @@ retry:if (mode &FMODE_WRITE ) r = w =1 ; - name =dentry_name (file->f_path.dentry); + name =dentry_name (file_dentry (file));if (name ==NULL )return -ENOMEM ;