diff mbox

[RFC,v0,47/49] pnfsd: pnfs_expire_client

Message ID 1380220987-14853-1-git-send-email-bhalevy@primarydata.com (mailing list archive)
State New, archived
Headers show

Commit Message

Benny Halevy Sept. 26, 2013, 6:43 p.m. UTC
Destroy the client layout state upon expiry.

pnfs_return_client_layouts is used to locate the related layout state
as if the client returned all of its layouts via RETURN_ALL with IOMODE_ANY.

Signed-off-by: Benny Halevy <bhalevy@primarydata.com>
---
 fs/nfsd/nfs4pnfsd.c | 22 ++++++++++++++++++++++
 fs/nfsd/nfs4state.c |  1 +
 fs/nfsd/state.h     |  2 ++
 3 files changed, 25 insertions(+)
diff mbox

Patch

diff --git a/fs/nfsd/nfs4pnfsd.c b/fs/nfsd/nfs4pnfsd.c
index 2ba4a29..d18e2a1 100644
--- a/fs/nfsd/nfs4pnfsd.c
+++ b/fs/nfsd/nfs4pnfsd.c
@@ -862,3 +862,25 @@  int nfs4_pnfs_return_layout(struct svc_rqst *rqstp,
 	dprintk("pNFS %s: exit status %d\n", __func__, status);
 	return status;
 }
+
+/*
+ * Note: must be called under the state lock
+ */
+void pnfs_expire_client(struct nfs4_client *clp)
+{
+	struct nfsd4_pnfs_layoutreturn lr = {
+		.args.lr_return_type = RETURN_ALL,
+		.args.lr_seg = {
+			.iomode = IOMODE_ANY,
+			.offset = 0,
+			.length = NFS4_MAX_UINT64,
+		},
+	};
+	LIST_HEAD(lo_destroy_list);
+
+	nfs4_assert_state_locked();
+
+	pnfs_return_client_layouts(clp, &lr, 0, &lo_destroy_list);
+
+	destroy_layout_list(&lo_destroy_list);
+}
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index a9bd82b..600edbc 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -1172,6 +1172,7 @@  static struct nfs4_client *alloc_client(struct xdr_netobj name)
 		oo = list_entry(clp->cl_openowners.next, struct nfs4_openowner, oo_perclient);
 		release_openowner(oo);
 	}
+	pnfs_expire_client(clp);
 	nfsd4_shutdown_callback(clp);
 	if (clp->cl_cb_conn.cb_xprt)
 		svc_xprt_put(clp->cl_cb_conn.cb_xprt);
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
index d2c75c5..90ec8b9 100644
--- a/fs/nfsd/state.h
+++ b/fs/nfsd/state.h
@@ -506,9 +506,11 @@  extern struct nfs4_client_reclaim *nfs4_client_to_reclaim(const char *name,
 #if defined(CONFIG_PNFSD)
 extern int nfsd4_init_pnfs_slabs(void);
 extern void nfsd4_free_pnfs_slabs(void);
+extern void pnfs_expire_client(struct nfs4_client *);
 #else /* CONFIG_PNFSD */
 static inline void nfsd4_free_pnfs_slabs(void) {}
 static inline int nfsd4_init_pnfs_slabs(void) { return 0; }
+static inline void pnfs_expire_client(struct nfs4_client *clp) {}
 #endif /* CONFIG_PNFSD */
 
 static inline u64