* [PATCH] NFSv4.1: Kill nfs4_ds_disconnect()
@ 2012-10-11 16:51 Trond Myklebust
2012-10-11 17:50 ` Andy Adamson
0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2012-10-11 16:51 UTC (permalink / raw)
To: linux-nfs
There is nothing to prevent another thread from dereferencing ds->ds_clp
during or after the call to nfs4_ds_disconnect(), and Oopsing due to the
resulting NULL pointer.
Instead, we should just rely on filelayout_mark_devid_invalid() to keep
us out of trouble by avoiding that deviceid.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---
fs/nfs/nfs4filelayout.c | 1 -
fs/nfs/nfs4filelayout.h | 1 -
fs/nfs/nfs4filelayoutdev.c | 22 ----------------------
3 files changed, 24 deletions(-)
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index 52d8472..816c2d0 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -207,7 +207,6 @@ static int filelayout_async_handle_error(struct rpc_task *task,
clear_bit(NFS_INO_LAYOUTCOMMIT, &NFS_I(inode)->flags);
_pnfs_return_layout(inode);
rpc_wake_up(&tbl->slot_tbl_waitq);
- nfs4_ds_disconnect(clp);
/* fall through */
default:
reset:
diff --git a/fs/nfs/nfs4filelayout.h b/fs/nfs/nfs4filelayout.h
index dca47d78..8c07241 100644
--- a/fs/nfs/nfs4filelayout.h
+++ b/fs/nfs/nfs4filelayout.h
@@ -149,6 +149,5 @@ extern void nfs4_fl_put_deviceid(struct nfs4_file_layout_dsaddr *dsaddr);
extern void nfs4_fl_free_deviceid(struct nfs4_file_layout_dsaddr *dsaddr);
struct nfs4_file_layout_dsaddr *
filelayout_get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id, gfp_t gfp_flags);
-void nfs4_ds_disconnect(struct nfs_client *clp);
#endif /* FS_NFS_NFS4FILELAYOUT_H */
diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c
index 3336d5e..a8eaa9b 100644
--- a/fs/nfs/nfs4filelayoutdev.c
+++ b/fs/nfs/nfs4filelayoutdev.c
@@ -149,28 +149,6 @@ _data_server_lookup_locked(const struct list_head *dsaddrs)
}
/*
- * Lookup DS by nfs_client pointer. Zero data server client pointer
- */
-void nfs4_ds_disconnect(struct nfs_client *clp)
-{
- struct nfs4_pnfs_ds *ds;
- struct nfs_client *found = NULL;
-
- dprintk("%s clp %p\n", __func__, clp);
- spin_lock(&nfs4_ds_cache_lock);
- list_for_each_entry(ds, &nfs4_data_server_cache, ds_node)
- if (ds->ds_clp && ds->ds_clp == clp) {
- found = ds->ds_clp;
- ds->ds_clp = NULL;
- }
- spin_unlock(&nfs4_ds_cache_lock);
- if (found) {
- set_bit(NFS_CS_STOP_RENEW, &clp->cl_res_state);
- nfs_put_client(clp);
- }
-}
-
-/*
* Create an rpc connection to the nfs4_pnfs_ds data server
* Currently only supports IPv4 and IPv6 addresses
*/
--
1.7.11.7
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] NFSv4.1: Kill nfs4_ds_disconnect()
2012-10-11 16:51 [PATCH] NFSv4.1: Kill nfs4_ds_disconnect() Trond Myklebust
@ 2012-10-11 17:50 ` Andy Adamson
2012-10-11 18:19 ` Myklebust, Trond
0 siblings, 1 reply; 3+ messages in thread
From: Andy Adamson @ 2012-10-11 17:50 UTC (permalink / raw)
To: Trond Myklebust; +Cc: linux-nfs
On Thu, Oct 11, 2012 at 12:51 PM, Trond Myklebust
<Trond.Myklebust@netapp.com> wrote:
> There is nothing to prevent another thread from dereferencing ds->ds_clp
> during or after the call to nfs4_ds_disconnect(), and Oopsing due to the
> resulting NULL pointer.
Yes.
>
> Instead, we should just rely on filelayout_mark_devid_invalid() to keep
> us out of trouble by avoiding that deviceid.
Why do we want to keep the connection and the nfs_client? For connection retry?
-->Andy
>
> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
> ---
> fs/nfs/nfs4filelayout.c | 1 -
> fs/nfs/nfs4filelayout.h | 1 -
> fs/nfs/nfs4filelayoutdev.c | 22 ----------------------
> 3 files changed, 24 deletions(-)
>
> diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
> index 52d8472..816c2d0 100644
> --- a/fs/nfs/nfs4filelayout.c
> +++ b/fs/nfs/nfs4filelayout.c
> @@ -207,7 +207,6 @@ static int filelayout_async_handle_error(struct rpc_task *task,
> clear_bit(NFS_INO_LAYOUTCOMMIT, &NFS_I(inode)->flags);
> _pnfs_return_layout(inode);
> rpc_wake_up(&tbl->slot_tbl_waitq);
> - nfs4_ds_disconnect(clp);
> /* fall through */
> default:
> reset:
> diff --git a/fs/nfs/nfs4filelayout.h b/fs/nfs/nfs4filelayout.h
> index dca47d78..8c07241 100644
> --- a/fs/nfs/nfs4filelayout.h
> +++ b/fs/nfs/nfs4filelayout.h
> @@ -149,6 +149,5 @@ extern void nfs4_fl_put_deviceid(struct nfs4_file_layout_dsaddr *dsaddr);
> extern void nfs4_fl_free_deviceid(struct nfs4_file_layout_dsaddr *dsaddr);
> struct nfs4_file_layout_dsaddr *
> filelayout_get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id, gfp_t gfp_flags);
> -void nfs4_ds_disconnect(struct nfs_client *clp);
>
> #endif /* FS_NFS_NFS4FILELAYOUT_H */
> diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c
> index 3336d5e..a8eaa9b 100644
> --- a/fs/nfs/nfs4filelayoutdev.c
> +++ b/fs/nfs/nfs4filelayoutdev.c
> @@ -149,28 +149,6 @@ _data_server_lookup_locked(const struct list_head *dsaddrs)
> }
>
> /*
> - * Lookup DS by nfs_client pointer. Zero data server client pointer
> - */
> -void nfs4_ds_disconnect(struct nfs_client *clp)
> -{
> - struct nfs4_pnfs_ds *ds;
> - struct nfs_client *found = NULL;
> -
> - dprintk("%s clp %p\n", __func__, clp);
> - spin_lock(&nfs4_ds_cache_lock);
> - list_for_each_entry(ds, &nfs4_data_server_cache, ds_node)
> - if (ds->ds_clp && ds->ds_clp == clp) {
> - found = ds->ds_clp;
> - ds->ds_clp = NULL;
> - }
> - spin_unlock(&nfs4_ds_cache_lock);
> - if (found) {
> - set_bit(NFS_CS_STOP_RENEW, &clp->cl_res_state);
> - nfs_put_client(clp);
> - }
> -}
> -
> -/*
> * Create an rpc connection to the nfs4_pnfs_ds data server
> * Currently only supports IPv4 and IPv6 addresses
> */
> --
> 1.7.11.7
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] NFSv4.1: Kill nfs4_ds_disconnect()
2012-10-11 17:50 ` Andy Adamson
@ 2012-10-11 18:19 ` Myklebust, Trond
0 siblings, 0 replies; 3+ messages in thread
From: Myklebust, Trond @ 2012-10-11 18:19 UTC (permalink / raw)
To: Andy Adamson; +Cc: linux-nfs
> -----Original Message-----
> From: Andy Adamson [mailto:androsadamson@gmail.com]
> Sent: Thursday, October 11, 2012 1:51 PM
> To: Myklebust, Trond
> Cc: linux-nfs@vger.kernel.org
> Subject: Re: [PATCH] NFSv4.1: Kill nfs4_ds_disconnect()
>
> On Thu, Oct 11, 2012 at 12:51 PM, Trond Myklebust
> <Trond.Myklebust@netapp.com> wrote:
> > There is nothing to prevent another thread from dereferencing
> > ds->ds_clp during or after the call to nfs4_ds_disconnect(), and
> > Oopsing due to the resulting NULL pointer.
>
> Yes.
>
> >
> > Instead, we should just rely on filelayout_mark_devid_invalid() to
> > keep us out of trouble by avoiding that deviceid.
>
> Why do we want to keep the connection and the nfs_client? For connection
> retry?
>
The deviceid doesn't really want to keep the nfs_client, but I don't see how you can remove it safely in the current code. There is too much that relies on being able to dereference ds->ds_clp without any locking.
As for the TCP connection: that is a property of the nfs_client and its RPC client, and as such should not be manipulated by pNFS. If there are other users, then they may be waiting for it to reconnect...
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-10-11 18:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-11 16:51 [PATCH] NFSv4.1: Kill nfs4_ds_disconnect() Trond Myklebust
2012-10-11 17:50 ` Andy Adamson
2012-10-11 18:19 ` Myklebust, Trond
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.