Unionfs: prevent false lockdep warnings in stacking
authorErez Zadok <ezk@cs.sunysb.edu>
Thu, 27 Dec 2007 18:35:36 +0000 (13:35 -0500)
committerErez Zadok <ezk@cs.sunysb.edu>
Mon, 12 Jan 2009 23:20:49 +0000 (18:20 -0500)
commit853206ec7f6f8a811afa6e42b762656967ba63aa
treed89af3cfc091462b46fad55c32faa771f49b8c5c
parent936744dd66c3764cc39915ee524d015e71eb758b
Unionfs: prevent false lockdep warnings in stacking

A stackable file system like unionfs often performs an operation on a lower
file system, by calling a vfs_* method, having been called possibly by the
very same method from the VFS.  Both calls to the vfs_* method grab a lock
in the same lock class, and hence lockdep complains.  This warning is a
false positive in instances where unionfs only calls the vfs_* method on
lower objects; there's a strict lock ordering here: upper objects first,
then lower objects.

We want to prevent these false positives so that lockdep will not shutdown
so it'd still be able to warn us about potentially true locking problems.
So, we temporarily turn off lockdep ONLY AROUND the calls to vfs methods to
which we pass lower objects, and only for those instances where lockdep
complained.  While this solution may seem unclean, it is not without
precedent: other places in the kernel also do similar temporary disabling,
of course after carefully having checked that it is the right thing to do.

In the long run, lockdep needs to be taught how to handle about stacking.
Then this patch can be removed.  It is likely that such lockdep-stacking
support will do essentially the same as this patch: consider the same
ordering (upper then lower) and consider upper vs. lower locks to be in
different classes.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
Documentation/filesystems/unionfs/issues.txt
fs/unionfs/copyup.c
fs/unionfs/inode.c
fs/unionfs/rename.c
fs/unionfs/super.c
fs/unionfs/unlink.c