Skip to content

Test overlayfs readdir cache

Amir Goldstein fstests linux-unionfs 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest5 patches 4 repliesIn review
  2. v12 patches 8 repliesSuperseded

Changes in v2 from the cover letter

- Use small getdents buffer to force multiple calls
- Tidy up new command line options for t_dir_offset2
- Check missing/stale entries on new fd
- Add impure dir use case to overlay test

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5src/t_dir_offset2: Add an option to limit of buffer sizesrc/t_dir_offset2.c+21 -50 replies
2/5src/t_dir_offset2: Add an option to find file by namesrc/t_dir_offset2.c+38 -10 replies
3/5src/t_dir_offset2: Add option to create or unlink filesrc/t_dir_offset2.c+53 -30 replies
4/5generic: Test readdir of modified directrorytests/generic/700 tests/generic/700.out tests/generic/group+65 -00 replies
5/5overlay: Test invalidate of readdir cachetests/overlay/077 tests/overlay/077.out tests/overlay/group+120 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/5] Test overlayfs readdir cache

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?

Thanks,
Amir.

Changes since v1:
- Use small getdents buffer to force multiple calls
- Tidy up new command line options for t_dir_offset2
- Check missing/stale entries on new fd
- Add impure dir use case to overlay test

Amir Goldstein (5):
src/t_dir_offset2: Add an option to limit of buffer size src/t_dir_offset2: Add an option to find file by name src/t_dir_offset2: Add option to create or unlink file
generic: Test readdir of modified directrory
overlay: Test invalidate of readdir cache

 src/t_dir_offset2.c   | 113 ++++++++++++++++++++++++++++++++++++++--
 tests/generic/700     |  62 ++++++++++++++++++++++
 tests/generic/700.out |   2 +
 tests/generic/group   |   1 +
 tests/overlay/077     | 117 ++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/077.out |   2 +
 tests/overlay/group   |   1 +
 7 files changed, 293 insertions(+), 5 deletions(-)
 create mode 100755 tests/generic/700
 create mode 100644 tests/generic/700.out
 create mode 100755 tests/overlay/077
 create mode 100644 tests/overlay/077.out

--

fs/overlayfs/readdir.c +1 -1
index cc1e80257064..cadcbfafa179 100644
@@ -486,7 +486,7 @@ static int ovl_cache_update_ino(struct path *path, struct ovl_cache_entry *p)
                        this = NULL;
                        goto fail;
                }
-               goto out;
+               goto fail;
        }
 
 get:
Signature · 1 line
2.31.1