All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH v2 10/33] NFS: Add a slot table to struct nfs_client for NFSv4.0 transport blocking
Date: Fri, 09 Aug 2013 12:49:11 -0400	[thread overview]
Message-ID: <20130809164910.5362.84774.stgit@seurat.1015granger.net> (raw)
In-Reply-To: <20130809161957.5362.90865.stgit@seurat.1015granger.net>

Anchor an nfs4_slot_table in the nfs_client for use with NFSv4.0
transport blocking.  It is initialized only for NFSv4.0 nfs_client's.

Introduce appropriate minor version ops to handle nfs_client
initialization and shutdown requirements that differ for each minor
version.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 fs/nfs/nfs4_fs.h          |    6 +++
 fs/nfs/nfs4client.c       |  101 +++++++++++++++++++++++++++++++++------------
 fs/nfs/nfs4proc.c         |    6 +++
 include/linux/nfs_fs_sb.h |    3 +
 4 files changed, 89 insertions(+), 27 deletions(-)

diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 8de9b93..af2d5bf 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -38,6 +38,8 @@ struct nfs4_minor_version_ops {
 	u32	minor_version;
 	unsigned init_caps;
 
+	int	(*init_client)(struct nfs_client *);
+	void	(*shutdown_client)(struct nfs_client *);
 	bool	(*match_stateid)(const nfs4_stateid *,
 			const nfs4_stateid *);
 	int	(*find_root_sec)(struct nfs_server *, struct nfs_fh *,
@@ -292,6 +294,10 @@ extern const u32 nfs4_pathconf_bitmap[3];
 extern const u32 nfs4_fsinfo_bitmap[3];
 extern const u32 nfs4_fs_locations_bitmap[3];
 
+void nfs40_shutdown_client(struct nfs_client *);
+void nfs41_shutdown_client(struct nfs_client *);
+int nfs40_init_client(struct nfs_client *);
+int nfs41_init_client(struct nfs_client *);
 void nfs4_free_client(struct nfs_client *);
 
 struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *);
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 90dce91..eedd686 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -41,7 +41,7 @@ static int nfs_get_cb_ident_idr(struct nfs_client *clp, int minorversion)
 }
 
 #ifdef CONFIG_NFS_V4_1
-static void nfs4_shutdown_session(struct nfs_client *clp)
+void nfs41_shutdown_client(struct nfs_client *clp)
 {
 	if (nfs4_has_session(clp)) {
 		nfs4_destroy_session(clp->cl_session);
@@ -49,11 +49,15 @@ static void nfs4_shutdown_session(struct nfs_client *clp)
 	}
 
 }
-#else /* CONFIG_NFS_V4_1 */
-static void nfs4_shutdown_session(struct nfs_client *clp)
+#endif	/* CONFIG_NFS_V4_1 */
+
+void nfs40_shutdown_client(struct nfs_client *clp)
 {
+	if (clp->cl_slot_tbl) {
+		nfs4_release_slot_table(clp->cl_slot_tbl);
+		kfree(clp->cl_slot_tbl);
+	}
 }
-#endif /* CONFIG_NFS_V4_1 */
 
 struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
 {
@@ -97,7 +101,7 @@ static void nfs4_shutdown_client(struct nfs_client *clp)
 {
 	if (__test_and_clear_bit(NFS_CS_RENEWD, &clp->cl_res_state))
 		nfs4_kill_renewd(clp);
-	nfs4_shutdown_session(clp);
+	clp->cl_mvops->shutdown_client(clp);
 	nfs4_destroy_callback(clp);
 	if (__test_and_clear_bit(NFS_CS_IDMAP, &clp->cl_res_state))
 		nfs_idmap_delete(clp);
@@ -144,34 +148,77 @@ static int nfs4_init_callback(struct nfs_client *clp)
 	return 0;
 }
 
+/**
+ * nfs40_init_client - nfs_client initialization tasks for NFSv4.0
+ * @clp - nfs_client to initialize
+ *
+ * Returns zero on success, or a negative errno if some error occurred.
+ */
+int nfs40_init_client(struct nfs_client *clp)
+{
+	struct nfs4_slot_table *tbl;
+	int ret;
+
+	tbl = kzalloc(sizeof(*tbl), GFP_NOFS);
+	if (tbl == NULL)
+		return -ENOMEM;
+
+	ret = nfs4_setup_slot_table(tbl, NFS4_MAX_SLOT_TABLE,
+					"NFSv4.0 transport Slot table");
+	if (ret) {
+		kfree(tbl);
+		return ret;
+	}
+
+	clp->cl_slot_tbl = tbl;
+	return 0;
+}
+
+#if defined(CONFIG_NFS_V4_1)
+
+/**
+ * nfs41_init_client - nfs_client initialization tasks for NFSv4.1+
+ * @clp - nfs_client to initialize
+ *
+ * Returns zero on success, or a negative errno if some error occurred.
+ */
+int nfs41_init_client(struct nfs_client *clp)
+{
+	struct nfs4_session *session = NULL;
+
+	/*
+	 * Create the session and mark it expired.
+	 * When a SEQUENCE operation encounters the expired session
+	 * it will do session recovery to initialize it.
+	 */
+	session = nfs4_alloc_session(clp);
+	if (!session)
+		return -ENOMEM;
+
+	clp->cl_session = session;
+
+	/*
+	 * The create session reply races with the server back
+	 * channel probe. Mark the client NFS_CS_SESSION_INITING
+	 * so that the client back channel can find the
+	 * nfs_client struct
+	 */
+	nfs_mark_client_ready(clp, NFS_CS_SESSION_INITING);
+	return 0;
+}
+
+#endif	/* CONFIG_NFS_V4_1 */
+
 /*
  * Initialize the minor version specific parts of an NFS4 client record
  */
 static int nfs4_init_client_minor_version(struct nfs_client *clp)
 {
-#if defined(CONFIG_NFS_V4_1)
-	if (clp->cl_mvops->minor_version) {
-		struct nfs4_session *session = NULL;
-		/*
-		 * Create the session and mark it expired.
-		 * When a SEQUENCE operation encounters the expired session
-		 * it will do session recovery to initialize it.
-		 */
-		session = nfs4_alloc_session(clp);
-		if (!session)
-			return -ENOMEM;
-
-		clp->cl_session = session;
-		/*
-		 * The create session reply races with the server back
-		 * channel probe. Mark the client NFS_CS_SESSION_INITING
-		 * so that the client back channel can find the
-		 * nfs_client struct
-		 */
-		nfs_mark_client_ready(clp, NFS_CS_SESSION_INITING);
-	}
-#endif /* CONFIG_NFS_V4_1 */
+	int ret;
 
+	ret = clp->cl_mvops->init_client(clp);
+	if (ret)
+		return ret;
 	return nfs4_init_callback(clp);
 }
 
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 0ba7e35..4352d51 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -7417,6 +7417,8 @@ static const struct nfs4_minor_version_ops nfs_v4_0_minor_ops = {
 		| NFS_CAP_ATOMIC_OPEN
 		| NFS_CAP_CHANGE_ATTR
 		| NFS_CAP_POSIX_LOCK,
+	.init_client = nfs40_init_client,
+	.shutdown_client = nfs40_shutdown_client,
 	.match_stateid = nfs4_match_stateid,
 	.find_root_sec = nfs4_find_root_sec,
 	.free_lock_state = nfs4_release_lockowner,
@@ -7435,6 +7437,8 @@ static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = {
 		| NFS_CAP_POSIX_LOCK
 		| NFS_CAP_STATEID_NFSV41
 		| NFS_CAP_ATOMIC_OPEN_V1,
+	.init_client = nfs41_init_client,
+	.shutdown_client = nfs41_shutdown_client,
 	.match_stateid = nfs41_match_stateid,
 	.find_root_sec = nfs41_find_root_sec,
 	.free_lock_state = nfs41_free_lock_state,
@@ -7454,6 +7458,8 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = {
 		| NFS_CAP_POSIX_LOCK
 		| NFS_CAP_STATEID_NFSV41
 		| NFS_CAP_ATOMIC_OPEN_V1,
+	.init_client = nfs41_init_client,
+	.shutdown_client = nfs41_shutdown_client,
 	.match_stateid = nfs41_match_stateid,
 	.find_root_sec = nfs41_find_root_sec,
 	.free_lock_state = nfs41_free_lock_state,
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index d221243..fc83d3d 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -78,6 +78,9 @@ struct nfs_client {
 	u32			cl_cb_ident;	/* v4.0 callback identifier */
 	const struct nfs4_minor_version_ops *cl_mvops;
 
+	/* NFSv4.0 transport blocking */
+	struct nfs4_slot_table	*cl_slot_tbl;
+
 	/* The sequence id to use for the next CREATE_SESSION */
 	u32			cl_seqid;
 	/* The flags used for obtaining the clientid during EXCHANGE_ID */


  parent reply	other threads:[~2013-08-09 16:49 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-09 16:47 [PATCH v2 00/33] Proposed migration patches for 3.12 Chuck Lever
2013-08-09 16:47 ` [PATCH v2 01/33] NFS: When displaying session slot numbers, use "%u" consistently Chuck Lever
2013-08-09 16:48 ` [PATCH v2 02/33] NFS: Rename nfs41_call_sync_data as a common data structure Chuck Lever
2013-08-09 16:48 ` [PATCH v2 03/33] NFS: Clean up nfs4_setup_sequence() Chuck Lever
2013-08-09 16:48 ` [PATCH v2 04/33] NFS: Common versions of sequence helper functions Chuck Lever
2013-08-09 16:48 ` [PATCH v2 05/33] NFS: Add RPC callouts to start NFSv4.0 synchronous requests Chuck Lever
2013-08-09 16:48 ` [PATCH v2 06/33] NFS: Remove unused call_sync minor version op Chuck Lever
2013-08-09 16:48 ` [PATCH v2 07/33] NFS: Enable slot table helpers for NFSv4.0 Chuck Lever
2013-09-03 16:50   ` Myklebust, Trond
2013-09-03 18:19     ` Chuck Lever
2013-08-09 16:48 ` [PATCH v2 08/33] NFS: Add global helper to set up a stand-along nfs4_slot_table Chuck Lever
2013-08-09 16:49 ` [PATCH v2 09/33] NFS: Add global helper for releasing slot table resources Chuck Lever
2013-08-09 16:49 ` Chuck Lever [this message]
2013-08-09 16:49 ` [PATCH v2 11/33] NFS: NFSv4.0 transport blocking Chuck Lever
2013-08-09 16:49 ` [PATCH v2 12/33] NFS: Enable nfs4_setup_sequence() for DELEGRETURN Chuck Lever
2013-08-09 16:49 ` [PATCH v2 13/33] NFS: Add nfs4_sequence calls for RELEASE_LOCKOWNER Chuck Lever
2013-08-09 16:49 ` [PATCH v2 14/33] NFS: Add nfs4_sequence calls for OPEN_CONFIRM Chuck Lever
2013-08-09 16:49 ` [PATCH v2 15/33] NFS: Update session draining barriers for NFSv4.0 transport blocking Chuck Lever
2013-09-03 17:52   ` Myklebust, Trond
2013-09-03 17:57     ` Chuck Lever
2013-08-09 16:50 ` [PATCH v2 16/33] SUNRPC: Modify synopsis of rpc_client_register() Chuck Lever
2013-09-03 18:04   ` Myklebust, Trond
2013-09-03 18:16     ` Chuck Lever
2013-09-03 18:23       ` Myklebust, Trond
2013-09-03 18:33         ` Chuck Lever
2013-08-09 16:50 ` [PATCH v2 17/33] SUNRPC: Add a helper to switch the transport of an rpc_clnt Chuck Lever
2013-08-09 16:50 ` [PATCH v2 18/33] NFS: Add nfs4_update_server Chuck Lever
2013-08-09 16:50 ` [PATCH v2 19/33] NFS: Add functions to swap transports during migration recovery Chuck Lever
2013-08-09 16:50 ` [PATCH v2 20/33] NFS: Introduce a vector of migration recovery ops Chuck Lever
2013-08-09 16:50 ` [PATCH v2 21/33] NFS: Export _nfs_display_fhandle() Chuck Lever
2013-08-09 16:50 ` [PATCH v2 22/33] NFS: Add method to retrieve fs_locations during migration recovery Chuck Lever
2013-08-09 16:51 ` [PATCH v2 23/33] NFS: Add a super_block backpointer to the nfs_server struct Chuck Lever
2013-08-09 16:51 ` [PATCH v2 24/33] NFS: Add basic migration support to state manager thread Chuck Lever
2013-08-09 16:51 ` [PATCH v2 25/33] NFS: Re-use exit code in nfs4_async_handle_error() Chuck Lever
2013-08-09 16:51 ` [PATCH v2 26/33] NFS: Rename "stateid_invalid" label Chuck Lever
2013-08-09 16:51 ` [PATCH v2 27/33] NFS: Add migration recovery callouts in nfs4proc.c Chuck Lever
2013-08-09 16:51 ` [PATCH v2 28/33] NFS: Add method to detect whether an FSID is still on the server Chuck Lever
2013-08-09 16:52 ` [PATCH v2 29/33] NFS: Implement support for NFS4ERR_LEASE_MOVED in state manager Chuck Lever
2013-08-09 16:52 ` [PATCH v2 30/33] NFS: Implement support for NFS4ERR_LEASE_MOVED Chuck Lever
2013-08-09 16:52 ` [PATCH v2 31/33] " Chuck Lever
2013-08-09 16:52 ` [PATCH v2 32/33] NFS: Implement NFSv4.1 " Chuck Lever
2013-08-09 16:52 ` [PATCH v2 33/33] NFS: Set EXCHGID4_FLAG_SUPP_MOVED_MIGR Chuck Lever

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=20130809164910.5362.84774.stgit@seurat.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    /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 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.