All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Watt <jpewhacker@gmail.com>
To: NeilBrown <neilb@suse.com>, Jeff Layton <jlayton@redhat.com>,
	Trond Myklebust <trond.myklebust@primarydata.com>,
	"J . Bruce Fields" <bfields@fieldses.org>
Cc: linux-nfs@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>,
	David Howells <dhowells@redhat.com>,
	Joshua Watt <JPEWhacker@gmail.com>
Subject: [RFC v3 6/7] NFS: Add API to fail client
Date: Tue, 14 Nov 2017 17:06:30 -0600	[thread overview]
Message-ID: <20171114230631.14682-7-JPEWhacker@gmail.com> (raw)
In-Reply-To: <20171114230631.14682-1-JPEWhacker@gmail.com>

Failing a client will cause all current and future RPCs sent to it to
fail with -EIO

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 fs/nfs/client.c           | 25 +++++++++++++++++++++++++
 fs/nfs/internal.h         |  1 +
 include/linux/nfs_fs_sb.h |  2 ++
 3 files changed, 28 insertions(+)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 9d88dea4bc59..0e41b8d5904a 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -758,6 +758,31 @@ static int nfs_init_server(struct nfs_server *server,
 	return error;
 }
 
+static void
+fail_rpc_client(struct rpc_clnt *client, bool failed)
+{
+	if (IS_ERR(client))
+		return;
+
+	client->cl_kill_new_tasks = failed;
+	if (failed)
+		rpc_killall_tasks(client);
+}
+
+void
+nfs_client_failed(struct nfs_client *client, bool failed)
+{
+	struct nfs_server *server;
+
+	client->cl_failed = failed;
+	fail_rpc_client(client->cl_rpcclient, failed);
+
+	list_for_each_entry_rcu(server, &client->cl_superblocks, client_link) {
+		fail_rpc_client(server->client, failed);
+		fail_rpc_client(server->client_acl, failed);
+	}
+}
+
 /*
  * Load up the server record from information gained in an fsinfo record
  */
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 75da8185ceb8..b713f9f38d6d 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -159,6 +159,7 @@ extern void nfs_clients_init(struct net *net);
 void nfs_cleanup_client_ids(void);
 extern struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *);
 int nfs_create_rpc_client(struct nfs_client *, const struct nfs_client_initdata *, rpc_authflavor_t);
+void nfs_client_failed(struct nfs_client *client, bool failed);
 struct nfs_client *nfs_get_client(const struct nfs_client_initdata *);
 int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *, struct nfs_fattr *);
 void nfs_server_insert_lists(struct nfs_server *);
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index 0eb7093faea7..6d182da286a2 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -58,6 +58,8 @@ struct nfs_client {
 	int			cl_proto;	/* Network transport protocol */
 	struct nfs_subversion *	cl_nfs_mod;	/* pointer to nfs version module */
 
+	bool			cl_failed;	/* Client has failed */
+
 	u32			cl_minorversion;/* NFSv4 minorversion */
 	struct rpc_cred		*cl_machine_cred;
 
-- 
2.13.6


  parent reply	other threads:[~2017-11-14 23:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-14 23:06 [RFC v3 0/7] NFS Force Unmounting Joshua Watt
2017-11-14 23:06 ` [RFC v3 1/7] SUNRPC: Add flag to kill new tasks Joshua Watt
2017-11-14 23:06 ` [RFC v3 2/7] SUNRPC: Expose kill_new_tasks in debugfs Joshua Watt
2017-11-14 23:06 ` [RFC v3 3/7] SUNRPC: Simplify client shutdown Joshua Watt
2017-11-14 23:06 ` [RFC v3 4/7] NFS: Add debugfs for nfs_server and nfs_client Joshua Watt
2017-11-14 23:06 ` [RFC v3 5/7] NFS: Propagate NFS_MOUNT_UNSHARED to clients Joshua Watt
2017-11-14 23:06 ` Joshua Watt [this message]
2017-11-14 23:06 ` [RFC v3 7/7] NFS: Control failed clients through debugfs Joshua Watt
2017-11-15 13:40 ` [RFC v3 0/7] NFS Force Unmounting Trond Myklebust
2017-11-15 16:10   ` Joshua Watt

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=20171114230631.14682-7-JPEWhacker@gmail.com \
    --to=jpewhacker@gmail.com \
    --cc=bfields@fieldses.org \
    --cc=dhowells@redhat.com \
    --cc=jlayton@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.com \
    --cc=trond.myklebust@primarydata.com \
    --cc=viro@zeniv.linux.org.uk \
    /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.