Skip to content

Commit fb692ec

Browse files
karstengrdavem330
authored andcommitted
net/smc: fix smc_buf_unuse to use the lgr pointer
The pointer to the link group is unset in the smc connection structure right before the call to smc_buf_unuse. Provide the lgr pointer to smc_buf_unuse explicitly. And move the call to smc_lgr_schedule_free_work to the end of smc_conn_free. Fixes: a6920d1 ("net/smc: handle unregistered buffers") Signed-off-by: Karsten Graul <kgraul@linux.ibm.com> Signed-off-by: Ursula Braun <ubraun@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ee1abcf commit fb692ec

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

net/smc/smc_core.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,17 @@ static void __smc_lgr_unregister_conn(struct smc_connection *conn)
122122
sock_put(&smc->sk); /* sock_hold in smc_lgr_register_conn() */
123123
}
124124

125-
/* Unregister connection and trigger lgr freeing if applicable
125+
/* Unregister connection from lgr
126126
*/
127127
static void smc_lgr_unregister_conn(struct smc_connection *conn)
128128
{
129129
struct smc_link_group *lgr = conn->lgr;
130-
int reduced = 0;
131130

132131
write_lock_bh(&lgr->conns_lock);
133132
if (conn->alert_token_local) {
134-
reduced = 1;
135133
__smc_lgr_unregister_conn(conn);
136134
}
137135
write_unlock_bh(&lgr->conns_lock);
138-
if (!reduced || lgr->conns_num)
139-
return;
140-
smc_lgr_schedule_free_work(lgr);
141136
}
142137

143138
/* Send delete link, either as client to request the initiation
@@ -291,7 +286,8 @@ static int smc_lgr_create(struct smc_sock *smc, bool is_smcd,
291286
return rc;
292287
}
293288

294-
static void smc_buf_unuse(struct smc_connection *conn)
289+
static void smc_buf_unuse(struct smc_connection *conn,
290+
struct smc_link_group *lgr)
295291
{
296292
if (conn->sndbuf_desc)
297293
conn->sndbuf_desc->used = 0;
@@ -301,8 +297,6 @@ static void smc_buf_unuse(struct smc_connection *conn)
301297
conn->rmb_desc->used = 0;
302298
} else {
303299
/* buf registration failed, reuse not possible */
304-
struct smc_link_group *lgr = conn->lgr;
305-
306300
write_lock_bh(&lgr->rmbs_lock);
307301
list_del(&conn->rmb_desc->list);
308302
write_unlock_bh(&lgr->rmbs_lock);
@@ -315,16 +309,21 @@ static void smc_buf_unuse(struct smc_connection *conn)
315309
/* remove a finished connection from its link group */
316310
void smc_conn_free(struct smc_connection *conn)
317311
{
318-
if (!conn->lgr)
312+
struct smc_link_group *lgr = conn->lgr;
313+
314+
if (!lgr)
319315
return;
320-
if (conn->lgr->is_smcd) {
316+
if (lgr->is_smcd) {
321317
smc_ism_unset_conn(conn);
322318
tasklet_kill(&conn->rx_tsklet);
323319
} else {
324320
smc_cdc_tx_dismiss_slots(conn);
325321
}
326-
smc_lgr_unregister_conn(conn);
327-
smc_buf_unuse(conn);
322+
smc_lgr_unregister_conn(conn); /* unsets conn->lgr */
323+
smc_buf_unuse(conn, lgr); /* allow buffer reuse */
324+
325+
if (!lgr->conns_num)
326+
smc_lgr_schedule_free_work(lgr);
328327
}
329328

330329
static void smc_link_clear(struct smc_link *lnk)

0 commit comments

Comments
 (0)