lustre-devel-lustre.org archive mirror
 help / color / mirror / Atom feed
From: James Simmons <jsimmons@infradead.org>
To: Andreas Dilger <adilger@whamcloud.com>,
	Oleg Drokin <green@whamcloud.com>, NeilBrown <neilb@suse.de>
Cc: Arshad Hussain <arshad.hussain@aeoncomputing.com>,
	Lustre Development List <lustre-devel@lists.lustre.org>
Subject: [lustre-devel] [PATCH 25/33] lnet: libcfs: use round_up directly
Date: Sun,  2 Feb 2025 15:46:25 -0500	[thread overview]
Message-ID: <20250202204633.1148872-26-jsimmons@infradead.org> (raw)
In-Reply-To: <20250202204633.1148872-1-jsimmons@infradead.org>

The macro cfs_size_round() is just round_up(val, 8). Replace
cfs_size_round() with the Linux standard round_up().

WC-bug-id: https://jira.whamcloud.com/browse/LU-9859
Lustre-commit: 20683c0d6c3e7d042 ("LU-9859 libcfs: use round_up directly")
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50545
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
---
 fs/lustre/include/cl_object.h         |  2 +-
 fs/lustre/llite/vvp_object.c          |  2 +-
 fs/lustre/mdc/mdc_request.c           |  9 ++++-----
 fs/lustre/obdclass/class_obd.c        |  6 +++---
 fs/lustre/obdecho/echo_client.c       |  2 +-
 fs/lustre/osc/osc_cache.c             |  2 +-
 fs/lustre/ptlrpc/batch.c              |  6 ++----
 fs/lustre/ptlrpc/layout.c             |  8 +++++---
 fs/lustre/ptlrpc/pack_generic.c       | 13 ++++++-------
 include/linux/libcfs/libcfs_private.h |  4 ----
 net/lnet/libcfs/module.c              |  8 ++++----
 11 files changed, 28 insertions(+), 34 deletions(-)

diff --git a/fs/lustre/include/cl_object.h b/fs/lustre/include/cl_object.h
index 9d940cbdb249..b8ac31960a2f 100644
--- a/fs/lustre/include/cl_object.h
+++ b/fs/lustre/include/cl_object.h
@@ -2162,7 +2162,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/fs/lustre/llite/vvp_object.c b/fs/lustre/llite/vvp_object.c
index 5120ec095862..f4b2f8921b6c 100644
--- a/fs/lustre/llite/vvp_object.c
+++ b/fs/lustre/llite/vvp_object.c
@@ -316,7 +316,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/fs/lustre/mdc/mdc_request.c b/fs/lustre/mdc/mdc_request.c
index 5919e5952c0e..2b8386661a31 100644
--- a/fs/lustre/mdc/mdc_request.c
+++ b/fs/lustre/mdc/mdc_request.c
@@ -1712,15 +1712,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);
 	key = kzalloc(keylen, GFP_NOFS);
 	if (!key)
 		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_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/fs/lustre/obdclass/class_obd.c b/fs/lustre/obdclass/class_obd.c
index ab27cf23ca9a..a6e256484800 100644
--- a/fs/lustre/obdclass/class_obd.c
+++ b/fs/lustre/obdclass/class_obd.c
@@ -278,17 +278,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/fs/lustre/obdecho/echo_client.c b/fs/lustre/obdecho/echo_client.c
index 220ceae89150..654bc3b7d351 100644
--- a/fs/lustre/obdecho/echo_client.c
+++ b/fs/lustre/obdecho/echo_client.c
@@ -294,7 +294,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/fs/lustre/osc/osc_cache.c b/fs/lustre/osc/osc_cache.c
index 691ebc0ad46a..f1f21c28765e 100644
--- a/fs/lustre/osc/osc_cache.c
+++ b/fs/lustre/osc/osc_cache.c
@@ -2302,7 +2302,7 @@ int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops,
 	struct osc_async_page *oap = &ops->ops_oap;
 
 	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/fs/lustre/ptlrpc/batch.c b/fs/lustre/ptlrpc/batch.c
index 77e3261862e0..753dfe3c15e8 100644
--- a/fs/lustre/ptlrpc/batch.c
+++ b/fs/lustre/ptlrpc/batch.c
@@ -132,14 +132,12 @@ 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;
 
-	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/fs/lustre/ptlrpc/layout.c b/fs/lustre/ptlrpc/layout.c
index 3a9e83f5262b..64e0224ce496 100644
--- a/fs/lustre/ptlrpc/layout.c
+++ b/fs/lustre/ptlrpc/layout.c
@@ -2404,9 +2404,11 @@ u32 req_capsule_fmt_size(u32 magic, const struct req_format *fmt,
 	if (!size)
 		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/fs/lustre/ptlrpc/pack_generic.c b/fs/lustre/ptlrpc/pack_generic.c
index 61fd122e8e3f..cb7a8a39a380 100644
--- a/fs/lustre/ptlrpc/pack_generic.c
+++ b/fs/lustre/ptlrpc/pack_generic.c
@@ -55,8 +55,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)
@@ -91,7 +90,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;
 }
@@ -164,7 +163,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);
@@ -376,7 +375,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;
 }
@@ -410,7 +409,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;
@@ -562,7 +561,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/include/linux/libcfs/libcfs_private.h b/include/linux/libcfs/libcfs_private.h
index 86d135a65d81..7c0fb5a1c652 100644
--- a/include/linux/libcfs/libcfs_private.h
+++ b/include/linux/libcfs/libcfs_private.h
@@ -139,13 +139,9 @@ do {								\
 /* logical equivalence */
 #define equi(a, b) (!!(a) == !!(b))
 
-#ifndef HAVE_CFS_SIZE_ROUND
 static inline size_t cfs_size_round(int val)
 {
 	return round_up(val, 8);
 }
 
-#define HAVE_CFS_SIZE_ROUND
-#endif
-
 #endif
diff --git a/net/lnet/libcfs/module.c b/net/lnet/libcfs/module.c
index a126683354ac..17cb8e4b818f 100644
--- a/net/lnet/libcfs/module.c
+++ b/net/lnet/libcfs/module.c
@@ -72,8 +72,8 @@ static inline size_t libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
 {
 	size_t len = sizeof(*data);
 
-	len += cfs_size_round(data->ioc_inllen1);
-	len += cfs_size_round(data->ioc_inllen2);
+	len += round_up(data->ioc_inllen1, 8);
+	len += round_up(data->ioc_inllen2, 8);
 	return len;
 }
 
@@ -124,7 +124,7 @@ static inline bool libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data)
 		return true;
 	}
 	if (data->ioc_inllen2 &&
-	    data->ioc_bulk[cfs_size_round(data->ioc_inllen1) +
+	    data->ioc_bulk[round_up(data->ioc_inllen1, 8) +
 			   data->ioc_inllen2 - 1] != '\0') {
 		CERROR("LIBCFS ioctl: inlbuf2 not 0 terminated\n");
 		return true;
@@ -144,7 +144,7 @@ static int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data)
 
 	if (data->ioc_inllen2)
 		data->ioc_inlbuf2 = &data->ioc_bulk[0] +
-			cfs_size_round(data->ioc_inllen1);
+				    round_up(data->ioc_inllen1, 8);
 
 	return 0;
 }
-- 
2.39.3

_______________________________________________
lustre-devel mailing list
lustre-devel@lists.lustre.org
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

  parent reply	other threads:[~2025-02-02 21:03 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-02 20:46 [lustre-devel] [PATCH 00/33] lustre: sync to OpenSFS branch May 31, 2023 James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 01/33] lnet: set msg field for lnet message header James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 02/33] Revert "lustre: llite: Check vmpage in releasepage" James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 03/33] lustre: llite: EIO is possible on a race with page reclaim James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 04/33] lustre: llite: add __GFP_NORETRY for read-ahead page James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 05/33] lustre: obd: change lmd flags to bitmap James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 06/33] lustre: uapi: cleanup FSFILT defines James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 07/33] lustre: obd: Reserve metadata overstriping flags James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 08/33] lnet: selftest: manage the workqueue state properly James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 09/33] lustre: remove cl_{offset, index, page_size} helpers James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 10/33] lustre: csdc: reserve layout bits for compress component James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 11/33] lustre: obd: replace simple_strtoul() James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 12/33] lnet: Use dynamic allocation for LND tunables James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 13/33] lustre: cksum: fix generating T10PI guard tags for partial brw page James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 14/33] lustre: llite: remove OBD_ -> CFS_ macros James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 15/33] lustre: obd: " James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 16/33] lnet: improve numeric NID to CPT hashing James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 17/33] lnet: libcfs: Remove unsed LASSERT_ATOMIC_* macros James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 18/33] lustre: misc: replace obsolete ioctl numbers James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 19/33] lustre: lmv: treat unknown hash type as sane type James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 20/33] lustre: llite: Fix return for non-queued aio James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 21/33] lnet: collect data about routes by using Netlink James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 22/33] lustre: ptlrpc: switch sptlrpc_rule_set_choose to large nid James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 23/33] lnet: use list_first_entry() where appropriate James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 24/33] lustre: statahead: using try lock for batched RPCs James Simmons
2025-02-02 20:46 ` James Simmons [this message]
2025-02-02 20:46 ` [lustre-devel] [PATCH 26/33] lustre: mdc: md_open_data should keep ref on close_req James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 27/33] lustre: llite: update comment of ll_swap_layouts_close James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 28/33] lustre: ldlm: replace OBD_ -> CFS_ macros James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 29/33] lustre: mdc: remove " James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 30/33] lnet: libcfs: move cfs_expr_list_print to nidstrings.c James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 31/33] lnet: libcfs: Remove reference to LASSERT_ATOMIC_POS James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 32/33] lnet: ksocklnd: ksocklnd_ni_get_eth_intf_speed() must use only rtnl lock James Simmons
2025-02-02 20:46 ` [lustre-devel] [PATCH 33/33] lustre: ldlm: convert ldlm extent locks to linux extent-tree James Simmons

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250202204633.1148872-26-jsimmons@infradead.org \
    --to=jsimmons@infradead.org \
    --cc=adilger@whamcloud.com \
    --cc=arshad.hussain@aeoncomputing.com \
    --cc=green@whamcloud.com \
    --cc=lustre-devel@lists.lustre.org \
    --cc=neilb@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).