On Mon, Apr 26, 2021 at 1:07 PM Miklos Szeredi <miklos@xxxxxxxxxx> wrote: > > On Sun, Apr 25, 2021 at 9:14 AM Amir Goldstein <amir73il@xxxxxxxxx> wrote: > > > > Eryu, > > > > This extends the generic t_dir_offset2 helper program to verify > > some cases of missing/stale entries and adds a new generic test which > > passes on overlayfs (and other fs) on upstream kernel. > > > > The overlayfs specific test fails on upstream kernel and the fix commit > > is currently in linux-next. As usual, you may want to wait with merging > > until the fix commit hits upstream. > > > > Based on feedback from Miklos, I changed the test to check for the > > missing/stale entries on a new fd, while old fd is kept open, because > > POSIX allows for stale/missing entries in the old fd. > > > > I was looking into another speculated bug in overlayfs which involves > > multiple calls to getdents. Although it turned out that overlayfs does > > not have the speculated bug, I left both generic and overlay test with > > multiple calls to getdents in order to excersize the relevant code. > > > > The attached patch was used to verify that the overlayfs test excercises > > the call to ovl_cache_update_ino() with stale entries. > > Overlayfs populates the merge dir readdir cache with a list of files in > > the first getdents call, but updates d_ino of files on the list in > > subsequent getdents calls. By that time, the last entry is stale and the > > following warning is printed (on linux-next with patch below applied): > > [ ] overlayfs: failed to look up (m100) for ino (0) > > [ ] overlayfs: failed to look up (f100) for ino (0) > > > > Miklos, > > > > Do you think it is worth the trouble to set p->is_whiteout and skip > > dir_emit() in this case? and do we need to worry about lookup_one_len() > > returning -ENOENT in this case? > > So lookup_one_len() first does a cached lookup, and if found returns > that. If not then it calls the filesystem's ->lookup() callback, > which in this case is ovl_lookup(). AFAICS ovl_lookup() will never > return ENOENT, even if the underlying filesystem does. > > Which means it's not necessary to worry about that case. > > The other case you found it that in case of a stale direntry the i_ino > update will be skipped and so it will return an inconsistent result, > right? Right. It returns a stale entry with the old real ino. Not sure if that is an "inconsistent" result. inconsistent w.r.t what? > Fixing that looks worthwhile, yes. > Will look into it. Thanks, Amir.