Re: [PATCH RFC 05/12] RDMA/rtrs-srv: Correct the checking of ib_map_mr_sg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 11/15/22 7:46 PM, Jinpu Wang wrote:
On Sun, Nov 13, 2022 at 2:08 AM Guoqing Jiang <guoqing.jiang@xxxxxxxxx> wrote:
We should check with nr_sgt, also the only successful case is that
all sg elements are mapped, so make it explict.

Signed-off-by: Guoqing Jiang <guoqing.jiang@xxxxxxxxx>
---
  drivers/infiniband/ulp/rtrs/rtrs-srv.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
index 88eae0dcf87f..f3bf5bbb4377 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
@@ -622,8 +622,8 @@ static int map_cont_bufs(struct rtrs_srv_path *srv_path)
                 }
                 nr = ib_map_mr_sg(mr, sgt->sgl, nr_sgt,
                                   NULL, max_chunk_size);
-               if (nr < 0 || nr < sgt->nents) {
-                       err = nr < 0 ? nr : -EINVAL;
+               if (nr != nr_sgt) {
+                       err = -EINVAL;
but with this, the initial errno are lost, we only return EINVAL

OK, assume you mean 'nr' here, I can change it back as iser_memory did.
But seems the only negative value returned from ib_map_mr_sg is also
"-EINVAL" from ib_sg_to_pages after go through hw drivers.

BTW, I looked all call sites of ib_map_mr_sg, seems they have different
kind of checking.

1. if (ret < 0 || ret < nents)

2. if (ret < nents) or if (ret < 0)

3. if (ret != nents)

Thanks,
Guoqing



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux