Whamcloud - gitweb
LU-12923 lustre: Replace CLASSERT() with BUILD_BUG_ON() 11/37111/5
authorArshad Hussain <arshad.super@gmail.com>
Sun, 29 Dec 2019 08:34:31 +0000 (14:04 +0530)
committerOleg Drokin <green@whamcloud.com>
Fri, 10 Jan 2020 07:42:43 +0000 (07:42 +0000)
This patch replaces remaining CLASSERT() with kernel defined
BUILD_BUG_ON()

Test-Parameters: trivial
Signed-off-by: Arshad Hussain <arshad.super@gmail.com>
Change-Id: Ie23846f8d67cac1872bda9c7e20fe9bc888bf365
Reviewed-on: https://review.whamcloud.com/37111
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/include/lu_object.h
lustre/include/lustre_net.h
lustre/mdd/mdd_object.c
lustre/osd-ldiskfs/osd_iam.h
lustre/osd-zfs/osd_index.c
lustre/ptlrpc/nodemap_storage.c

index 80fa26f..6b7f495 100644 (file)
@@ -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)                                \
index a758cb1..1c7072c 100644 (file)
@@ -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;
index 0613c79..29af1ed 100644 (file)
@@ -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
index 23cd286..afeb8be 100644 (file)
@@ -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 */
index c4e397b..ec95d03 100644 (file)
@@ -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 .
index ea72c87..6951db0 100644 (file)
@@ -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);