ovl: set lower layer st_dev only if setting lower st_ino
Amir Goldstein
maintainerPATCH v2 1/1 ovl: set lower layer st_dev only if setting lower st_ino
For broken hardlinks, we do not return lower st_ino, so we should also not return lower pseudo st_dev.
--- fs/overlayfs/inode.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
Miklos,
This is the bug fix on top of current overlayfs-next. Since this patch will not apply to v4.15, I will send backported v1 to stable after this is merged.
If you prefer to rebase xino patches over v1 bugfix, you can use this one as conflict resolution.
Thanks,
Amir.
fs/overlayfs/inode.c +15 -9
@@ -59,13 +59,19 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)return err; } -static int ovl_map_dev_ino (struct dentry *dentry,struct kstat *stat) +static int ovl_map_dev_ino (struct dentry *dentry,struct kstat *stat, +u64 origin_ino) { -struct ovl_layer *lower_layer =ovl_layer_lower (dentry); -bool samefs =ovl_same_sb (dentry->d_sb); +struct ovl_layer *lower_layer =NULL ;unsigned int xinobits =ovl_xino_bits (dentry->d_sb); -if (samefs) { +if (origin_ino) { + stat->ino = origin_ino; + lower_layer =ovl_layer_lower (dentry); +WARN_ON (!lower_layer); + } + +if (ovl_same_sb (dentry->d_sb)) {/* * When all layers are on the same fs, all real inode * number are unique, so we use the overlay st_dev,
@@ -131,6 +137,7 @@ int ovl_getattr(const struct path *path, struct kstat *stat,const struct cred *old_cred;bool is_dir =S_ISDIR (dentry->d_inode->i_mode);bool samefs =ovl_same_sb (dentry->d_sb); +u64 origin_ino =0 ;int err; type =ovl_path_real (dentry, &realpath);
@@ -177,14 +184,13 @@ int ovl_getattr(const struct path *path, struct kstat *stat,if (ovl_test_flag (OVL_INDEX ,d_inode (dentry)) || (!ovl_verify_lower (dentry->d_sb) && (is_dir || lowerstat.nlink ==1 ))) - stat->ino = lowerstat.ino; - -if (samefs) -WARN_ON_ONCE (stat->dev != lowerstat.dev); + origin_ino = lowerstat.ino; + }else if (!OVL_TYPE_UPPER (type)) { + origin_ino = stat->ino; } } - err =ovl_map_dev_ino (dentry, stat); + err =ovl_map_dev_ino (dentry, stat, origin_ino);if (err) goto out;
Signature · 1 line
2.7.4
Miklos Szeredi
maintainerQuoted 10 lines · Amir Goldstein
For broken hardlinks, we do not return lower
st_ino, so we should also not return lower pseudost_dev.Fixes a0c5ad307ac0 ("ovl: relax same fs constraint for constant st_ino")Cc <[email protected]> #v4.15Signed-off-by Amir Goldstein <[email protected]>--- fs/overlayfs/inode.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
Quoted 8 lines
Miklos,
This is the bug fix on top of current overlayfs-next. Since this patch will not apply to v4.15, I will send backported v1 to stable after this is merged.
If you prefer to rebase xino patches over v1 bugfix, you can use this one as conflict resolution.
Rebased and gone for a slightly different resolution, bug AFAIK the same result in terms of functionality.
Please verify.
Thanks,
Miklos
Amir Goldstein
maintainerQuoted 17 lines · Miklos Szeredi
Quoted 16 lines · Amir Goldstein
For broken hardlinks, we do not return lower
st_ino, so we should also not return lower pseudost_dev.Fixes a0c5ad307ac0 ("ovl: relax same fs constraint for constant st_ino")Cc <[email protected]> #v4.15Signed-off-by Amir Goldstein <[email protected]>--- fs/overlayfs/inode.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)Miklos,
This is the bug fix on top of current overlayfs-next. Since this patch will not apply to v4.15, I will send backported v1 to stable after this is merged.
Quoted 8 lines
Quoted 2 lines
If you prefer to rebase xino patches over v1 bugfix, you can use this one as conflict resolution.
Rebased and gone for a slightly different resolution, bug AFAIK the same result in terms of functionality.
Please verify.
Looks good and verified.
Thanks,
Amir.