From 20683c0d6c3e7d04293238d0a68e862c9bc46d40 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Wed, 10 May 2023 09:15:34 -0400 Subject: [PATCH] LU-9859 libcfs: use round_up directly The macro cfs_size_round() is just round_up(val, 8). Replace cfs_size_round() with the Linux standard round_up(). Change-Id: I5a5ba4e663672c0b0bba5c99be9e0bece2dc3c87 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50545 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Arshad Hussain Reviewed-by: Andreas Dilger Reviewed-by: Neil Brown Reviewed-by: Oleg Drokin --- contrib/scripts/spelling.txt | 1 + libcfs/include/libcfs/libcfs_private.h | 2 +- libcfs/libcfs/module.c | 2 +- lustre/include/cl_object.h | 2 +- lustre/include/lustre_log.h | 2 +- lustre/include/lustre_update.h | 14 +++++++------- lustre/include/obj_update.h | 8 ++++---- lustre/llite/vvp_object.c | 2 +- lustre/mdc/mdc_request.c | 8 ++++---- lustre/mdt/mdt_coordinator.c | 12 ++++++------ lustre/mdt/mdt_handler.c | 4 ++-- lustre/mdt/mdt_hsm.c | 4 ++-- lustre/mgs/mgs_llog.c | 8 ++++---- lustre/obdclass/class_obd.c | 6 +++--- lustre/obdclass/llog.c | 2 +- lustre/obdclass/llog_ioctl.c | 2 +- lustre/obdecho/echo_client.c | 2 +- lustre/osc/osc_cache.c | 2 +- lustre/osd-ldiskfs/osd_handler.c | 6 +++--- lustre/osd-ldiskfs/osd_scrub.c | 4 ++-- lustre/ptlrpc/batch.c | 7 ++----- lustre/ptlrpc/layout.c | 9 +++++---- lustre/ptlrpc/pack_generic.c | 15 +++++++-------- lustre/target/out_handler.c | 4 ++-- lustre/target/out_lib.c | 2 +- lustre/target/update_records.c | 8 ++++---- lustre/target/update_trans.c | 8 +++----- 27 files changed, 71 insertions(+), 75 deletions(-) diff --git a/contrib/scripts/spelling.txt b/contrib/scripts/spelling.txt index 26a1249..5209c82 100644 --- a/contrib/scripts/spelling.txt +++ b/contrib/scripts/spelling.txt @@ -86,6 +86,7 @@ cfs_proc_dir_entry_t||struct proc_dir_entry cfs_rcu_head_t||struct rcu_head cfs_rand||get_random_u32 cfs_srand||add_device_randomness +cfs_size_round||round_up cfs_trimwhite||strim cfs_time_add_64||ktime_add cfs_time_after||time_after diff --git a/libcfs/include/libcfs/libcfs_private.h b/libcfs/include/libcfs/libcfs_private.h index c9f3b4b..fb736a3 100644 --- a/libcfs/include/libcfs/libcfs_private.h +++ b/libcfs/include/libcfs/libcfs_private.h @@ -292,7 +292,7 @@ do { \ #ifndef HAVE_CFS_SIZE_ROUND static inline size_t cfs_size_round(size_t val) { - return (val + 7) & (~0x7); + return round_up(val, 8); } #define HAVE_CFS_SIZE_ROUND #endif diff --git a/libcfs/libcfs/module.c b/libcfs/libcfs/module.c index 56df906..e764c9f 100644 --- a/libcfs/libcfs/module.c +++ b/libcfs/libcfs/module.c @@ -130,7 +130,7 @@ int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data) if (data->ioc_inllen2 != 0) data->ioc_inlbuf2 = &data->ioc_bulk[0] + - cfs_size_round(data->ioc_inllen1); + round_up(data->ioc_inllen1, 8); RETURN(0); } diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index b4c138f..cad4702 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -2143,7 +2143,7 @@ static inline int cl_object_same(struct cl_object *o0, struct cl_object *o1) static inline void cl_object_page_init(struct cl_object *clob, int size) { clob->co_slice_off = cl_object_header(clob)->coh_page_bufsize; - cl_object_header(clob)->coh_page_bufsize += cfs_size_round(size); + cl_object_header(clob)->coh_page_bufsize += round_up(size, 8); WARN_ON(cl_object_header(clob)->coh_page_bufsize > 512); } diff --git a/lustre/include/lustre_log.h b/lustre/include/lustre_log.h index 52ad713..87b4ec9 100644 --- a/lustre/include/lustre_log.h +++ b/lustre/include/lustre_log.h @@ -378,7 +378,7 @@ static inline int llog_handle2ops(struct llog_handle *loghandle, static inline int llog_data_len(int len) { - return cfs_size_round(len); + return round_up(len, 8); } static inline int llog_get_size(struct llog_handle *loghandle) diff --git a/lustre/include/lustre_update.h b/lustre/include/lustre_update.h index 78cd3d4..23b309c 100644 --- a/lustre/include/lustre_update.h +++ b/lustre/include/lustre_update.h @@ -141,8 +141,7 @@ update_param_next_param(const struct update_param *param) static inline size_t __update_records_size(size_t raw_size) { - return cfs_size_round(offsetof(struct update_records, ur_ops) + - raw_size); + return round_up(offsetof(struct update_records, ur_ops) + raw_size, 8); } static inline size_t @@ -167,8 +166,8 @@ update_records_size(const struct update_records *record) static inline size_t __llog_update_record_size(size_t records_size) { - return cfs_size_round(sizeof(struct llog_rec_hdr) + records_size + - sizeof(struct llog_rec_tail)); + return round_up(sizeof(struct llog_rec_hdr) + records_size + + sizeof(struct llog_rec_tail), 8); } static inline size_t @@ -252,8 +251,9 @@ object_update_result_insert(struct object_update_reply *reply, update_result->our_datalen = data_len; } - reply->ourp_lens[index] = cfs_size_round(data_len + - sizeof(struct object_update_result)); + reply->ourp_lens[index] = round_up(data_len + + sizeof(struct object_update_result), + 8); } static inline int @@ -267,7 +267,7 @@ object_update_result_data_get(const struct object_update_reply *reply, LASSERT(lbuf != NULL); update_result = object_update_result_get(reply, index, &size); if (update_result == NULL || - size < cfs_size_round(sizeof(struct object_update_reply)) || + size < round_up(sizeof(struct object_update_reply), 8) || update_result->our_datalen > size) RETURN(-EFAULT); diff --git a/lustre/include/obj_update.h b/lustre/include/obj_update.h index fc67d9e..1b7a5b3 100644 --- a/lustre/include/obj_update.h +++ b/lustre/include/obj_update.h @@ -36,7 +36,7 @@ static inline size_t object_update_param_size(const struct object_update_param *param) { - return cfs_size_round(sizeof(*param) + param->oup_len); + return round_up(sizeof(*param) + param->oup_len, 8); } static inline size_t @@ -98,13 +98,13 @@ object_update_result_get(const struct object_update_reply *reply, return NULL; ptr = (char *)reply + - cfs_size_round(offsetof(struct object_update_reply, - ourp_lens[count])); + round_up(offsetof(struct object_update_reply, + ourp_lens[count]), 8); for (i = 0; i < index; i++) { if (reply->ourp_lens[i] == 0) return NULL; - ptr += cfs_size_round(reply->ourp_lens[i]); + ptr += round_up(reply->ourp_lens[i], 8); } if (size != NULL) diff --git a/lustre/llite/vvp_object.c b/lustre/llite/vvp_object.c index 2e890ad..d96146d 100644 --- a/lustre/llite/vvp_object.c +++ b/lustre/llite/vvp_object.c @@ -324,7 +324,7 @@ struct lu_object *vvp_object_alloc(const struct lu_env *env, obj = &vob->vob_cl.co_lu; hdr = &vob->vob_header; cl_object_header_init(hdr); - hdr->coh_page_bufsize = cfs_size_round(sizeof(struct cl_page)); + hdr->coh_page_bufsize = round_up(sizeof(struct cl_page), 8); lu_object_init(obj, &hdr->coh_lu, dev); lu_object_add_top(&hdr->coh_lu, obj); diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 3f70814..f344818 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1713,14 +1713,14 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf) RETURN(-EOVERFLOW); /* Key is KEY_FID2PATH + getinfo_fid2path description */ - keylen = cfs_size_round(sizeof(KEY_FID2PATH) + sizeof(*gf) + - sizeof(struct lu_fid)); + keylen = round_up(sizeof(KEY_FID2PATH) + sizeof(*gf) + + sizeof(struct lu_fid), 8); OBD_ALLOC(key, keylen); if (key == NULL) RETURN(-ENOMEM); memcpy(key, KEY_FID2PATH, sizeof(KEY_FID2PATH)); - memcpy(key + cfs_size_round(sizeof(KEY_FID2PATH)), gf, sizeof(*gf)); - memcpy(key + cfs_size_round(sizeof(KEY_FID2PATH)) + sizeof(*gf), + memcpy(key + round_up(sizeof(KEY_FID2PATH), 8), gf, sizeof(*gf)); + memcpy(key + round_up(sizeof(KEY_FID2PATH), 8) + sizeof(*gf), gf->gf_u.gf_root_fid, sizeof(struct lu_fid)); CDEBUG(D_IOCTL, "path get "DFID" from %llu #%d\n", PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno); diff --git a/lustre/mdt/mdt_coordinator.c b/lustre/mdt/mdt_coordinator.c index 54084a1..029903e 100644 --- a/lustre/mdt/mdt_coordinator.c +++ b/lustre/mdt/mdt_coordinator.c @@ -182,7 +182,7 @@ static int mdt_cdt_waiting_cb(const struct lu_env *env, RETURN(hsd->hsd_housekeeping ? 0 : LLOG_PROC_BREAK); } - hai_size = cfs_size_round(larr->arr_hai.hai_len); + hai_size = round_up(larr->arr_hai.hai_len, 8); archive_id = larr->arr_archive_id; /* Can we add this action to one of the existing HALs in hsd. */ @@ -220,7 +220,7 @@ static int mdt_cdt_waiting_cb(const struct lu_env *env, for (i = 0; i < request->hal->hal_count; i++) hai = hai_next(hai); request->hal_used_sz -= - cfs_size_round(hai->hai_len); + round_up(hai->hai_len, 8); hsd->hsd_action_count--; } while (request->hal_used_sz + hai_size > LDLM_MAXREQSIZE); @@ -242,6 +242,7 @@ static int mdt_cdt_waiting_cb(const struct lu_env *env, } if (!request) { + size_t count = round_up(MTI_NAME_MAXLEN + 1, 8) + 2 * hai_size; struct hsm_action_list *hal; LASSERT(hsd->hsd_request_count < hsd->hsd_request_len); @@ -249,8 +250,7 @@ static int mdt_cdt_waiting_cb(const struct lu_env *env, /* allocates hai vector size just needs to be large * enough */ - request->hal_sz = sizeof(*request->hal) + - cfs_size_round(MTI_NAME_MAXLEN + 1) + 2 * hai_size; + request->hal_sz = sizeof(*request->hal) + count; OBD_ALLOC_LARGE(hal, request->hal_sz); if (!hal) RETURN(-ENOMEM); @@ -1859,8 +1859,8 @@ static int hsm_cancel_all_actions(struct mdt_device *mdt) } /* needed size */ - hal_len = sizeof(*hal) + cfs_size_round(MTI_NAME_MAXLEN + 1) + - cfs_size_round(car->car_hai->hai_len); + hal_len = sizeof(*hal) + round_up(MTI_NAME_MAXLEN + 1, 8) + + round_up(car->car_hai->hai_len, 8); if (hal_len > hal_sz && hal_sz > 0) { /* not enough room, free old buffer */ diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index e31fee0..fe7f8fc 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -7564,7 +7564,7 @@ static int mdt_rpc_fid2path(struct mdt_thread_info *info, void *key, int keylen, struct lu_fid *root_fid = NULL; int rc = 0; - fpin = key + cfs_size_round(sizeof(KEY_FID2PATH)); + fpin = key + round_up(sizeof(KEY_FID2PATH), 8); fpout = val; if (req_capsule_req_need_swab(info->mti_pill)) @@ -7574,7 +7574,7 @@ static int mdt_rpc_fid2path(struct mdt_thread_info *info, void *key, int keylen, if (fpout->gf_pathlen != vallen - sizeof(*fpin)) RETURN(-EINVAL); - if (keylen >= cfs_size_round(sizeof(KEY_FID2PATH)) + sizeof(*fpin) + + if (keylen >= round_up(sizeof(KEY_FID2PATH), 8) + sizeof(*fpin) + sizeof(struct lu_fid)) { /* client sent its root FID, which is normally fileset FID */ root_fid = fpin->gf_u.gf_root_fid; diff --git a/lustre/mdt/mdt_hsm.c b/lustre/mdt/mdt_hsm.c index 56d9a3a..234679d 100644 --- a/lustre/mdt/mdt_hsm.c +++ b/lustre/mdt/mdt_hsm.c @@ -563,8 +563,8 @@ int mdt_hsm_request(struct tgt_session_info *tsi) GOTO(out_ucred, rc = -EINVAL); } - hal_size = sizeof(*hal) + cfs_size_round(MTI_NAME_MAXLEN) /* fsname */ + - (sizeof(*hai) + cfs_size_round(hr->hr_data_len)) * + hal_size = sizeof(*hal) + round_up(MTI_NAME_MAXLEN, 8) /* fsname */ + + (sizeof(*hai) + round_up(hr->hr_data_len, 8)) * hr->hr_itemcount; MDT_HSM_ALLOC(hal, hal_size); diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index de8dfc5..3d9a9d2 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -4684,7 +4684,7 @@ static int mgs_lcfg_fork_handler(const struct lu_env *env, memcpy(n_buf + n_namelen, o_buf + o_namelen, o_buflen - o_namelen); lustre_cfg_bufs_reset(n_bufs, n_buf); - n_buf += cfs_size_round(o_buflen + diff); + n_buf += round_up(o_buflen + diff, 8); } else { lustre_cfg_bufs_reset(n_bufs, o_buflen != 0 ? o_buf : NULL); } @@ -4752,7 +4752,7 @@ static int mgs_lcfg_fork_handler(const struct lu_env *env, memcpy(n_buf + n_namelen, o_buf + o_namelen, o_buflen - o_namelen); lustre_cfg_bufs_set(n_bufs, 1, n_buf, o_buflen + diff); - n_buf += cfs_size_round(o_buflen + diff); + n_buf += round_up(o_buflen + diff, 8); /* buf[2] is the pool name, reuse it directly */ lustre_cfg_bufs_set(n_bufs, 2, lustre_cfg_buf(o_lcfg, 2), @@ -4841,14 +4841,14 @@ static int mgs_lcfg_fork_handler(const struct lu_env *env, if (o_buflen == o_namelen) { lustre_cfg_bufs_set(n_bufs, i, n_buf, n_namelen); - n_buf += cfs_size_round(n_namelen); + n_buf += round_up(n_namelen, 8); continue; } memcpy(n_buf + n_namelen, o_buf + o_namelen, o_buflen - o_namelen); lustre_cfg_bufs_set(n_bufs, i, n_buf, o_buflen + diff); - n_buf += cfs_size_round(o_buflen + diff); + n_buf += round_up(o_buflen + diff, 8); } break; } diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 3cc1d37..44a824a 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -305,17 +305,17 @@ int obd_ioctl_getdata(struct obd_ioctl_data **datap, int *len, void __user *arg) if (data->ioc_inllen1) { data->ioc_inlbuf1 = &data->ioc_bulk[0]; - offset += cfs_size_round(data->ioc_inllen1); + offset += round_up(data->ioc_inllen1, 8); } if (data->ioc_inllen2) { data->ioc_inlbuf2 = &data->ioc_bulk[0] + offset; - offset += cfs_size_round(data->ioc_inllen2); + offset += round_up(data->ioc_inllen2, 8); } if (data->ioc_inllen3) { data->ioc_inlbuf3 = &data->ioc_bulk[0] + offset; - offset += cfs_size_round(data->ioc_inllen3); + offset += round_up(data->ioc_inllen3, 8); } if (data->ioc_inllen4) diff --git a/lustre/obdclass/llog.c b/lustre/obdclass/llog.c index 634903b..f8197e5 100644 --- a/lustre/obdclass/llog.c +++ b/lustre/obdclass/llog.c @@ -1182,7 +1182,7 @@ int llog_write_rec(const struct lu_env *env, struct llog_handle *handle, RETURN(-EOPNOTSUPP); buflen = rec->lrh_len; - LASSERT(cfs_size_round(buflen) == buflen); + LASSERT(round_up(buflen, 8) == buflen); old_cred = llog_raise_resource(); rc = lop->lop_write_rec(env, handle, rec, logcookies, idx, th); diff --git a/lustre/obdclass/llog_ioctl.c b/lustre/obdclass/llog_ioctl.c index e8ef97b..070b221 100644 --- a/lustre/obdclass/llog_ioctl.c +++ b/lustre/obdclass/llog_ioctl.c @@ -392,7 +392,7 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd, case OBD_IOC_LLOG_INFO: { int l; int remains = data->ioc_inllen2 + - cfs_size_round(data->ioc_inllen1); + round_up(data->ioc_inllen1, 8); char *out = data->ioc_bulk; l = snprintf(out, remains, diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 16075ba..b4eebe1 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -371,7 +371,7 @@ static struct lu_object *echo_object_alloc(const struct lu_env *env, obj = &echo_obj2cl(eco)->co_lu; cl_object_header_init(hdr); - hdr->coh_page_bufsize = cfs_size_round(sizeof(struct cl_page)); + hdr->coh_page_bufsize = round_up(sizeof(struct cl_page), 8); lu_object_init(obj, &hdr->coh_lu, dev); lu_object_add_top(&hdr->coh_lu, obj); diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c index 4de0298..90be051 100644 --- a/lustre/osc/osc_cache.c +++ b/lustre/osc/osc_cache.c @@ -2236,7 +2236,7 @@ int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops, ENTRY; if (!page) - return cfs_size_round(sizeof(*oap)); + return round_up(sizeof(*oap), 8); oap->oap_obj = osc; oap->oap_page = page->cp_vmpage; diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index efb68c8..c725934 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -7109,7 +7109,7 @@ static int osd_ldiskfs_filldir(void *ctx, ent->oied_type = d_type; it->oie_rd_dirent++; - it->oie_dirent = (void *)ent + cfs_size_round(sizeof(*ent) + ent->oied_namelen); + it->oie_dirent = (void *)ent + round_up(sizeof(*ent) + ent->oied_namelen, 8); RETURN(0); } @@ -7200,8 +7200,8 @@ static int osd_it_ea_next(const struct lu_env *env, struct dt_it *di) if (it->oie_it_dirent < it->oie_rd_dirent) { it->oie_dirent = (void *)it->oie_dirent + - cfs_size_round(sizeof(struct osd_it_ea_dirent) + - it->oie_dirent->oied_namelen); + round_up(sizeof(struct osd_it_ea_dirent) + + it->oie_dirent->oied_namelen, 8); it->oie_it_dirent++; rc = 0; } else { diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index fa2c7d3..8a9f188 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -3100,8 +3100,8 @@ static int osd_scan_dir(const struct lu_env *env, struct osd_device *dev, cb(env, dev, inode, oie); oie->oie_dirent = (void *)oie->oie_dirent + - cfs_size_round(sizeof(struct osd_it_ea_dirent) + - oie->oie_dirent->oied_namelen); + round_up(sizeof(struct osd_it_ea_dirent) + + oie->oie_dirent->oied_namelen, 8); oie->oie_it_dirent++; if (oie->oie_it_dirent <= oie->oie_rd_dirent) diff --git a/lustre/ptlrpc/batch.c b/lustre/ptlrpc/batch.c index 59050ac..1684b31 100644 --- a/lustre/ptlrpc/batch.c +++ b/lustre/ptlrpc/batch.c @@ -134,16 +134,13 @@ static int batch_prep_update_req(struct batch_update_head *head, struct batch_update_buffer *buf; struct but_update_header *buh; struct but_update_buffer *bub; + int repsize = head->buh_repsize; int page_count = 0; int total = 0; - int repsize; int rc; ENTRY; - - repsize = head->buh_repsize + - cfs_size_round(offsetof(struct batch_update_reply, - burp_repmsg[0])); + repsize += round_up(offsetof(struct batch_update_reply, burp_repmsg[0]), 8); if (repsize < OUT_UPDATE_REPLY_SIZE) repsize = OUT_UPDATE_REPLY_SIZE; diff --git a/lustre/ptlrpc/layout.c b/lustre/ptlrpc/layout.c index 4fb7b28..cb8ee5f 100644 --- a/lustre/ptlrpc/layout.c +++ b/lustre/ptlrpc/layout.c @@ -2576,10 +2576,11 @@ __u32 req_capsule_fmt_size(__u32 magic, const struct req_format *fmt, if (size == 0) return size; - for (; i < fmt->rf_fields[loc].nr; ++i) - if (fmt->rf_fields[loc].d[i]->rmf_size != -1) - size += cfs_size_round(fmt->rf_fields[loc].d[i]-> - rmf_size); + for (; i < fmt->rf_fields[loc].nr; ++i) { + if (fmt->rf_fields[loc].d[i]->rmf_size == -1) + continue; + size += round_up(fmt->rf_fields[loc].d[i]->rmf_size, 8); + } return size; } EXPORT_SYMBOL(req_capsule_fmt_size); diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 20a742a..40fe614 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -53,8 +53,7 @@ static inline __u32 lustre_msg_hdr_size_v2(__u32 count) { - return cfs_size_round(offsetof(struct lustre_msg_v2, - lm_buflens[count])); + return round_up(offsetof(struct lustre_msg_v2, lm_buflens[count]), 8); } __u32 lustre_msg_hdr_size(__u32 magic, __u32 count) @@ -114,7 +113,7 @@ __u32 lustre_msg_size_v2(int count, __u32 *lengths) LASSERT(count > 0); size = lustre_msg_hdr_size_v2(count); for (i = 0; i < count; i++) - size += cfs_size_round(lengths[i]); + size += round_up(lengths[i], 8); return size; } @@ -189,7 +188,7 @@ void lustre_init_msg_v2(struct lustre_msg_v2 *msg, int count, __u32 *lens, if (tmp) memcpy(ptr, tmp, lens[i]); - ptr += cfs_size_round(lens[i]); + ptr += round_up(lens[i], 8); } } EXPORT_SYMBOL(lustre_init_msg_v2); @@ -410,7 +409,7 @@ void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, __u32 n, __u32 min_size) offset = lustre_msg_hdr_size_v2(bufcount); for (i = 0; i < n; i++) - offset += cfs_size_round(m->lm_buflens[i]); + offset += round_up(m->lm_buflens[i], 8); return (char *)m + offset; } @@ -444,7 +443,7 @@ static int lustre_shrink_msg_v2(struct lustre_msg_v2 *msg, __u32 segment, if (move_data && msg->lm_bufcount > segment + 1) { tail = lustre_msg_buf_v2(msg, segment + 1, 0); for (n = segment + 1; n < msg->lm_bufcount; n++) - tail_len += cfs_size_round(msg->lm_buflens[n]); + tail_len += round_up(msg->lm_buflens[n], 8); } msg->lm_buflens[segment] = newlen; @@ -503,7 +502,7 @@ static int lustre_grow_msg_v2(struct lustre_msg_v2 *msg, __u32 segment, if (msg->lm_bufcount > segment + 1) { tail = lustre_msg_buf_v2(msg, segment + 1, 0); for (n = segment + 1; n < msg->lm_bufcount; n++) - tail_len += cfs_size_round(msg->lm_buflens[n]); + tail_len += round_up(msg->lm_buflens[n], 8); } msg->lm_buflens[segment] = newlen; @@ -594,7 +593,7 @@ static int lustre_unpack_msg_v2(struct lustre_msg_v2 *m, int len) for (i = 0; i < m->lm_bufcount; i++) { if (swabbed) __swab32s(&m->lm_buflens[i]); - buflen = cfs_size_round(m->lm_buflens[i]); + buflen = round_up(m->lm_buflens[i], 8); if (buflen < 0 || buflen > PTLRPC_MAX_BUFLEN) { CERROR("buffer %d length %d is not valid\n", i, buflen); return -EINVAL; diff --git a/lustre/target/out_handler.c b/lustre/target/out_handler.c index 49accc7..c70eade 100644 --- a/lustre/target/out_handler.c +++ b/lustre/target/out_handler.c @@ -733,8 +733,8 @@ out_free: out: /* Insert read buffer */ update_result->our_rc = ptlrpc_status_hton(rc); - reply->ourp_lens[index] = cfs_size_round(update_result->our_datalen + - sizeof(*update_result)); + reply->ourp_lens[index] = round_up(update_result->our_datalen + + sizeof(*update_result), 8); RETURN(rc); } diff --git a/lustre/target/out_lib.c b/lustre/target/out_lib.c index 05987a7..a1f2966 100644 --- a/lustre/target/out_lib.c +++ b/lustre/target/out_lib.c @@ -109,7 +109,7 @@ int out_update_header_pack(const struct lu_env *env, /* Check whether the packing exceeding the maxima update length */ update_size = sizeof(*update); for (i = 0; i < param_count; i++) - update_size += cfs_size_round(sizeof(*param) + param_sizes[i]); + update_size += round_up(sizeof(*param) + param_sizes[i], 8); if (unlikely(update_size >= *max_update_size)) { *max_update_size = update_size; diff --git a/lustre/target/update_records.c b/lustre/target/update_records.c index 56a833c..cec4374 100644 --- a/lustre/target/update_records.c +++ b/lustre/target/update_records.c @@ -209,8 +209,8 @@ static int update_records_update_pack(const struct lu_env *env, for (i = 0; i < param_bufs_count; i++) total_param_sizes += - cfs_size_round(sizeof(struct object_update_param) + - param_sizes[i]); + round_up(sizeof(struct object_update_param) + + param_sizes[i], 8); /* Check whether the packing exceeding the maximum parameter size */ if (unlikely(*max_param_size < total_param_sizes)) { @@ -263,8 +263,8 @@ static size_t update_records_update_size(__u32 param_count, size_t *sizes) size = update_op_size(param_count); for (i = 0; i < param_count; i++) - size += cfs_size_round(sizeof(struct object_update_param) + - sizes[i]); + size += round_up(sizeof(struct object_update_param) + + sizes[i], 8); return size; } diff --git a/lustre/target/update_trans.c b/lustre/target/update_trans.c index 77f6c4a..22b49e7 100644 --- a/lustre/target/update_trans.c +++ b/lustre/target/update_trans.c @@ -359,13 +359,11 @@ static int prepare_writing_updates(const struct lu_env *env, params_size = update_params_size(tur->tur_update_params, tur->tur_update_param_count); LASSERT(lur->lur_update_rec.ur_param_count == 0); - update_size = llog_update_record_size(lur); - if (cfs_size_round(update_size + params_size) > - tur->tur_update_records_buf_size) { + update_size = round_up(llog_update_record_size(lur) + params_size, 8); + if (update_size > tur->tur_update_records_buf_size) { int rc; - rc = tur_update_records_extend(tur, - cfs_size_round(update_size + params_size)); + rc = tur_update_records_extend(tur, update_size); if (rc < 0) return rc; -- 1.8.3.1