Skip to content

Commit 35ff290

Browse files
Hakon-Buggegregkh
authored andcommitted
rds: ib: Increment i_fastreg_wrs before bailing out
commit 4351ca3 upstream. We need to increment i_fastreg_wrs before we bail out from rds_ib_post_reg_frmr(). We have a fixed budget of how many FRWR operations that can be outstanding using the dedicated QP used for memory registrations and de-registrations. This budget is enforced by the atomic_t i_fastreg_wrs. If we bail out early in rds_ib_post_reg_frmr(), we will "leak" the possibility of posting an FRWR operation, and if that accumulates, no FRWR operation can be carried out. Fixes: 1659185 ("RDS: IB: Support Fastreg MR (FRMR) memory registration mode") Fixes: 3a2886c ("net/rds: Keep track of and wait for FRWR segments in use upon shutdown") Cc: stable@vger.kernel.org Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com> Reviewed-by: Allison Henderson <allison.henderson@oracle.com> Link: https://patch.msgid.link/20250911133336.451212-1-haakon.bugge@oracle.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 340c45b commit 35ff290

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

net/rds/ib_frmr.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,15 @@ static int rds_ib_post_reg_frmr(struct rds_ib_mr *ibmr)
133133

134134
ret = ib_map_mr_sg_zbva(frmr->mr, ibmr->sg, ibmr->sg_dma_len,
135135
&off, PAGE_SIZE);
136-
if (unlikely(ret != ibmr->sg_dma_len))
137-
return ret < 0 ? ret : -EINVAL;
136+
if (unlikely(ret != ibmr->sg_dma_len)) {
137+
ret = ret < 0 ? ret : -EINVAL;
138+
goto out_inc;
139+
}
138140

139-
if (cmpxchg(&frmr->fr_state,
140-
FRMR_IS_FREE, FRMR_IS_INUSE) != FRMR_IS_FREE)
141-
return -EBUSY;
141+
if (cmpxchg(&frmr->fr_state, FRMR_IS_FREE, FRMR_IS_INUSE) != FRMR_IS_FREE) {
142+
ret = -EBUSY;
143+
goto out_inc;
144+
}
142145

143146
atomic_inc(&ibmr->ic->i_fastreg_inuse_count);
144147

@@ -166,11 +169,10 @@ static int rds_ib_post_reg_frmr(struct rds_ib_mr *ibmr)
166169
/* Failure here can be because of -ENOMEM as well */
167170
rds_transition_frwr_state(ibmr, FRMR_IS_INUSE, FRMR_IS_STALE);
168171

169-
atomic_inc(&ibmr->ic->i_fastreg_wrs);
170172
if (printk_ratelimit())
171173
pr_warn("RDS/IB: %s returned error(%d)\n",
172174
__func__, ret);
173-
goto out;
175+
goto out_inc;
174176
}
175177

176178
/* Wait for the registration to complete in order to prevent an invalid
@@ -179,8 +181,10 @@ static int rds_ib_post_reg_frmr(struct rds_ib_mr *ibmr)
179181
*/
180182
wait_event(frmr->fr_reg_done, !frmr->fr_reg);
181183

182-
out:
184+
return ret;
183185

186+
out_inc:
187+
atomic_inc(&ibmr->ic->i_fastreg_wrs);
184188
return ret;
185189
}
186190

0 commit comments

Comments
 (0)