From 9159b2d1393d5a1de1e601d2b0e1978668e5ec13 Mon Sep 17 00:00:00 2001 From: frank zago Date: Tue, 29 Jul 2014 22:11:04 -0500 Subject: [PATCH] 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 --- libcfs/include/libcfs/libcfs.h | 11 +++++++++++ 1 file changed, 11 insertions(+) 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. -- 1.8.3.1