diff options
author | simran singhal <singhalsimran0@gmail.com> | 2017-02-22 15:02:04 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-03-06 09:17:00 +0100 |
commit | fce3444aeae22edc2bb6100888be8039a6e9bb5b (patch) | |
tree | f3c7013b67c950bd888d813e32096da4d1fce346 /drivers/staging/lustre/lustre/ptlrpc | |
parent | 2720ecceb73c9acd66a5644c3de335467d33f49f (diff) |
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>
Diffstat (limited to 'drivers/staging/lustre/lustre/ptlrpc')
-rw-r--r-- | drivers/staging/lustre/lustre/ptlrpc/client.c | 3 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 2 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 2 |
3 files changed, 3 insertions, 4 deletions
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 04a98a08ece1..45b9aec617e9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -3144,8 +3144,7 @@ void ptlrpc_set_bulk_mbits(struct ptlrpc_request *req) * that server can infer the number of bulks that were prepared, * see LU-1431 */ - req->rq_mbits += ((bd->bd_iov_count + LNET_MAX_IOV - 1) / - LNET_MAX_IOV) - 1; + req->rq_mbits += DIV_ROUND_UP(bd->bd_iov_count, LNET_MAX_IOV) - 1; } /** diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index b8701841ab4a..352f614b781a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -142,7 +142,7 @@ static int ptlrpc_register_bulk(struct ptlrpc_request *req) LASSERT(desc->bd_cbid.cbid_fn == client_bulk_callback); LASSERT(desc->bd_cbid.cbid_arg == desc); - total_md = (desc->bd_iov_count + LNET_MAX_IOV - 1) / LNET_MAX_IOV; + total_md = DIV_ROUND_UP(desc->bd_iov_count, LNET_MAX_IOV); /* rq_mbits is matchbits of the final bulk */ mbits = req->rq_mbits - total_md + 1; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index 2fe9085e2034..128838a695e0 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -272,7 +272,7 @@ static unsigned long enc_pools_shrink_scan(struct shrinker *s, static inline int npages_to_npools(unsigned long npages) { - return (int)((npages + PAGES_PER_POOL - 1) / PAGES_PER_POOL); + return (int)DIV_ROUND_UP(npages, PAGES_PER_POOL); } /* |