From: Chuck Lever <chuck.lever@oracle.com>
To: trond.myklebust@netapp.com
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 5/5] NFS: Save FSID's root FH in nfs_server
Date: Tue, 25 Jun 2013 12:24:05 -0400 [thread overview]
Message-ID: <20130625162405.36416.83658.stgit@seurat.1015granger.net> (raw)
In-Reply-To: <20130625162233.36416.34947.stgit@seurat.1015granger.net>
Save each FSID's root file handle in the FSID's nfs_server structure
on the client. This is needed for NFSv4 migration recovery.
nfs_create_server() (used for NFSv2/3) is also updated for
completeness.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/nfs/client.c | 8 ++++++++
fs/nfs/internal.h | 12 ++++++++++++
fs/nfs/nfs4client.c | 5 +++++
include/linux/nfs_fs_sb.h | 1 +
4 files changed, 26 insertions(+)
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index dbb65fb..29cf2b9 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1028,6 +1028,7 @@ void nfs_free_server(struct nfs_server *server)
ida_destroy(&server->openowner_id);
nfs_free_iostats(server->io_stats);
bdi_destroy(&server->backing_dev_info);
+ nfs_free_fhandle(server->rootfh);
kfree(server);
nfs_release_automount_timer();
dprintk("<-- nfs_free_server()\n");
@@ -1053,6 +1054,9 @@ struct nfs_server *nfs_create_server(struct nfs_mount_info *mount_info,
fattr = nfs_alloc_fattr();
if (fattr == NULL)
goto error;
+ nfs_save_root_fh(server, mount_info->mntfh);
+ if (server->rootfh == NULL)
+ goto error;
/* Get a client representation */
error = nfs_init_server(server, mount_info->parsed, nfs_mod);
@@ -1122,6 +1126,9 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,
fattr_fsinfo = nfs_alloc_fattr();
if (fattr_fsinfo == NULL)
goto out_free_server;
+ nfs_save_root_fh(server, fh);
+ if (server->rootfh == NULL)
+ goto out_free_server;
/* Copy data from the source */
server->nfs_client = source->nfs_client;
@@ -1161,6 +1168,7 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,
return server;
out_free_server:
+ nfs_free_fhandle(server->rootfh);
nfs_free_fattr(fattr_fsinfo);
nfs_free_server(server);
dprintk("<-- nfs_clone_server() = error %d\n", error);
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 91e59a3..10a3327 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -574,3 +574,15 @@ u64 nfs_timespec_to_change_attr(const struct timespec *ts)
{
return ((u64)ts->tv_sec << 30) + ts->tv_nsec;
}
+
+/*
+ * Save a copy of the root FH
+ */
+static inline
+void nfs_save_root_fh(struct nfs_server *server, const struct nfs_fh *fh)
+{
+ server->rootfh = nfs_alloc_fhandle();
+ if (server->rootfh == NULL)
+ return;
+ nfs_copy_fh(server->rootfh, fh);
+}
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 3aec2de..18c2154 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -731,6 +731,11 @@ static int nfs4_server_common_setup(struct nfs_server *server,
if (fattr == NULL)
return -ENOMEM;
+ error = -ENOMEM;
+ nfs_save_root_fh(server, mntfh);
+ if (server->rootfh == NULL)
+ goto out;
+
/* We must ensure the session is initialised first */
error = nfs4_init_session(server);
if (error < 0)
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index 3b7fa2a..df4df80 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -170,6 +170,7 @@ struct nfs_server {
struct list_head layouts;
struct list_head delegations;
void (*destroy)(struct nfs_server *);
+ struct nfs_fh *rootfh;
atomic_t active; /* Keep trace of any activity to this server */
next prev parent reply other threads:[~2013-06-25 16:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-25 16:23 [PATCH 0/5] For 3.11 Chuck Lever
2013-06-25 16:23 ` [PATCH 1/5] NFS: Set NFS_CS_MIGRATION for NFSv4 mounts Chuck Lever
2013-06-28 20:03 ` Myklebust, Trond
2013-06-25 16:23 ` [PATCH 2/5] NFS: Use root's credential for lease management when keytab is missing Chuck Lever
2013-06-28 20:11 ` Myklebust, Trond
2013-06-28 20:16 ` Chuck Lever
2013-06-25 16:23 ` [PATCH 3/5] NFS: Never use user credentials for lease renewal Chuck Lever
2013-06-28 20:02 ` Myklebust, Trond
2013-06-28 20:03 ` Chuck Lever
2013-06-28 20:06 ` Myklebust, Trond
2013-06-25 16:23 ` [PATCH 4/5] NFS: Export _nfs_display_fhandle() Chuck Lever
2013-06-25 16:24 ` Chuck Lever [this message]
2013-06-25 16:37 ` [PATCH 5/5] NFS: Save FSID's root FH in nfs_server Myklebust, Trond
2013-06-25 20:22 ` Chuck Lever
2013-06-25 21:15 ` Myklebust, Trond
2013-06-25 21:51 ` Chuck Lever
2013-06-25 22:10 ` Myklebust, Trond
2013-06-26 0:15 ` 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=20130625162405.36416.83658.stgit@seurat.1015granger.net \
--to=chuck.lever@oracle.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;
as well as URLs for NNTP newsgroup(s).