Whamcloud - gitweb
LU-4801 ldlm: discard l_lock from struct ldlm_lock.
This spinlock (l_lock) is only used to stablise the l_resource
pointer while taking a spinlock on the resource.
This is not necessary - it is sufficient to take the resource
spinlock, and then check if l_resource has changed or not. If it
hasn't then it cannot change until the resource spinlock is dropped.
We must ensure this is safe even if the resource is freed before
lock_res_and_lock() managed to get the lock. To do this we use
call_rcu() to free the resource. This means that if we find a
resource after taking the RCU read lock, then it is always safe to
take and then drop the spinlock. After taking the spinlock, we can
check if it is more generally safe to use.
Discarding l_lock shrinks 'struct ldlm_lock' which helps save memory.
Note that it would be cleaner to use SLAB_TYPESAFE_BY_RCU instead of
call_rcu(), but this is not correctly supported on all platforms that
lustre supports. To simplify a transition to SLAB_TYPESAFE_BY_RCU
once that is usable, an 'init_once' function is used to initialize the
spinlock as would be needed in that case.
Signed-off-by: Mr NeilBrown <neilb@suse.com>
Change-Id: Ief5af0b3bc9bed0cd32673e4d62ce51c83846418
Reviewed-on: https://review.whamcloud.com/39811
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>