Skip to content

RFC Reduce excessive use of lock_rename() in overlayfs

Amir Goldstein linux-fsdevel linux-unionfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest4 patches 18 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4vfs: reinterpret sillyrename flag as delete lockfs/afs/dir.c fs/btrfs/ioctl.c fs/namei.c +1 more+19 -100 replies
2/4vfs: introduce delete trylock/unlockinclude/linux/dcache.h+23 -10 replies
3/4ovl: delete lock upper dir and work dirfs/overlayfs/super.c+52 -110 replies
4/4ovl: relax lock_rename when moving files between work and upper dirfs/namei.c fs/overlayfs/copy_up.c fs/overlayfs/dir.c +2 more+44 -1218 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [RFC][PATH 0/4] Reduce excessive use of lock_rename() in overlayfs

lock_rename() is a very big hammer used before every call to vfs_rename(), in order to avoid some horrible corner cases that are described in the comment above vfs_rename().

lock_rename() taked a super block global mutex before every rename operation that involved moving to a different parent and forces all such renames in the file system to be serialized.

That cost may be acceptable to most workloads, because moving files/dirs between directories are not as common as other file system operations.

Overlayfs uses vfs_rename() more that most file systems do, not only for user requested renames, but also for every copy-up and every whiteout, so vfs_rename() can be triggered from user operations open/create/delete, that are much more common the renames.

It turns out, though, that all the horrible corner cases that require the big lock_rename() hammer, can be eliminated when setting up the overlay mount and then lock_rename() can be avoided in many use cases.

I do not have any performance results to show, which is really called for in this sort of work. But it seems obvious that when running multiple docker containers, file system operations should not be serialized among all of them. So I am hoping that someone, with test machines stronger than mine, can take this code to a test drive.

This code passed regression tests with unionmount-testsuite, pjdfstest and xfstests -g quick.
It fails xfs tests generic/373 and generic/374 and for a good reason:
those tests try to mount 2 overlayfs mounts with the same upper/work dirs. I will send patches to fix those 2 tests.

Amir Goldstein (4):
vfs: reinterpret sillyrename flag as delete lock
vfs: introduce delete trylock/unlock
ovl: delete lock upper dir and work dir
ovl: relax lock_rename when moving files between work and upper dir

 fs/afs/dir.c             |  6 ++---
 fs/btrfs/ioctl.c         |  5 ++--
 fs/namei.c               | 25 ++++++++++++++++---
 fs/overlayfs/copy_up.c   |  7 +++---
 fs/overlayfs/dir.c       | 25 +++++++++++++------
 fs/overlayfs/overlayfs.h |  2 ++
 fs/overlayfs/super.c     | 63 +++++++++++++++++++++++++++++++++++++++---------
 include/linux/dcache.h   | 35 +++++++++++++++++++++++++++
 include/linux/namei.h    |  2 ++
 9 files changed, 137 insertions(+), 33 deletions(-)
Signature · 1 line
2.7.4