xarray: add the xa_lock to the radix_tree_root
authorMatthew Wilcox <[email protected]>
Tue, 10 Apr 2018 23:36:52 +0000 (16:36 -0700)
committerLinus Torvalds <[email protected]>
Wed, 11 Apr 2018 17:28:39 +0000 (10:28 -0700)
commitf6bb2a2c0b81c47282ddb7883f92e65a063c27dd
tree74eb6dece48af9baee664a3abe1d70b5798f8b0d
parente5a955419642e0842fd26e1ada6ab3328018ca16
xarray: add the xa_lock to the radix_tree_root

This results in no change in structure size on 64-bit machines as it
fits in the padding between the gfp_t and the void *.  32-bit machines
will grow the structure from 8 to 12 bytes.  Almost all radix trees are
protected with (at least) a spinlock, so as they are converted from
radix trees to xarrays, the data structures will shrink again.

Initialising the spinlock requires a name for the benefit of lockdep, so
RADIX_TREE_INIT() now needs to know the name of the radix tree it's
initialising, and so do IDR_INIT() and IDA_INIT().

Also add the xa_lock() and xa_unlock() family of wrappers to make it
easier to use the lock.  If we could rely on -fplan9-extensions in the
compiler, we could avoid all of this syntactic sugar, but that wasn't
added until gcc 4.6.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Matthew Wilcox <[email protected]>
Reviewed-by: Jeff Layton <[email protected]>
Cc: Darrick J. Wong <[email protected]>
Cc: Dave Chinner <[email protected]>
Cc: Ryusuke Konishi <[email protected]>
Cc: Will Deacon <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
fs/f2fs/gc.c
include/linux/idr.h
include/linux/radix-tree.h
include/linux/xarray.h [new file with mode: 0644]
kernel/pid.c
tools/include/linux/spinlock.h