Message ID | 20221116111400.7203-5-guoqing.jiang@linux.dev (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Misc patches for rtrs | expand |
On Wed, Nov 16, 2022 at 12:14 PM Guoqing Jiang <guoqing.jiang@linux.dev> wrote: > > We should check with count, also the only successful case is that > all sg elements are mapped, so make it explict. s/explicit/explicitly > > Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev> Acked-by: Jack Wang <jinpu.wang@ionos.com> > --- > drivers/infiniband/ulp/rtrs/rtrs-clt.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c > index 8546b8816524..be7c8480f947 100644 > --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c > +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c > @@ -1064,10 +1064,8 @@ static int rtrs_map_sg_fr(struct rtrs_clt_io_req *req, size_t count) > > /* Align the MR to a 4K page size to match the block virt boundary */ > nr = ib_map_mr_sg(req->mr, req->sglist, count, NULL, SZ_4K); > - if (nr < 0) > - return nr; > - if (nr < req->sg_cnt) > - return -EINVAL; > + if (nr != count) > + return nr < 0 ? nr : -EINVAL; > ib_update_fast_reg_key(req->mr, ib_inc_rkey(req->mr->rkey)); > > return nr; > -- > 2.31.1 >
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 8546b8816524..be7c8480f947 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -1064,10 +1064,8 @@ static int rtrs_map_sg_fr(struct rtrs_clt_io_req *req, size_t count) /* Align the MR to a 4K page size to match the block virt boundary */ nr = ib_map_mr_sg(req->mr, req->sglist, count, NULL, SZ_4K); - if (nr < 0) - return nr; - if (nr < req->sg_cnt) - return -EINVAL; + if (nr != count) + return nr < 0 ? nr : -EINVAL; ib_update_fast_reg_key(req->mr, ib_inc_rkey(req->mr->rkey)); return nr;
We should check with count, also the only successful case is that all sg elements are mapped, so make it explict. Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev> --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)