Re: [PATCH] ovl: fix inconsistent d_ino for merge dir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2017/12/30 17:51, Amir Goldstein Wrote:

On Sat, Dec 30, 2017 at 9:49 AM, zhangyi (F) <yi.zhang@xxxxxxxxxx> wrote:
Current ovl_getattr() (stat(2)) return lower's d_ino for merge
directory (No any extended attribute) but ovl_iterate()
(getdents(2)) return upper's d_ino.

This patch correct inconsistent d_ino for this case, change to
return lower's d_ino in ovl_iterate() for merge dir.

Signed-off-by: zhangyi (F) <yi.zhang@xxxxxxxxxx>
---
  fs/overlayfs/readdir.c | 5 +++++
  1 file changed, 5 insertions(+)

diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index 8c98578..9548712 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -136,6 +136,11 @@ static bool ovl_calc_d_ino(struct ovl_readdir_data *rdd,
             ovl_test_flag(OVL_IMPURE, d_inode(rdd->dentry)))
                 return true;

+       /* Recalc d_ino for all dir in merge dir (contains merge subdirs) */
+       if (p->type == DT_DIR &&
+           OVL_TYPE_MERGE(ovl_path_type(rdd->dentry)))
Why only subdirs and not files with origin?
This is a partial fix and I think Miklos has rejected a similar fix by Chandan
and said that this should be fixed by a future fsck.overlay (hint hint).
The inconsistency is that the directory contains origin (and merge subdir)
and is not marked "impure". That is what fsck.overlay needs to fix and then
"Recalc d_ino for for all entries if dir is impure (contains copied up entries)"
will do the right thing.

I understand the inconsistency of missing impure xattr should be fixed by fsck.overlay,
but the case of this patch want to fix is not this one.

It's for the case of newly created overlay image. There is no origin xattr for the merge subdir and no impure xattr for it's parent, and there is also no requirement that user
should run fsck.overlay before first mount.

eg (a simplest situation):
# mkdir lower upper work merge
# mkdir lower/dir upper/dir
# mount -t overlay overlay -olowerdir=lower,upperdir=upper,workdir=work merge
# stat -c "%i" merge/dir/
389572
# getdents merge | grep dir                     (getdents is program list in getdents(2))
389573  directory    16          2  dir

I think if we set origin for merge dir and set impure for it's parent in ovl_lookup() can also
fix this problem.

Thanks,
Yi.
--
To unsubscribe from this list: send the line "unsubscribe linux-unionfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux