* [PATCH 1/5] NFSD: Using free_conn free connection
2014-01-09 10:31 ` [PATCH 0/5] NFSD/SUNRPC: Fix some bugs which cause memory leak for the backchannel Kinglong Mee
@ 2014-01-09 10:31 ` Kinglong Mee
2014-01-09 10:32 ` [PATCH 2/5] NFSD: Free backchannel xprt in bc_destroy Kinglong Mee
` (3 subsequent siblings)
4 siblings, 0 replies; 18+ messages in thread
From: Kinglong Mee @ 2014-01-09 10:31 UTC (permalink / raw)
To: Trond Myklebust, Dr Fields James Bruce; +Cc: Linux NFS Mailing List
Connection from alloc_conn must be freed through free_conn,
otherwise, the reference of svc_xprt will never be put.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
fs/nfsd/nfs4state.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 7d613a7..f89f1f8 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2282,7 +2282,8 @@ out:
if (!list_empty(&clp->cl_revoked))
seq->status_flags |= SEQ4_STATUS_RECALLABLE_STATE_REVOKED;
out_no_session:
- kfree(conn);
+ if (conn)
+ free_conn(conn);
spin_unlock(&nn->client_lock);
return status;
out_put_session:
--
1.8.4.2
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 2/5] NFSD: Free backchannel xprt in bc_destroy
2014-01-09 10:31 ` [PATCH 0/5] NFSD/SUNRPC: Fix some bugs which cause memory leak for the backchannel Kinglong Mee
2014-01-09 10:31 ` [PATCH 1/5] NFSD: Using free_conn free connection Kinglong Mee
@ 2014-01-09 10:32 ` Kinglong Mee
2014-01-09 10:32 ` [PATCH 3/5] SUNRPC: New helper for creating client with rpc_xprt Kinglong Mee
` (2 subsequent siblings)
4 siblings, 0 replies; 18+ messages in thread
From: Kinglong Mee @ 2014-01-09 10:32 UTC (permalink / raw)
To: Trond Myklebust, Dr Fields James Bruce; +Cc: Linux NFS Mailing List
Backchannel xprt isnot freed right now.
Free it in bc_destroy, and put the reference of THIS_MODULE.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
net/sunrpc/xprtsock.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 4fcdf74..7289e3c 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -2545,6 +2545,10 @@ static void bc_close(struct rpc_xprt *xprt)
static void bc_destroy(struct rpc_xprt *xprt)
{
+ dprintk("RPC: bc_destroy xprt %p\n", xprt);
+
+ xs_xprt_free(xprt);
+ module_put(THIS_MODULE);
}
static struct rpc_xprt_ops xs_local_ops = {
--
1.8.4.2
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 3/5] SUNRPC: New helper for creating client with rpc_xprt
2014-01-09 10:31 ` [PATCH 0/5] NFSD/SUNRPC: Fix some bugs which cause memory leak for the backchannel Kinglong Mee
2014-01-09 10:31 ` [PATCH 1/5] NFSD: Using free_conn free connection Kinglong Mee
2014-01-09 10:32 ` [PATCH 2/5] NFSD: Free backchannel xprt in bc_destroy Kinglong Mee
@ 2014-01-09 10:32 ` Kinglong Mee
2014-01-09 10:33 ` [PATCH 4/5] NFSD/SUNRPC: Check rpc_xprt out of xs_setup_bc_tcp Kinglong Mee
2014-01-09 10:33 ` [PATCH 5/5] SUNRPC: Clear xpt_bc_xprt if xs_setup_bc_tcp failed Kinglong Mee
4 siblings, 0 replies; 18+ messages in thread
From: Kinglong Mee @ 2014-01-09 10:32 UTC (permalink / raw)
To: Trond Myklebust, Dr Fields James Bruce; +Cc: Linux NFS Mailing List
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
include/linux/sunrpc/clnt.h | 2 ++
net/sunrpc/clnt.c | 58 ++++++++++++++++++++++++++-------------------
2 files changed, 35 insertions(+), 25 deletions(-)
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
index 8af2804..bb9a1fa 100644
--- a/include/linux/sunrpc/clnt.h
+++ b/include/linux/sunrpc/clnt.h
@@ -130,6 +130,8 @@ struct rpc_create_args {
#define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9)
struct rpc_clnt *rpc_create(struct rpc_create_args *args);
+struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,
+ struct rpc_xprt *xprt);
struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
const struct rpc_program *, u32);
void rpc_task_reset_client(struct rpc_task *task, struct rpc_clnt *clnt);
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index b9276a6..c70da0e 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -438,6 +438,38 @@ out_no_rpciod:
return ERR_PTR(err);
}
+struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,
+ struct rpc_xprt *xprt)
+{
+ struct rpc_clnt *clnt;
+
+ clnt = rpc_new_client(args, xprt, NULL);
+ if (IS_ERR(clnt))
+ return clnt;
+
+ if (!(args->flags & RPC_CLNT_CREATE_NOPING)) {
+ int err = rpc_ping(clnt);
+ if (err != 0) {
+ rpc_shutdown_client(clnt);
+ return ERR_PTR(err);
+ }
+ }
+
+ clnt->cl_softrtry = 1;
+ if (args->flags & RPC_CLNT_CREATE_HARDRTRY)
+ clnt->cl_softrtry = 0;
+
+ if (args->flags & RPC_CLNT_CREATE_AUTOBIND)
+ clnt->cl_autobind = 1;
+ if (args->flags & RPC_CLNT_CREATE_DISCRTRY)
+ clnt->cl_discrtry = 1;
+ if (!(args->flags & RPC_CLNT_CREATE_QUIET))
+ clnt->cl_chatty = 1;
+
+ return clnt;
+}
+EXPORT_SYMBOL_GPL(rpc_create_xprt);
+
/**
* rpc_create - create an RPC client and transport with one call
* @args: rpc_clnt create argument structure
@@ -451,7 +483,6 @@ out_no_rpciod:
struct rpc_clnt *rpc_create(struct rpc_create_args *args)
{
struct rpc_xprt *xprt;
- struct rpc_clnt *clnt;
struct xprt_create xprtargs = {
.net = args->net,
.ident = args->protocol,
@@ -515,30 +546,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
if (args->flags & RPC_CLNT_CREATE_NONPRIVPORT)
xprt->resvport = 0;
- clnt = rpc_new_client(args, xprt, NULL);
- if (IS_ERR(clnt))
- return clnt;
-
- if (!(args->flags & RPC_CLNT_CREATE_NOPING)) {
- int err = rpc_ping(clnt);
- if (err != 0) {
- rpc_shutdown_client(clnt);
- return ERR_PTR(err);
- }
- }
-
- clnt->cl_softrtry = 1;
- if (args->flags & RPC_CLNT_CREATE_HARDRTRY)
- clnt->cl_softrtry = 0;
-
- if (args->flags & RPC_CLNT_CREATE_AUTOBIND)
- clnt->cl_autobind = 1;
- if (args->flags & RPC_CLNT_CREATE_DISCRTRY)
- clnt->cl_discrtry = 1;
- if (!(args->flags & RPC_CLNT_CREATE_QUIET))
- clnt->cl_chatty = 1;
-
- return clnt;
+ return rpc_create_xprt(args, xprt);
}
EXPORT_SYMBOL_GPL(rpc_create);
--
1.8.4.2
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 4/5] NFSD/SUNRPC: Check rpc_xprt out of xs_setup_bc_tcp
2014-01-09 10:31 ` [PATCH 0/5] NFSD/SUNRPC: Fix some bugs which cause memory leak for the backchannel Kinglong Mee
` (2 preceding siblings ...)
2014-01-09 10:32 ` [PATCH 3/5] SUNRPC: New helper for creating client with rpc_xprt Kinglong Mee
@ 2014-01-09 10:33 ` Kinglong Mee
2014-01-09 16:26 ` Dr Fields James Bruce
2014-01-09 10:33 ` [PATCH 5/5] SUNRPC: Clear xpt_bc_xprt if xs_setup_bc_tcp failed Kinglong Mee
4 siblings, 1 reply; 18+ messages in thread
From: Kinglong Mee @ 2014-01-09 10:33 UTC (permalink / raw)
To: Trond Myklebust, Dr Fields James Bruce; +Cc: Linux NFS Mailing List
Besides checking rpc_xprt out of xs_setup_bc_tcp,
increase it's reference (it's important).
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
fs/nfsd/nfs4callback.c | 19 ++++++++++++++++++-
include/linux/sunrpc/xprt.h | 13 ++++++++++++-
net/sunrpc/xprt.c | 12 ------------
net/sunrpc/xprtsock.c | 9 ---------
4 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index 7f05cd1..39c8ef8 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -32,6 +32,7 @@
*/
#include <linux/sunrpc/clnt.h>
+#include <linux/sunrpc/xprt.h>
#include <linux/sunrpc/svc_xprt.h>
#include <linux/slab.h>
#include "nfsd.h"
@@ -635,6 +636,22 @@ static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc
}
}
+static struct rpc_clnt *create_backchannel_client(struct rpc_create_args *args)
+{
+ struct rpc_xprt *xprt;
+
+ if (args->protocol != XPRT_TRANSPORT_BC_TCP)
+ return rpc_create(args);
+
+ xprt = args->bc_xprt->xpt_bc_xprt;
+ if (xprt) {
+ xprt_get(xprt);
+ return rpc_create_xprt(args, xprt);
+ }
+
+ return rpc_create(args);
+}
+
static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses)
{
struct rpc_timeout timeparms = {
@@ -674,7 +691,7 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c
args.authflavor = ses->se_cb_sec.flavor;
}
/* Create RPC client */
- client = rpc_create(&args);
+ client = create_backchannel_client(&args);
if (IS_ERR(client)) {
dprintk("NFSD: couldn't create callback client: %ld\n",
PTR_ERR(client));
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index 8097b9d..3e5efb2 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -295,13 +295,24 @@ int xprt_adjust_timeout(struct rpc_rqst *req);
void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task);
void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task);
void xprt_release(struct rpc_task *task);
-struct rpc_xprt * xprt_get(struct rpc_xprt *xprt);
void xprt_put(struct rpc_xprt *xprt);
struct rpc_xprt * xprt_alloc(struct net *net, size_t size,
unsigned int num_prealloc,
unsigned int max_req);
void xprt_free(struct rpc_xprt *);
+/**
+ * xprt_get - return a reference to an RPC transport.
+ * @xprt: pointer to the transport
+ *
+ */
+static inline struct rpc_xprt *xprt_get(struct rpc_xprt *xprt)
+{
+ if (atomic_inc_not_zero(&xprt->count))
+ return xprt;
+ return NULL;
+}
+
static inline __be32 *xprt_skip_transport_header(struct rpc_xprt *xprt, __be32 *p)
{
return p + xprt->tsh_size;
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index ddd198e..b0a1bbb 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -1383,15 +1383,3 @@ void xprt_put(struct rpc_xprt *xprt)
if (atomic_dec_and_test(&xprt->count))
xprt_destroy(xprt);
}
-
-/**
- * xprt_get - return a reference to an RPC transport.
- * @xprt: pointer to the transport
- *
- */
-struct rpc_xprt *xprt_get(struct rpc_xprt *xprt)
-{
- if (atomic_inc_not_zero(&xprt->count))
- return xprt;
- return NULL;
-}
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 7289e3c..37ea15a 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -2923,15 +2923,6 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args)
struct svc_sock *bc_sock;
struct rpc_xprt *ret;
- if (args->bc_xprt->xpt_bc_xprt) {
- /*
- * This server connection already has a backchannel
- * transport; we can't create a new one, as we wouldn't
- * be able to match replies based on xid any more. So,
- * reuse the already-existing one:
- */
- return args->bc_xprt->xpt_bc_xprt;
- }
xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries,
xprt_tcp_slot_table_entries);
if (IS_ERR(xprt))
--
1.8.4.2
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH 4/5] NFSD/SUNRPC: Check rpc_xprt out of xs_setup_bc_tcp
2014-01-09 10:33 ` [PATCH 4/5] NFSD/SUNRPC: Check rpc_xprt out of xs_setup_bc_tcp Kinglong Mee
@ 2014-01-09 16:26 ` Dr Fields James Bruce
2014-01-09 17:27 ` Trond Myklebust
0 siblings, 1 reply; 18+ messages in thread
From: Dr Fields James Bruce @ 2014-01-09 16:26 UTC (permalink / raw)
To: Kinglong Mee; +Cc: Trond Myklebust, Linux NFS Mailing List
On Thu, Jan 09, 2014 at 06:33:10PM +0800, Kinglong Mee wrote:
> Besides checking rpc_xprt out of xs_setup_bc_tcp,
> increase it's reference (it's important).
This sounds wrong to me: the presence of a backchannel can't prevent the
client's connection from going away. Instead, when the connection dies,
any associated backchannels should be immediately destroyed.
--b.
>
> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
> ---
> fs/nfsd/nfs4callback.c | 19 ++++++++++++++++++-
> include/linux/sunrpc/xprt.h | 13 ++++++++++++-
> net/sunrpc/xprt.c | 12 ------------
> net/sunrpc/xprtsock.c | 9 ---------
> 4 files changed, 30 insertions(+), 23 deletions(-)
>
> diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
> index 7f05cd1..39c8ef8 100644
> --- a/fs/nfsd/nfs4callback.c
> +++ b/fs/nfsd/nfs4callback.c
> @@ -32,6 +32,7 @@
> */
>
> #include <linux/sunrpc/clnt.h>
> +#include <linux/sunrpc/xprt.h>
> #include <linux/sunrpc/svc_xprt.h>
> #include <linux/slab.h>
> #include "nfsd.h"
> @@ -635,6 +636,22 @@ static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc
> }
> }
>
> +static struct rpc_clnt *create_backchannel_client(struct rpc_create_args *args)
> +{
> + struct rpc_xprt *xprt;
> +
> + if (args->protocol != XPRT_TRANSPORT_BC_TCP)
> + return rpc_create(args);
> +
> + xprt = args->bc_xprt->xpt_bc_xprt;
> + if (xprt) {
> + xprt_get(xprt);
> + return rpc_create_xprt(args, xprt);
> + }
> +
> + return rpc_create(args);
> +}
> +
> static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses)
> {
> struct rpc_timeout timeparms = {
> @@ -674,7 +691,7 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c
> args.authflavor = ses->se_cb_sec.flavor;
> }
> /* Create RPC client */
> - client = rpc_create(&args);
> + client = create_backchannel_client(&args);
> if (IS_ERR(client)) {
> dprintk("NFSD: couldn't create callback client: %ld\n",
> PTR_ERR(client));
> diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
> index 8097b9d..3e5efb2 100644
> --- a/include/linux/sunrpc/xprt.h
> +++ b/include/linux/sunrpc/xprt.h
> @@ -295,13 +295,24 @@ int xprt_adjust_timeout(struct rpc_rqst *req);
> void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task);
> void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task);
> void xprt_release(struct rpc_task *task);
> -struct rpc_xprt * xprt_get(struct rpc_xprt *xprt);
> void xprt_put(struct rpc_xprt *xprt);
> struct rpc_xprt * xprt_alloc(struct net *net, size_t size,
> unsigned int num_prealloc,
> unsigned int max_req);
> void xprt_free(struct rpc_xprt *);
>
> +/**
> + * xprt_get - return a reference to an RPC transport.
> + * @xprt: pointer to the transport
> + *
> + */
> +static inline struct rpc_xprt *xprt_get(struct rpc_xprt *xprt)
> +{
> + if (atomic_inc_not_zero(&xprt->count))
> + return xprt;
> + return NULL;
> +}
> +
> static inline __be32 *xprt_skip_transport_header(struct rpc_xprt *xprt, __be32 *p)
> {
> return p + xprt->tsh_size;
> diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
> index ddd198e..b0a1bbb 100644
> --- a/net/sunrpc/xprt.c
> +++ b/net/sunrpc/xprt.c
> @@ -1383,15 +1383,3 @@ void xprt_put(struct rpc_xprt *xprt)
> if (atomic_dec_and_test(&xprt->count))
> xprt_destroy(xprt);
> }
> -
> -/**
> - * xprt_get - return a reference to an RPC transport.
> - * @xprt: pointer to the transport
> - *
> - */
> -struct rpc_xprt *xprt_get(struct rpc_xprt *xprt)
> -{
> - if (atomic_inc_not_zero(&xprt->count))
> - return xprt;
> - return NULL;
> -}
> diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
> index 7289e3c..37ea15a 100644
> --- a/net/sunrpc/xprtsock.c
> +++ b/net/sunrpc/xprtsock.c
> @@ -2923,15 +2923,6 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args)
> struct svc_sock *bc_sock;
> struct rpc_xprt *ret;
>
> - if (args->bc_xprt->xpt_bc_xprt) {
> - /*
> - * This server connection already has a backchannel
> - * transport; we can't create a new one, as we wouldn't
> - * be able to match replies based on xid any more. So,
> - * reuse the already-existing one:
> - */
> - return args->bc_xprt->xpt_bc_xprt;
> - }
> xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries,
> xprt_tcp_slot_table_entries);
> if (IS_ERR(xprt))
> --
> 1.8.4.2
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 4/5] NFSD/SUNRPC: Check rpc_xprt out of xs_setup_bc_tcp
2014-01-09 16:26 ` Dr Fields James Bruce
@ 2014-01-09 17:27 ` Trond Myklebust
2014-01-10 2:41 ` Kinglong Mee
0 siblings, 1 reply; 18+ messages in thread
From: Trond Myklebust @ 2014-01-09 17:27 UTC (permalink / raw)
To: Dr Fields James Bruce; +Cc: Kinglong Mee, Linux NFS Mailing List
On Jan 9, 2014, at 11:26, Dr Fields James Bruce <bfields@fieldses.org> wrote:
> On Thu, Jan 09, 2014 at 06:33:10PM +0800, Kinglong Mee wrote:
>> Besides checking rpc_xprt out of xs_setup_bc_tcp,
>> increase it's reference (it's important).
>
> This sounds wrong to me: the presence of a backchannel can't prevent the
> client's connection from going away. Instead, when the connection dies,
> any associated backchannels should be immediately destroyed.
Hi Bruce,
The right way to deal with this is to have knfsd shut down the rpc_client when it detects the TCP disconnection event. The xprt->count shouldn’t be an issue here: it has nothing to do with the socket connection state.
Cheers
Trond
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 4/5] NFSD/SUNRPC: Check rpc_xprt out of xs_setup_bc_tcp
2014-01-09 17:27 ` Trond Myklebust
@ 2014-01-10 2:41 ` Kinglong Mee
2014-01-27 23:08 ` Dr Fields James Bruce
0 siblings, 1 reply; 18+ messages in thread
From: Kinglong Mee @ 2014-01-10 2:41 UTC (permalink / raw)
To: Trond Myklebust, Dr Fields James Bruce; +Cc: Linux NFS Mailing List
On 01/10/2014 01:27 AM, Trond Myklebust wrote:
>
> On Jan 9, 2014, at 11:26, Dr Fields James Bruce <bfields@fieldses.org> wrote:
>
>> On Thu, Jan 09, 2014 at 06:33:10PM +0800, Kinglong Mee wrote:
>>> Besides checking rpc_xprt out of xs_setup_bc_tcp,
>>> increase it's reference (it's important).
>>
>> This sounds wrong to me: the presence of a backchannel can't prevent the
>> client's connection from going away. Instead, when the connection dies,
>> any associated backchannels should be immediately destroyed.
>
> Hi Bruce,
>
> The right way to deal with this is to have knfsd shut down the rpc_client
> when it detects the TCP disconnection event.
Yes, that's right.
Knfsd has do it as you said.
When getting xprt's status of XPT_CLOSE in svc_recv/svc_handle_xprt,
knfsd will delete the xprt by svc_delete_xprt.
In svc_delete_xprt, knfsd calls call_xpt_users to notify those users of the xprt.
So, nfsd4_conn_lost will be called to free the connection.
After freeing connection, nfsd4_probe_callback will update the callback for the client.
And, the clp->cl_cb_client will be shutdown in nfsd4_process_cb_update.
At last, all using of the xprt will be released.
I have test it, that's OK.
> The xprt->count shouldn’t be an issue here:
> it has nothing to do with the socket connection state.
The xprt of backchannel, there are two references,
1. rpc_clnt
2. svc_xprt
For rpc_clnt, initialize the xprt->count in xs_setup_bc_tcp,
or increase it in create_backchannel_client, and, decrease in rpc_free_client.
For svc_xprt, increase it in xs_setup_bc_tcp, and decrease in svc_xprt_free.
thanks,
Kinglong Mee
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 4/5] NFSD/SUNRPC: Check rpc_xprt out of xs_setup_bc_tcp
2014-01-10 2:41 ` Kinglong Mee
@ 2014-01-27 23:08 ` Dr Fields James Bruce
2014-02-11 12:08 ` Kinglong Mee
0 siblings, 1 reply; 18+ messages in thread
From: Dr Fields James Bruce @ 2014-01-27 23:08 UTC (permalink / raw)
To: Kinglong Mee; +Cc: Trond Myklebust, Linux NFS Mailing List
Apologies, I completely dropped this and now I've lost the thread of the
discussion.
What is your most recent patchset?
--b.
On Fri, Jan 10, 2014 at 10:41:24AM +0800, Kinglong Mee wrote:
> On 01/10/2014 01:27 AM, Trond Myklebust wrote:
> >
> > On Jan 9, 2014, at 11:26, Dr Fields James Bruce <bfields@fieldses.org> wrote:
> >
> >> On Thu, Jan 09, 2014 at 06:33:10PM +0800, Kinglong Mee wrote:
> >>> Besides checking rpc_xprt out of xs_setup_bc_tcp,
> >>> increase it's reference (it's important).
> >>
> >> This sounds wrong to me: the presence of a backchannel can't prevent the
> >> client's connection from going away. Instead, when the connection dies,
> >> any associated backchannels should be immediately destroyed.
> >
> > Hi Bruce,
> >
> > The right way to deal with this is to have knfsd shut down the rpc_client
> > when it detects the TCP disconnection event.
>
> Yes, that's right.
> Knfsd has do it as you said.
>
> When getting xprt's status of XPT_CLOSE in svc_recv/svc_handle_xprt,
> knfsd will delete the xprt by svc_delete_xprt.
>
> In svc_delete_xprt, knfsd calls call_xpt_users to notify those users of the xprt.
> So, nfsd4_conn_lost will be called to free the connection.
> After freeing connection, nfsd4_probe_callback will update the callback for the client.
> And, the clp->cl_cb_client will be shutdown in nfsd4_process_cb_update.
>
> At last, all using of the xprt will be released.
> I have test it, that's OK.
>
> > The xprt->count shouldn’t be an issue here:
> > it has nothing to do with the socket connection state.
>
> The xprt of backchannel, there are two references,
> 1. rpc_clnt
> 2. svc_xprt
>
> For rpc_clnt, initialize the xprt->count in xs_setup_bc_tcp,
> or increase it in create_backchannel_client, and, decrease in rpc_free_client.
>
> For svc_xprt, increase it in xs_setup_bc_tcp, and decrease in svc_xprt_free.
>
> thanks,
> Kinglong Mee
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 4/5] NFSD/SUNRPC: Check rpc_xprt out of xs_setup_bc_tcp
2014-01-27 23:08 ` Dr Fields James Bruce
@ 2014-02-11 12:08 ` Kinglong Mee
0 siblings, 0 replies; 18+ messages in thread
From: Kinglong Mee @ 2014-02-11 12:08 UTC (permalink / raw)
To: Dr Fields James Bruce; +Cc: Trond Myklebust, Linux NFS Mailing List
Dear Bruce,
I am sorry for replying so late.
I will resend those patchs again.
thanks,
Kinglong Mee
On Tue, Jan 28, 2014 at 7:08 AM, Dr Fields James Bruce
<bfields@fieldses.org> wrote:
> Apologies, I completely dropped this and now I've lost the thread of the
> discussion.
>
> What is your most recent patchset?
>
> --b.
>
> On Fri, Jan 10, 2014 at 10:41:24AM +0800, Kinglong Mee wrote:
>> On 01/10/2014 01:27 AM, Trond Myklebust wrote:
>> >
>> > On Jan 9, 2014, at 11:26, Dr Fields James Bruce <bfields@fieldses.org> wrote:
>> >
>> >> On Thu, Jan 09, 2014 at 06:33:10PM +0800, Kinglong Mee wrote:
>> >>> Besides checking rpc_xprt out of xs_setup_bc_tcp,
>> >>> increase it's reference (it's important).
>> >>
>> >> This sounds wrong to me: the presence of a backchannel can't prevent the
>> >> client's connection from going away. Instead, when the connection dies,
>> >> any associated backchannels should be immediately destroyed.
>> >
>> > Hi Bruce,
>> >
>> > The right way to deal with this is to have knfsd shut down the rpc_client
>> > when it detects the TCP disconnection event.
>>
>> Yes, that's right.
>> Knfsd has do it as you said.
>>
>> When getting xprt's status of XPT_CLOSE in svc_recv/svc_handle_xprt,
>> knfsd will delete the xprt by svc_delete_xprt.
>>
>> In svc_delete_xprt, knfsd calls call_xpt_users to notify those users of the xprt.
>> So, nfsd4_conn_lost will be called to free the connection.
>> After freeing connection, nfsd4_probe_callback will update the callback for the client.
>> And, the clp->cl_cb_client will be shutdown in nfsd4_process_cb_update.
>>
>> At last, all using of the xprt will be released.
>> I have test it, that's OK.
>>
>> > The xprt->count shouldn't be an issue here:
>> > it has nothing to do with the socket connection state.
>>
>> The xprt of backchannel, there are two references,
>> 1. rpc_clnt
>> 2. svc_xprt
>>
>> For rpc_clnt, initialize the xprt->count in xs_setup_bc_tcp,
>> or increase it in create_backchannel_client, and, decrease in rpc_free_client.
>>
>> For svc_xprt, increase it in xs_setup_bc_tcp, and decrease in svc_xprt_free.
>>
>> thanks,
>> Kinglong Mee
>>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 5/5] SUNRPC: Clear xpt_bc_xprt if xs_setup_bc_tcp failed
2014-01-09 10:31 ` [PATCH 0/5] NFSD/SUNRPC: Fix some bugs which cause memory leak for the backchannel Kinglong Mee
` (3 preceding siblings ...)
2014-01-09 10:33 ` [PATCH 4/5] NFSD/SUNRPC: Check rpc_xprt out of xs_setup_bc_tcp Kinglong Mee
@ 2014-01-09 10:33 ` Kinglong Mee
4 siblings, 0 replies; 18+ messages in thread
From: Kinglong Mee @ 2014-01-09 10:33 UTC (permalink / raw)
To: Trond Myklebust, Dr Fields James Bruce; +Cc: Linux NFS Mailing List
Don't move the assign of args->bc_xprt->xpt_bc_xprt out of xs_setup_bc_tcp,
because rpc_ping (which is in rpc_create) will using it.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
net/sunrpc/xprtsock.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 37ea15a..c996ace 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -2981,9 +2981,10 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args)
*/
xprt_set_connected(xprt);
-
if (try_module_get(THIS_MODULE))
return xprt;
+
+ args->bc_xprt->xpt_bc_xprt = NULL;
xprt_put(xprt);
ret = ERR_PTR(-EINVAL);
out_err:
--
1.8.4.2
^ permalink raw reply related [flat|nested] 18+ messages in thread