From patchwork Tue Nov 14 23:06:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Watt X-Patchwork-Id: 10058541 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2869760215 for ; Tue, 14 Nov 2017 23:06:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B8E529AB4 for ; Tue, 14 Nov 2017 23:06:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1044C29AB2; Tue, 14 Nov 2017 23:06:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3BFF29AB4 for ; Tue, 14 Nov 2017 23:06:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753449AbdKNXGm (ORCPT ); Tue, 14 Nov 2017 18:06:42 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:44211 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755339AbdKNXGl (ORCPT ); Tue, 14 Nov 2017 18:06:41 -0500 Received: by mail-io0-f194.google.com with SMTP id q101so8820048ioi.1 for ; Tue, 14 Nov 2017 15:06:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZiprDYH5Wki6/blUOtg11YAz7J3PJTiHH3JVNEfrDaw=; b=EdExgUpGpJ23BzNz/9fYmePuL++4sBWtDLoepfmq0zc6uHpAmuOo4p7jrHqqfi1oAn m+pUpiRbdSn5Ab3rgEodHkWoDD7U8B4GNzoSbAN2eEWXSLwAwAGKh/lIejKFBMbKSYSg NqI8y2pzANV7Em6t9vSI5neHrS7hGdL5/aa1ly3YzG9i5EN1VX7SvCHWdglfdFM4jwGc 2jZ1IGX5HxvfXw2EQJN5qqKFlbheLyvKabU6/kjmbqPdo6BF2sloa4BWVkeQjXrwCeR2 7QcWpQopXnrHUEY8HbomEzOP/MbXPdbBvr1xwbkiAEWvIvg6LNyy1NncgCoPtSUwn4bG 3koA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZiprDYH5Wki6/blUOtg11YAz7J3PJTiHH3JVNEfrDaw=; b=e+SE7Ro9kONmoOuliMWGMruusuevUOSenFxivq0Ijvv8ywzqIjjt7PwgFwt2HQzVAs 4/xJTB4yuNdfMefZu4hfz0yvar99Pc/b4q8+Aw8Wtgn3Xh3cNcnovTQa7GyHkT6XKV6n a5eV1hGB5hgZhhHijFkGK+bNEibDj+1UkGyUt3HH9DcpPmTKoWLWtUTdufE6Eb/x9WVi L/fQF4m6aymVVytkk0Wl02dwy1ke9jaLUwgrKF01alszm7OkXBwe9kQiLRvbU0Drxjjg 19B6PrVM+96TvtcxsdcU78ebq6uNvaVXzhKdGdDPAAwzSKmTIeWAf46Dg9uP4OS2u8jZ 7YmQ== X-Gm-Message-State: AJaThX4ss7zE3y/gBxjdCrswO0zOYfJYSBLY2Hc6LGi33X+WJrDaDCgc qxO/IOcb1WF3SoRQ9yc9EjI= X-Google-Smtp-Source: AGs4zMYN1xHgRqaweplxc/QVzOt4AkQDpZO6WeDVblIfiT2J86p+dxIhZLuf4wUtBM8FjWeXkzzipg== X-Received: by 10.107.159.13 with SMTP id i13mr8566500ioe.300.1510700800538; Tue, 14 Nov 2017 15:06:40 -0800 (PST) Received: from ola-842mrw1.ad.garmin.com ([204.77.163.55]) by smtp.googlemail.com with ESMTPSA id e203sm6015236itb.32.2017.11.14.15.06.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Nov 2017 15:06:40 -0800 (PST) From: Joshua Watt X-Google-Original-From: Joshua Watt To: NeilBrown , Jeff Layton , Trond Myklebust , "J . Bruce Fields" Cc: linux-nfs@vger.kernel.org, Al Viro , David Howells , Joshua Watt Subject: [RFC v3 6/7] NFS: Add API to fail client Date: Tue, 14 Nov 2017 17:06:30 -0600 Message-Id: <20171114230631.14682-7-JPEWhacker@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171114230631.14682-1-JPEWhacker@gmail.com> References: <20171114230631.14682-1-JPEWhacker@gmail.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Failing a client will cause all current and future RPCs sent to it to fail with -EIO Signed-off-by: Joshua Watt --- 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;