@@ -1584,7 +1584,8 @@ static int kiblnd_alloc_freg_pool(struct kib_fmr_poolset *fps,
goto out_middle;
}
- frd->frd_valid = true;
+ /* indicate that the local invalidate needs to be generated */
+ frd->frd_valid = false;
list_add_tail(&frd->frd_list, &fpo->fast_reg.fpo_pool_list);
fpo->fast_reg.fpo_pool_size++;
@@ -1738,7 +1739,6 @@ void kiblnd_fmr_pool_unmap(struct kib_fmr *fmr, int status)
fps = fpo->fpo_owner;
if (frd) {
- frd->frd_valid = false;
frd->frd_posted = false;
fmr->fmr_frd = NULL;
spin_lock(&fps->fps_lock);
@@ -1800,6 +1800,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
u32 key = is_rx ? mr->rkey : mr->lkey;
struct ib_send_wr *inv_wr;
+ frd->frd_valid = true;
inv_wr = &frd->frd_inv_wr;
memset(inv_wr, 0, sizeof(*inv_wr));
inv_wr->opcode = IB_WR_LOCAL_INV;
@@ -847,12 +847,8 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
struct ib_send_wr *wrq = &tx->tx_wrq[0].wr;
if (frd && !frd->frd_posted) {
- if (!frd->frd_valid) {
- wrq = &frd->frd_inv_wr;
- wrq->next = &frd->frd_fastreg_wr.wr;
- } else {
- wrq = &frd->frd_fastreg_wr.wr;
- }
+ wrq = &frd->frd_inv_wr;
+ wrq->next = &frd->frd_fastreg_wr.wr;
frd->frd_fastreg_wr.wr.next = &tx->tx_wrq[0].wr;
}
@@ -866,6 +862,15 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
rc = -EINVAL;
else
rc = ib_post_send(conn->ibc_cmid->qp, wrq, &bad);
+
+ if (frd && !frd->frd_posted) {
+ /* The local invalidate becomes invalid (has been
+ * successfully used) if the post succeeds or the
+ * failing wr was not the invalidate.
+ */
+ frd->frd_valid =
+ !(rc == 0 || (bad != &frd->frd_inv_wr));
+ }
}
conn->ibc_last_send = ktime_get();