OSDN Git Service

ovl: skip stale entries in merge dir cache iteration
authorAmir Goldstein <amir73il@gmail.com>
Mon, 26 Apr 2021 15:20:21 +0000 (18:20 +0300)
committerMiklos Szeredi <mszeredi@redhat.com>
Tue, 10 Aug 2021 08:21:30 +0000 (10:21 +0200)
commit9011c2791e63fc05721b545c41ad025d8073566e
tree4168367806b39326e1abebf0607eb1b39ec5369f
parente73f0f0ee7541171d89f2e2491130c7771ba58d3
ovl: skip stale entries in merge dir cache iteration

On the first getdents call, ovl_iterate() populates the readdir cache
with a list of entries, but for upper entries with origin lower inode,
p->ino remains zero.

Following getdents calls traverse the readdir cache list and call
ovl_cache_update_ino() for entries with zero p->ino to lookup the entry
in the overlay and return d_ino that is consistent with st_ino.

If the upper file was unlinked between the first getdents call and the
getdents call that lists the file entry, ovl_cache_update_ino() will not
find the entry and fall back to setting d_ino to the upper real st_ino,
which is inconsistent with how this object was presented to users.

Instead of listing a stale entry with inconsistent d_ino, simply skip
the stale entry, which is better for users.

xfstest overlay/077 is failing without this patch.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Link: https://lore.kernel.org/fstests/CAOQ4uxgR_cLnC_vdU5=seP3fwqVkuZM_-WfD6maFTMbMYq=a9w@mail.gmail.com/
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/readdir.c