Whamcloud - gitweb
LU-5396: define __must_hold() for older kernels 94/11294/12
authorfrank zago <fzago@cray.com>
Wed, 30 Jul 2014 03:11:04 +0000 (22:11 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 27 Aug 2014 15:59:31 +0000 (15:59 +0000)
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 <fzago@cray.com>
Reviewed-on: http://review.whamcloud.com/11294
Tested-by: Jenkins
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Patrick Farrell <paf@cray.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/include/libcfs/libcfs.h

index 2fbab09..4d3122e 100644 (file)
@@ -81,6 +81,17 @@ static inline int __is_po2(unsigned long long val)
 
 #define LOWEST_BIT_SET(x)       ((x) & ~((x) - 1))
 
 
 #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.
 /*
  * Lustre Error Checksum: calculates checksum
  * of Hex number by XORing each bit.