Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: lustre: Using macro DIV_ROUND_UP

The macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /(d)).
It clarifies the divisor calculations. This occurence was detected using
the coccinelle script:

@@
expression e1;
expression e2;
@@
(
- ((e1) + e2 - 1) / (e2)
+ DIV_ROUND_UP(e1,e2)
|
- ((e1) + (e2 - 1)) / (e2)
+ DIV_ROUND_UP(e1,e2)
)

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

simran singhal and committed by
Greg Kroah-Hartman
fce3444a 2720ecce

+8 -12
+1 -1
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
··· 2037 2037 tpo->tpo_tx_descs = NULL; 2038 2038 tpo->tpo_tx_pages = NULL; 2039 2039 2040 - npg = (size * IBLND_MSG_SIZE + PAGE_SIZE - 1) / PAGE_SIZE; 2040 + npg = DIV_ROUND_UP(size * IBLND_MSG_SIZE, PAGE_SIZE); 2041 2041 if (kiblnd_alloc_pages(&tpo->tpo_tx_pages, ps->ps_cpt, npg)) { 2042 2042 CERROR("Can't allocate tx pages: %d\n", npg); 2043 2043 LIBCFS_FREE(tpo, sizeof(*tpo));
+4 -7
drivers/staging/lustre/lnet/selftest/conrpc.c
··· 785 785 struct test_bulk_req *brq = &req->tsr_u.bulk_v0; 786 786 787 787 brq->blk_opc = param->blk_opc; 788 - brq->blk_npg = (param->blk_size + PAGE_SIZE - 1) / 789 - PAGE_SIZE; 788 + brq->blk_npg = DIV_ROUND_UP(param->blk_size, PAGE_SIZE); 790 789 brq->blk_flags = param->blk_flags; 791 790 792 791 return 0; ··· 832 833 trq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.tes_reqst; 833 834 834 835 if (transop == LST_TRANS_TSBSRVADD) { 835 - int ndist = (sgrp->grp_nnode + test->tes_dist - 1) / 836 - test->tes_dist; 837 - int nspan = (dgrp->grp_nnode + test->tes_span - 1) / 838 - test->tes_span; 839 - int nmax = (ndist + nspan - 1) / nspan; 836 + int ndist = DIV_ROUND_UP(sgrp->grp_nnode, test->tes_dist); 837 + int nspan = DIV_ROUND_UP(dgrp->grp_nnode, test->tes_span); 838 + int nmax = DIV_ROUND_UP(ndist, nspan); 840 839 841 840 trq->tsr_ndest = 0; 842 841 trq->tsr_loop = nmax * test->tes_dist * test->tes_concur;
+1 -2
drivers/staging/lustre/lustre/ptlrpc/client.c
··· 3144 3144 * that server can infer the number of bulks that were prepared, 3145 3145 * see LU-1431 3146 3146 */ 3147 - req->rq_mbits += ((bd->bd_iov_count + LNET_MAX_IOV - 1) / 3148 - LNET_MAX_IOV) - 1; 3147 + req->rq_mbits += DIV_ROUND_UP(bd->bd_iov_count, LNET_MAX_IOV) - 1; 3149 3148 } 3150 3149 3151 3150 /**
+1 -1
drivers/staging/lustre/lustre/ptlrpc/niobuf.c
··· 142 142 LASSERT(desc->bd_cbid.cbid_fn == client_bulk_callback); 143 143 LASSERT(desc->bd_cbid.cbid_arg == desc); 144 144 145 - total_md = (desc->bd_iov_count + LNET_MAX_IOV - 1) / LNET_MAX_IOV; 145 + total_md = DIV_ROUND_UP(desc->bd_iov_count, LNET_MAX_IOV); 146 146 /* rq_mbits is matchbits of the final bulk */ 147 147 mbits = req->rq_mbits - total_md + 1; 148 148
+1 -1
drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
··· 272 272 static inline 273 273 int npages_to_npools(unsigned long npages) 274 274 { 275 - return (int)((npages + PAGES_PER_POOL - 1) / PAGES_PER_POOL); 275 + return (int)DIV_ROUND_UP(npages, PAGES_PER_POOL); 276 276 } 277 277 278 278 /*