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>
Tue, 13 Jan 2009 01:43:30 +0000 (20:43 -0500)
commit727702668708703851668dc2a93bd0540ab693cc
tree2c8a051c25e6892243aa070e7fe853eec381665b
parent7979d048d0ffc7c7b9a9eb10a18c1e52846f97ed
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