* [PATCH net 0/3] net/smc: fixes 2018/05/03
@ 2018-05-03 15:57 Ursula Braun
2018-05-03 15:57 ` [PATCH net 1/3] net/smc: call consolidation Ursula Braun
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Ursula Braun @ 2018-05-03 15:57 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun
From: Ursula Braun <ursula.braun@de.ibm.com>
Dave,
here are smc fixes for 2 problems:
* receive buffers in SMC must be registered. If registration fails
these buffers must not be kept within the link group for reuse.
Patch 1 is a preparational patch; patch 2 contains the fix.
* sendpage: do not hold the sock lock when calling kernel_sendpage()
or sock_no_sendpage()
Thanks, Ursula
Karsten Graul (2):
net/smc: call consolidation
net/smc: handle unregistered buffers
Stefan Raspl (1):
smc: fix sendpage() call
net/smc/af_smc.c | 43 +++++++++++++++++++++----------------------
net/smc/smc_core.c | 22 +++++++++++++++++++---
net/smc/smc_core.h | 3 ++-
3 files changed, 42 insertions(+), 26 deletions(-)
--
2.13.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net 1/3] net/smc: call consolidation
2018-05-03 15:57 [PATCH net 0/3] net/smc: fixes 2018/05/03 Ursula Braun
@ 2018-05-03 15:57 ` Ursula Braun
2018-05-03 15:57 ` [PATCH net 2/3] net/smc: handle unregistered buffers Ursula Braun
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Ursula Braun @ 2018-05-03 15:57 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun
From: Karsten Graul <kgraul@linux.ibm.com>
Consolidate the call to smc_wr_reg_send() in a new function.
No functional changes.
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
---
net/smc/af_smc.c | 35 +++++++++++++++--------------------
1 file changed, 15 insertions(+), 20 deletions(-)
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 8b4c059bd13b..fdb2976117bd 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -292,6 +292,15 @@ static void smc_copy_sock_settings_to_smc(struct smc_sock *smc)
smc_copy_sock_settings(&smc->sk, smc->clcsock->sk, SK_FLAGS_CLC_TO_SMC);
}
+/* register a new rmb */
+static int smc_reg_rmb(struct smc_link *link, struct smc_buf_desc *rmb_desc)
+{
+ /* register memory region for new rmb */
+ if (smc_wr_reg_send(link, rmb_desc->mr_rx[SMC_SINGLE_LINK]))
+ return -EFAULT;
+ return 0;
+}
+
static int smc_clnt_conf_first_link(struct smc_sock *smc)
{
struct smc_link_group *lgr = smc->conn.lgr;
@@ -321,9 +330,7 @@ static int smc_clnt_conf_first_link(struct smc_sock *smc)
smc_wr_remember_qp_attr(link);
- rc = smc_wr_reg_send(link,
- smc->conn.rmb_desc->mr_rx[SMC_SINGLE_LINK]);
- if (rc)
+ if (smc_reg_rmb(link, smc->conn.rmb_desc))
return SMC_CLC_DECL_INTERR;
/* send CONFIRM LINK response over RoCE fabric */
@@ -473,13 +480,8 @@ static int smc_connect_rdma(struct smc_sock *smc)
goto decline_rdma_unlock;
}
} else {
- struct smc_buf_desc *buf_desc = smc->conn.rmb_desc;
-
- if (!buf_desc->reused) {
- /* register memory region for new rmb */
- rc = smc_wr_reg_send(link,
- buf_desc->mr_rx[SMC_SINGLE_LINK]);
- if (rc) {
+ if (!smc->conn.rmb_desc->reused) {
+ if (smc_reg_rmb(link, smc->conn.rmb_desc)) {
reason_code = SMC_CLC_DECL_INTERR;
goto decline_rdma_unlock;
}
@@ -719,9 +721,7 @@ static int smc_serv_conf_first_link(struct smc_sock *smc)
link = &lgr->lnk[SMC_SINGLE_LINK];
- rc = smc_wr_reg_send(link,
- smc->conn.rmb_desc->mr_rx[SMC_SINGLE_LINK]);
- if (rc)
+ if (smc_reg_rmb(link, smc->conn.rmb_desc))
return SMC_CLC_DECL_INTERR;
/* send CONFIRM LINK request to client over the RoCE fabric */
@@ -854,13 +854,8 @@ static void smc_listen_work(struct work_struct *work)
smc_rx_init(new_smc);
if (local_contact != SMC_FIRST_CONTACT) {
- struct smc_buf_desc *buf_desc = new_smc->conn.rmb_desc;
-
- if (!buf_desc->reused) {
- /* register memory region for new rmb */
- rc = smc_wr_reg_send(link,
- buf_desc->mr_rx[SMC_SINGLE_LINK]);
- if (rc) {
+ if (!new_smc->conn.rmb_desc->reused) {
+ if (smc_reg_rmb(link, new_smc->conn.rmb_desc)) {
reason_code = SMC_CLC_DECL_INTERR;
goto decline_rdma_unlock;
}
--
2.13.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 2/3] net/smc: handle unregistered buffers
2018-05-03 15:57 [PATCH net 0/3] net/smc: fixes 2018/05/03 Ursula Braun
2018-05-03 15:57 ` [PATCH net 1/3] net/smc: call consolidation Ursula Braun
@ 2018-05-03 15:57 ` Ursula Braun
2018-05-03 15:57 ` [PATCH net 3/3] smc: fix sendpage() call Ursula Braun
2018-05-03 18:47 ` [PATCH net 0/3] net/smc: fixes 2018/05/03 David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Ursula Braun @ 2018-05-03 15:57 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun
From: Karsten Graul <kgraul@linux.ibm.com>
When smc_wr_reg_send() fails then tag (regerr) the affected buffer and
free it in smc_buf_unuse().
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
---
net/smc/af_smc.c | 4 +++-
net/smc/smc_core.c | 22 +++++++++++++++++++---
net/smc/smc_core.h | 3 ++-
3 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index fdb2976117bd..d03b8d29ffc0 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -296,8 +296,10 @@ static void smc_copy_sock_settings_to_smc(struct smc_sock *smc)
static int smc_reg_rmb(struct smc_link *link, struct smc_buf_desc *rmb_desc)
{
/* register memory region for new rmb */
- if (smc_wr_reg_send(link, rmb_desc->mr_rx[SMC_SINGLE_LINK]))
+ if (smc_wr_reg_send(link, rmb_desc->mr_rx[SMC_SINGLE_LINK])) {
+ rmb_desc->regerr = 1;
return -EFAULT;
+ }
return 0;
}
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index f44f6803f7ff..d4bd01bb44e1 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -32,6 +32,9 @@
static u32 smc_lgr_num; /* unique link group number */
+static void smc_buf_free(struct smc_buf_desc *buf_desc, struct smc_link *lnk,
+ bool is_rmb);
+
static void smc_lgr_schedule_free_work(struct smc_link_group *lgr)
{
/* client link group creation always follows the server link group
@@ -234,9 +237,22 @@ static void smc_buf_unuse(struct smc_connection *conn)
conn->sndbuf_size = 0;
}
if (conn->rmb_desc) {
- conn->rmb_desc->reused = true;
- conn->rmb_desc->used = 0;
- conn->rmbe_size = 0;
+ if (!conn->rmb_desc->regerr) {
+ conn->rmb_desc->reused = 1;
+ conn->rmb_desc->used = 0;
+ conn->rmbe_size = 0;
+ } else {
+ /* buf registration failed, reuse not possible */
+ struct smc_link_group *lgr = conn->lgr;
+ struct smc_link *lnk;
+
+ write_lock_bh(&lgr->rmbs_lock);
+ list_del(&conn->rmb_desc->list);
+ write_unlock_bh(&lgr->rmbs_lock);
+
+ lnk = &lgr->lnk[SMC_SINGLE_LINK];
+ smc_buf_free(conn->rmb_desc, lnk, true);
+ }
}
}
diff --git a/net/smc/smc_core.h b/net/smc/smc_core.h
index 07e2a393e6d9..5dfcb15d529f 100644
--- a/net/smc/smc_core.h
+++ b/net/smc/smc_core.h
@@ -123,7 +123,8 @@ struct smc_buf_desc {
*/
u32 order; /* allocation order */
u32 used; /* currently used / unused */
- bool reused; /* new created / reused */
+ u8 reused : 1; /* new created / reused */
+ u8 regerr : 1; /* err during registration */
};
struct smc_rtoken { /* address/key of remote RMB */
--
2.13.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 3/3] smc: fix sendpage() call
2018-05-03 15:57 [PATCH net 0/3] net/smc: fixes 2018/05/03 Ursula Braun
2018-05-03 15:57 ` [PATCH net 1/3] net/smc: call consolidation Ursula Braun
2018-05-03 15:57 ` [PATCH net 2/3] net/smc: handle unregistered buffers Ursula Braun
@ 2018-05-03 15:57 ` Ursula Braun
2018-05-03 18:47 ` [PATCH net 0/3] net/smc: fixes 2018/05/03 David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Ursula Braun @ 2018-05-03 15:57 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun
From: Stefan Raspl <stefan.raspl@linux.ibm.com>
The sendpage() call grabs the sock lock before calling the default
implementation - which tries to grab it once again.
Signed-off-by: Stefan Raspl <raspl@linux.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com><
---
net/smc/af_smc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index d03b8d29ffc0..544bab42f925 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -1315,8 +1315,11 @@ static ssize_t smc_sendpage(struct socket *sock, struct page *page,
smc = smc_sk(sk);
lock_sock(sk);
- if (sk->sk_state != SMC_ACTIVE)
+ if (sk->sk_state != SMC_ACTIVE) {
+ release_sock(sk);
goto out;
+ }
+ release_sock(sk);
if (smc->use_fallback)
rc = kernel_sendpage(smc->clcsock, page, offset,
size, flags);
@@ -1324,7 +1327,6 @@ static ssize_t smc_sendpage(struct socket *sock, struct page *page,
rc = sock_no_sendpage(sock, page, offset, size, flags);
out:
- release_sock(sk);
return rc;
}
--
2.13.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net 0/3] net/smc: fixes 2018/05/03
2018-05-03 15:57 [PATCH net 0/3] net/smc: fixes 2018/05/03 Ursula Braun
` (2 preceding siblings ...)
2018-05-03 15:57 ` [PATCH net 3/3] smc: fix sendpage() call Ursula Braun
@ 2018-05-03 18:47 ` David Miller
3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2018-05-03 18:47 UTC (permalink / raw)
To: ubraun; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl
From: Ursula Braun <ubraun@linux.ibm.com>
Date: Thu, 3 May 2018 17:57:36 +0200
> From: Ursula Braun <ursula.braun@de.ibm.com>
>
> Dave,
>
> here are smc fixes for 2 problems:
> * receive buffers in SMC must be registered. If registration fails
> these buffers must not be kept within the link group for reuse.
> Patch 1 is a preparational patch; patch 2 contains the fix.
> * sendpage: do not hold the sock lock when calling kernel_sendpage()
> or sock_no_sendpage()
Series applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-05-03 18:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-03 15:57 [PATCH net 0/3] net/smc: fixes 2018/05/03 Ursula Braun
2018-05-03 15:57 ` [PATCH net 1/3] net/smc: call consolidation Ursula Braun
2018-05-03 15:57 ` [PATCH net 2/3] net/smc: handle unregistered buffers Ursula Braun
2018-05-03 15:57 ` [PATCH net 3/3] smc: fix sendpage() call Ursula Braun
2018-05-03 18:47 ` [PATCH net 0/3] net/smc: fixes 2018/05/03 David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.