Linux NFS development
 help / color / mirror / Atom feed
From: andros@netapp.com
To: trond.myklebust@netapp.com
Cc: linux-nfs@vger.kernel.org, Andy Adamson <andros@netapp.com>
Subject: [PATCH Version 2 10/12] NFSv4.1 de reference a disconnected data server client record
Date: Wed, 21 Mar 2012 15:46:22 -0400	[thread overview]
Message-ID: <1332359184-1887-11-git-send-email-andros@netapp.com> (raw)
In-Reply-To: <1332359184-1887-1-git-send-email-andros@netapp.com>

From: Andy Adamson <andros@netapp.com>

When the last DS io is processed, the data server client record will be
freed.

Signed-off-by: Andy Adamson <andros@netapp.com>
---
 fs/nfs/nfs4filelayout.c    |    4 ++++
 fs/nfs/nfs4filelayout.h    |    1 +
 fs/nfs/nfs4filelayoutdev.c |   17 +++++++++++++++++
 3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index 129b57f..ee0159b 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -209,10 +209,12 @@ static int filelayout_read_done_cb(struct rpc_task *task,
 			reset, data->ds_clp, data->ds_clp->cl_session);
 
 		if (test_bit(NFS4_RESET_TO_MDS, &reset)) {
+			struct nfs_client *clp = data->ds_clp;
 			filelayout_reset_read(task, data);
 			if (test_bit(NFS4_RESET_DEVICEID, &reset)) {
 				filelayout_mark_devid_invalid(devid);
 				rpc_wake_up(&tbl->slot_tbl_waitq);
+				nfs4_ds_disconnect(clp);
 			}
 		}
 		rpc_restart_call_prepare(task);
@@ -304,10 +306,12 @@ static int filelayout_write_done_cb(struct rpc_task *task,
 			reset, data->ds_clp, data->ds_clp->cl_session);
 
 		if (test_bit(NFS4_RESET_TO_MDS, &reset)) {
+			struct nfs_client *clp = data->ds_clp;
 			filelayout_reset_write(task, data);
 			if (test_bit(NFS4_RESET_DEVICEID, &reset)) {
 				filelayout_mark_devid_invalid(devid);
 				rpc_wake_up(&tbl->slot_tbl_waitq);
+				nfs4_ds_disconnect(clp);
 			}
 		}
 		rpc_restart_call_prepare(task);
diff --git a/fs/nfs/nfs4filelayout.h b/fs/nfs/nfs4filelayout.h
index 08b667a..3abf7d9 100644
--- a/fs/nfs/nfs4filelayout.h
+++ b/fs/nfs/nfs4filelayout.h
@@ -138,5 +138,6 @@ 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 *
 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 2b8ae96..0e54cdf 100644
--- a/fs/nfs/nfs4filelayoutdev.c
+++ b/fs/nfs/nfs4filelayoutdev.c
@@ -145,6 +145,23 @@ _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;
+
+	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) {
+			nfs_put_client(clp);
+			ds->ds_clp = NULL;
+		}
+	spin_unlock(&nfs4_ds_cache_lock);
+}
+
+/*
  * Create an rpc connection to the nfs4_pnfs_ds data server
  * Currently only supports IPv4 and IPv6 addresses
  */
-- 
1.7.6.4


  parent reply	other threads:[~2012-03-21 19:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-21 19:46 [PATCH Version 2 00/12] NFSv4.1 file layout data server quick failover andros
2012-03-21 19:46 ` [PATCH Version 2 01/12] NFSv4.1 move nfs4_reset_read and nfs_reset_write andros
2012-03-21 19:46 ` [PATCH Version 2 02/12] NFSv4.1: cleanup filelayout invalid deviceid handling andros
2012-03-21 19:46 ` [PATCH Version 2 03/12] NFSv4.1 cleanup filelayout invalid layout handling andros
2012-03-21 19:46 ` [PATCH Version 2 04/12] NFSv4.1 set RPC_TASK_SOFTCONN for filelayout DS RPC calls andros
2012-03-21 19:46 ` [PATCH Version 2 05/12] NFSv4.1: mark deviceid invalid on filelayout DS connection errors andros
2012-03-21 20:39   ` Myklebust, Trond
2012-03-22 13:23     ` Adamson, Andy
2012-03-22 13:44       ` Myklebust, Trond
2012-03-22 13:53         ` Andy Adamson
2012-03-21 19:46 ` [PATCH Version 2 06/12] NFSv4.1: send filelayout DS commits to the MDS on invalid deviceid andros
2012-03-21 19:46 ` [PATCH Version 2 07/12] NFSv4.1 Check invalid deviceid upon slot table waitq wakeup andros
2012-03-21 19:46 ` [PATCH Version 2 08/12] NFSv4.1 wake up all tasks on un-connected DS slot table waitq andros
2012-03-21 19:46 ` [PATCH Version 2 09/12] NFSv4.1 ref count nfs_client across filelayout data server io andros
2012-03-21 19:46 ` andros [this message]
2012-03-21 19:46 ` [PATCH Version 2 11/12] NFSv4.1 check for NULL pnfs_layout_hdr in pnfs scan commit lists andros
2012-03-21 19:46 ` [PATCH Version 2 12/12] NFSv4.1 have filelayout_initiate_commit return void andros
2012-03-21 20:47   ` Myklebust, Trond
2012-03-25 14:59     ` Fred Isaman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1332359184-1887-11-git-send-email-andros@netapp.com \
    --to=andros@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@netapp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox