From: James Simmons Date: Sat, 17 Aug 2019 14:47:42 +0000 (-0400) Subject: LU-9859 mdt: replace CLASSERT with BUILD_BUG_ON X-Git-Tag: 2.12.58~34 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=8f65b07e90be21242cb49493421dcd3081f6fbac LU-9859 mdt: replace CLASSERT with BUILD_BUG_ON Replace the lustre specific CLASSERT in mdt layer with what the linux kernel provides. Note the logic is reverse. Test-Parameters: trivial Change-Id: I1e4d75a6643204c55c888a5c2e95a8b12251f5b7 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/32219 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Ben Evans Reviewed-by: Shaun Tancheff Reviewed-by: Neil Brown Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdt/mdt_coordinator.c b/lustre/mdt/mdt_coordinator.c index 25dddf5..723924d 100644 --- a/lustre/mdt/mdt_coordinator.c +++ b/lustre/mdt/mdt_coordinator.c @@ -1091,7 +1091,7 @@ static int mdt_hsm_cdt_start(struct mdt_device *mdt) RETURN(-EALREADY); } - CLASSERT(1 << (CDT_POLICY_SHIFT_COUNT - 1) == CDT_POLICY_LAST); + BUILD_BUG_ON(BIT(CDT_POLICY_SHIFT_COUNT - 1) != CDT_POLICY_LAST); cdt->cdt_policy = CDT_DEFAULT_POLICY; /* just need to be larger than previous one */ diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 25ab57a..b3f29e1 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -1107,8 +1107,8 @@ int mdt_attr_get_complex(struct mdt_thread_info *info, if (need & MA_HSM && S_ISREG(mode)) { buf->lb_buf = info->mti_xattr_buf; buf->lb_len = sizeof(info->mti_xattr_buf); - CLASSERT(sizeof(struct hsm_attrs) <= - sizeof(info->mti_xattr_buf)); + BUILD_BUG_ON(sizeof(struct hsm_attrs) > + sizeof(info->mti_xattr_buf)); rc2 = mo_xattr_get(info->mti_env, next, buf, XATTR_NAME_HSM); rc2 = lustre_buf2hsm(info->mti_xattr_buf, rc2, &ma->ma_hsm); if (rc2 == 0) @@ -7061,10 +7061,10 @@ static int __init mdt_init(void) { int rc; - CLASSERT(sizeof("0x0123456789ABCDEF:0x01234567:0x01234567") == - FID_NOBRACE_LEN + 1); - CLASSERT(sizeof("[0x0123456789ABCDEF:0x01234567:0x01234567]") == - FID_LEN + 1); + BUILD_BUG_ON(sizeof("0x0123456789ABCDEF:0x01234567:0x01234567") != + FID_NOBRACE_LEN + 1); + BUILD_BUG_ON(sizeof("[0x0123456789ABCDEF:0x01234567:0x01234567]") != + FID_LEN + 1); rc = lu_kmem_init(mdt_caches); if (rc) return rc; diff --git a/lustre/mdt/mdt_hsm.c b/lustre/mdt/mdt_hsm.c index 1effc5a..92b842a 100644 --- a/lustre/mdt/mdt_hsm.c +++ b/lustre/mdt/mdt_hsm.c @@ -66,7 +66,7 @@ int mdt_hsm_attr_set(struct mdt_thread_info *info, struct mdt_object *obj, ENTRY; attrs = (struct hsm_attrs *)info->mti_xattr_buf; - CLASSERT(sizeof(info->mti_xattr_buf) >= sizeof(*attrs)); + BUILD_BUG_ON(sizeof(info->mti_xattr_buf) < sizeof(*attrs)); /* pack HSM attributes */ lustre_hsm2buf(info->mti_xattr_buf, mh); diff --git a/lustre/mdt/mdt_io.c b/lustre/mdt/mdt_io.c index 3dcc8a8..b4b6802 100644 --- a/lustre/mdt/mdt_io.c +++ b/lustre/mdt/mdt_io.c @@ -879,7 +879,7 @@ int mdt_punch_hdl(struct tgt_session_info *tsi) ENTRY; /* check that we do support OBD_CONNECT_TRUNCLOCK. */ - CLASSERT(OST_CONNECT_SUPPORTED & OBD_CONNECT_TRUNCLOCK); + BUILD_BUG_ON(!(OST_CONNECT_SUPPORTED & OBD_CONNECT_TRUNCLOCK)); if ((oa->o_valid & (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS)) != (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS)) diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index a09997d..d8fd04c 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -1098,7 +1098,7 @@ static int mdt_setattr_unpack_rec(struct mdt_thread_info *info) ENTRY; - CLASSERT(sizeof(*rec) == sizeof(struct mdt_rec_reint)); + BUILD_BUG_ON(sizeof(*rec) != sizeof(struct mdt_rec_reint)); rec = req_capsule_client_get(pill, &RMF_REC_REINT); if (rec == NULL) RETURN(-EFAULT); @@ -1259,7 +1259,7 @@ static int mdt_create_unpack(struct mdt_thread_info *info) ENTRY; - CLASSERT(sizeof(*rec) == sizeof(struct mdt_rec_reint)); + BUILD_BUG_ON(sizeof(*rec) != sizeof(struct mdt_rec_reint)); rec = req_capsule_client_get(pill, &RMF_REC_REINT); if (rec == NULL) RETURN(-EFAULT); @@ -1338,7 +1338,7 @@ static int mdt_link_unpack(struct mdt_thread_info *info) ENTRY; - CLASSERT(sizeof(*rec) == sizeof(struct mdt_rec_reint)); + BUILD_BUG_ON(sizeof(*rec) != sizeof(struct mdt_rec_reint)); rec = req_capsule_client_get(pill, &RMF_REC_REINT); if (rec == NULL) RETURN(-EFAULT); @@ -1382,7 +1382,7 @@ static int mdt_unlink_unpack(struct mdt_thread_info *info) ENTRY; - CLASSERT(sizeof(*rec) == sizeof(struct mdt_rec_reint)); + BUILD_BUG_ON(sizeof(*rec) != sizeof(struct mdt_rec_reint)); rec = req_capsule_client_get(pill, &RMF_REC_REINT); if (rec == NULL) RETURN(-EFAULT); @@ -1435,7 +1435,7 @@ static int mdt_rename_unpack(struct mdt_thread_info *info) ENTRY; - CLASSERT(sizeof(*rec) == sizeof(struct mdt_rec_reint)); + BUILD_BUG_ON(sizeof(*rec) != sizeof(struct mdt_rec_reint)); rec = req_capsule_client_get(pill, &RMF_REC_REINT); if (rec == NULL) RETURN(-EFAULT); @@ -1488,7 +1488,7 @@ static int mdt_migrate_unpack(struct mdt_thread_info *info) ENTRY; - CLASSERT(sizeof(*rec) == sizeof(struct mdt_rec_reint)); + BUILD_BUG_ON(sizeof(*rec) != sizeof(struct mdt_rec_reint)); rec = req_capsule_client_get(pill, &RMF_REC_REINT); if (rec == NULL) RETURN(-EFAULT); @@ -1579,7 +1579,8 @@ static int mdt_open_unpack(struct mdt_thread_info *info) int rc; ENTRY; - CLASSERT(sizeof(struct mdt_rec_create) == sizeof(struct mdt_rec_reint)); + BUILD_BUG_ON(sizeof(struct mdt_rec_create) != + sizeof(struct mdt_rec_reint)); rec = req_capsule_client_get(pill, &RMF_REC_REINT); if (rec == NULL) RETURN(-EFAULT); @@ -1662,9 +1663,8 @@ static int mdt_setxattr_unpack(struct mdt_thread_info *info) ENTRY; - CLASSERT(sizeof(struct mdt_rec_setxattr) == - sizeof(struct mdt_rec_reint)); - + BUILD_BUG_ON(sizeof(struct mdt_rec_setxattr) != + sizeof(struct mdt_rec_reint)); rec = req_capsule_client_get(pill, &RMF_REC_REINT); if (rec == NULL) RETURN(-EFAULT); @@ -1725,7 +1725,7 @@ static int mdt_resync_unpack(struct mdt_thread_info *info) struct mdt_rec_resync *rec; ENTRY; - CLASSERT(sizeof(*rec) == sizeof(struct mdt_rec_reint)); + BUILD_BUG_ON(sizeof(*rec) != sizeof(struct mdt_rec_reint)); rec = req_capsule_client_get(pill, &RMF_REC_REINT); if (rec == NULL) RETURN(-EFAULT); diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 28ad9ab..8ef5b2c 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -1847,8 +1847,8 @@ static int mdt_hsm_release(struct mdt_thread_info *info, struct mdt_object *o, ma->ma_hsm.mh_flags = HS_ARCHIVED | HS_EXISTS; } else { /* Set up HSM attribte for PCC archived object */ - CLASSERT(sizeof(struct hsm_attrs) <= - sizeof(info->mti_xattr_buf)); + BUILD_BUG_ON(sizeof(struct hsm_attrs) > + sizeof(info->mti_xattr_buf)); buf = &info->mti_buf; buf->lb_buf = info->mti_xattr_buf; buf->lb_len = sizeof(struct hsm_attrs); @@ -1947,7 +1947,7 @@ static int mdt_hsm_release(struct mdt_thread_info *info, struct mdt_object *o, } /* Set up HSM attribute for orphan object */ - CLASSERT(sizeof(struct hsm_attrs) <= sizeof(info->mti_xattr_buf)); + BUILD_BUG_ON(sizeof(struct hsm_attrs) > sizeof(info->mti_xattr_buf)); buf = &info->mti_buf; buf->lb_buf = info->mti_xattr_buf; buf->lb_len = sizeof(struct hsm_attrs); diff --git a/lustre/mdt/mdt_som.c b/lustre/mdt/mdt_som.c index 3eebe03..fa3f033 100644 --- a/lustre/mdt/mdt_som.c +++ b/lustre/mdt/mdt_som.c @@ -75,8 +75,8 @@ int mdt_get_som(struct mdt_thread_info *info, struct mdt_object *obj, buf->lb_buf = info->mti_xattr_buf; buf->lb_len = sizeof(info->mti_xattr_buf); - CLASSERT(sizeof(struct lustre_som_attrs) <= - sizeof(info->mti_xattr_buf)); + BUILD_BUG_ON(sizeof(struct lustre_som_attrs) > + sizeof(info->mti_xattr_buf)); rc = mo_xattr_get(info->mti_env, mdt_object_child(obj), buf, XATTR_NAME_SOM); rc = lustre_buf2som(info->mti_xattr_buf, rc, &ma->ma_som); @@ -126,7 +126,7 @@ int mdt_set_som(struct mdt_thread_info *info, struct mdt_object *obj, PFID(mdt_object_fid(obj)), size, blocks, flag); som = (struct lustre_som_attrs *)info->mti_xattr_buf; - CLASSERT(sizeof(info->mti_xattr_buf) >= sizeof(*som)); + BUILD_BUG_ON(sizeof(info->mti_xattr_buf) < sizeof(*som)); som->lsa_valid = flag; som->lsa_size = size;