From f0fa794d0fc35be8fb0839731d122a73395f2a05 Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Sun, 29 Dec 2019 14:04:31 +0530 Subject: [PATCH] LU-12923 lustre: Replace CLASSERT() with BUILD_BUG_ON() This patch replaces remaining CLASSERT() with kernel defined BUILD_BUG_ON() Test-Parameters: trivial Signed-off-by: Arshad Hussain Change-Id: Ie23846f8d67cac1872bda9c7e20fe9bc888bf365 Reviewed-on: https://review.whamcloud.com/37111 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: Petros Koutoupis Tested-by: jenkins Tested-by: Maloo --- lustre/include/lu_object.h | 2 +- lustre/include/lustre_net.h | 18 +++++++++--------- lustre/mdd/mdd_object.c | 2 +- lustre/osd-ldiskfs/osd_iam.h | 4 +--- lustre/osd-zfs/osd_index.c | 6 +++--- lustre/ptlrpc/nodemap_storage.c | 2 +- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index 80fa26f..6b7f4955 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -1116,7 +1116,7 @@ struct lu_context_key { { \ type *value; \ \ - CLASSERT(PAGE_SIZE >= sizeof(*value)); \ + BUILD_BUG_ON(PAGE_SIZE < sizeof(*value)); \ \ OBD_ALLOC_PTR(value); \ if (value == NULL) \ diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index a758cb1..1c7072c 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -559,15 +559,15 @@ struct ptlrpc_client { #define REQ_MAX_ACK_LOCKS 8 union ptlrpc_async_args { - /** - * Scratchpad for passing args to completion interpreter. Users - * cast to the struct of their choosing, and CLASSERT that this is - * big enough. For _tons_ of context, OBD_ALLOC a struct and store - * a pointer to it here. The pointer_arg ensures this struct is at - * least big enough for that. - */ - void *pointer_arg[11]; - __u64 space[7]; + /** + * Scratchpad for passing args to completion interpreter. Users + * cast to the struct of their choosing, and BUILD_BUG_ON that this is + * big enough. For _tons_ of context, OBD_ALLOC a struct and store + * a pointer to it here. The pointer_arg ensures this struct is at + * least big enough for that. + */ + void *pointer_arg[11]; + __u64 space[7]; }; struct ptlrpc_request_set; diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index 0613c79..29af1ed 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -2323,7 +2323,7 @@ static int mdd_swap_layouts(const struct lu_env *env, struct md_object *obj1, ENTRY; - CLASSERT(ARRAY_SIZE(info->mti_buf) >= 4); + BUILD_BUG_ON(ARRAY_SIZE(info->mti_buf) < 4); memset(info->mti_buf, 0, sizeof(info->mti_buf)); /* we have to sort the 2 obj, so locking will always diff --git a/lustre/osd-ldiskfs/osd_iam.h b/lustre/osd-ldiskfs/osd_iam.h index 23cd286..afeb8be 100644 --- a/lustre/osd-ldiskfs/osd_iam.h +++ b/lustre/osd-ldiskfs/osd_iam.h @@ -46,9 +46,7 @@ /* * osd_iam.h */ -#ifndef CLASSERT -#define CLASSERT(cond) do {switch(42) {case (cond): case 0: break;}} while (0) -#endif + /* implication */ #define ergo(a, b) (!(a) || (b)) /* logical equivalence */ diff --git a/lustre/osd-zfs/osd_index.c b/lustre/osd-zfs/osd_index.c index c4e397b..ec95d03 100644 --- a/lustre/osd-zfs/osd_index.c +++ b/lustre/osd-zfs/osd_index.c @@ -1029,8 +1029,8 @@ static int osd_dir_insert(const struct lu_env *env, struct dt_object *dt, } } - CLASSERT(sizeof(zde->lzd_reg) == 8); - CLASSERT(sizeof(*zde) % 8 == 0); + BUILD_BUG_ON(sizeof(zde->lzd_reg) != 8); + BUILD_BUG_ON(sizeof(*zde) % 8 != 0); memset(&zde->lzd_reg, 0, sizeof(zde->lzd_reg)); zde->lzd_reg.zde_type = IFTODT(rec1->rec_type & S_IFMT); @@ -1330,7 +1330,7 @@ static int osd_dir_it_next(const struct lu_env *env, struct dt_it *di) ENTRY; /* temp. storage should be enough for any key supported by ZFS */ - CLASSERT(sizeof(za->za_name) <= sizeof(it->ozi_name)); + BUILD_BUG_ON(sizeof(za->za_name) > sizeof(it->ozi_name)); /* * the first ->next() moves the cursor to . diff --git a/lustre/ptlrpc/nodemap_storage.c b/lustre/ptlrpc/nodemap_storage.c index ea72c87..6951db0 100644 --- a/lustre/ptlrpc/nodemap_storage.c +++ b/lustre/ptlrpc/nodemap_storage.c @@ -249,7 +249,7 @@ static int nodemap_idx_insert(const struct lu_env *env, struct dt_device *dev = lu2dt_dev(idx->do_lu.lo_dev); int rc; - CLASSERT(sizeof(union nodemap_rec) == 32); + BUILD_BUG_ON(sizeof(union nodemap_rec) != 32); th = dt_trans_create(env, dev); -- 1.8.3.1