From: frank zago Date: Wed, 30 Jul 2014 03:11:04 +0000 (-0500) Subject: LU-5396: define __must_hold() for older kernels X-Git-Tag: 2.6.52~18 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=9159b2d1393d5a1de1e601d2b0e1978668e5ec13;hp=07bd49670282fcd75f1a937b621aa3c11db88407;p=fs%2Flustre-release.git LU-5396: define __must_hold() for older kernels Backport of sparse macro __must_hold(), introduced in linux kernel commit 8529091e: linux/compiler.h has macros to denote functions that acquire or release locks, but not to denote functions called with a lock held that return with the lock still held. Add a __must_hold macro to cover that case. Change-Id: Ic77304a5f78f1681cfc48a728a12759366bb2cb8 Signed-off-by: frank zago Reviewed-on: http://review.whamcloud.com/11294 Tested-by: Jenkins Reviewed-by: John L. Hammond Reviewed-by: Patrick Farrell Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/libcfs/include/libcfs/libcfs.h b/libcfs/include/libcfs/libcfs.h index 2fbab09..4d3122e 100644 --- a/libcfs/include/libcfs/libcfs.h +++ b/libcfs/include/libcfs/libcfs.h @@ -81,6 +81,17 @@ static inline int __is_po2(unsigned long long val) #define LOWEST_BIT_SET(x) ((x) & ~((x) - 1)) +/* Sparse annotations */ +#ifdef __KERNEL__ +# if !defined(__must_hold) +# ifdef __CHECKER__ +# define __must_hold(x) __attribute__((context(x, 1, 1))) +# else /* __CHECKER__ */ +# define __must_hold(x) +# endif /* !__CHECKER__ */ +# endif /* !__must_hold */ +#endif /* __KERNEL__ */ + /* * Lustre Error Checksum: calculates checksum * of Hex number by XORing each bit.