From: Shaun Tancheff Date: Sun, 31 Jan 2021 14:47:21 +0000 (-0600) Subject: LU-14390 gnilnd: Use DIV_ROUND_UP to calculate niov X-Git-Tag: 2.14.51~163 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=3117913e21adb941e0ef3467ff7588d5e5fbc6e4;hp=e00733f0f87659c936039a58ea738cfb070638bc LU-14390 gnilnd: Use DIV_ROUND_UP to calculate niov Use DIV_ROUND_UP to calculate niov, also remove 'unlikely' as this is the common case. Fixes: 7a74d382 ("LU-13004 modules: replace lnet_kiov_t with struct bio_vec") Test-Parameters: trivial Signed-off-by: Shaun Tancheff Change-Id: Iaf62326743ebe5e92bb3aa4b5780b47a5cfdfb18 Reviewed-on: https://review.whamcloud.com/41371 Tested-by: jenkins Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Neil Brown Reviewed-by: Oleg Drokin --- diff --git a/lnet/klnds/gnilnd/gnilnd_cb.c b/lnet/klnds/gnilnd/gnilnd_cb.c index 5f838b1..edd60ce 100644 --- a/lnet/klnds/gnilnd/gnilnd_cb.c +++ b/lnet/klnds/gnilnd/gnilnd_cb.c @@ -535,10 +535,9 @@ kgnilnd_setup_immediate_buffer(kgn_tx_t *tx, unsigned int niov, tx->tx_buffer = NULL; } else { - if ((niov > 0) && unlikely(niov > (nob/PAGE_SIZE))) { - niov = round_up(nob + offset + kiov->bv_offset, - PAGE_SIZE); - } + if (niov && niov > (nob >> PAGE_SHIFT)) + niov = DIV_ROUND_UP(nob + offset + kiov->bv_offset, + PAGE_SIZE); LASSERTF(niov > 0 && niov < GNILND_MAX_IMMEDIATE/PAGE_SIZE, "bad niov %d msg %p kiov %p offset %d nob%d\n",