From patchwork Tue Nov 14 23:06:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Watt X-Patchwork-Id: 10058547 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 91CC760215 for ; Tue, 14 Nov 2017 23:06:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8516229AA1 for ; Tue, 14 Nov 2017 23:06:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A15E29AAE; Tue, 14 Nov 2017 23:06:47 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 16A0729AA1 for ; Tue, 14 Nov 2017 23:06:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755261AbdKNXGp (ORCPT ); Tue, 14 Nov 2017 18:06:45 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:54443 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756490AbdKNXGm (ORCPT ); Tue, 14 Nov 2017 18:06:42 -0500 Received: by mail-io0-f195.google.com with SMTP id w127so8804280iow.11 for ; Tue, 14 Nov 2017 15:06:41 -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=njN9X2ofdUadrScl8KKSDHFLUw6ZwW0e/wcakdBwNtk=; b=BjAgS2+LaCNQsZokdln1kTP/YEDN8W2wLPD48uyEr6nroUAt6WPUBWxEaB84OFtDov JGoKoaaA2hJI0iUMZIMRwgm/luH4KS2Of499LHMzpmGnkM9l0bbf8cDvAzdXa7phA0AE OZ7svCdUrDDOIRu4j5jSJrQBf48rz2lYT8IYM9zCx6ZBpze2WV/0dV2GXApjSGk0NhVO 09CePClR6UNrzA4/uEIdg6e/mrRImGSnKHMKUnI6qq8nT/suyZcfLCdRonfVAh3u4RwD OY6iyJq7kCBcZrAk2p7267PrdLq9Pqz+vfix05+O36UsfBSwyVhLeYmAoG2FIuCsaQH7 KJzw== 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=njN9X2ofdUadrScl8KKSDHFLUw6ZwW0e/wcakdBwNtk=; b=IO5SqN3SoEnDwDnsRGnm8Xi53KfmNu0/2FVTdPnOInA0eo76yZbN+u9N5m0G2hLLGI tdpgHe+8t7WmrFtepfNJdiWdukgekypaktd2T9JIuIPezv5PxbJUdyyUV7ObD4TXcYYg 690yto2GKItfX5pSBAPGKJ+glePdkJXI2saindxarxmi0ikomlzFfZmwewdA07ktSeJ2 6mYFJC585vzcFUE0Tz6F5aiYiqkPsx87SkKvNA9cR7oPA5nkc0bDRpqbemQaAmQv6EXh T8O9HauAFIUlP5ApveKpzUu9Z4OclmlMzBG9wo7S4nu+4jXOcPm5myWIUgJNb/K3+ocZ /26Q== X-Gm-Message-State: AJaThX5NYB84nle9ly80Y/dV9drlhRDUOEvMc3IGg/neDo9IGE4XOKCT 7rG53WfXTsDDrNbjPqBgc5Q= X-Google-Smtp-Source: AGs4zMYG40EPQh7FWpbTcuHC3+utB758wpBwjocdS/YywIdDJkBGgqHLUXkztI0LBl/sTtbHhamdKA== X-Received: by 10.107.135.151 with SMTP id r23mr6850781ioi.171.1510700801451; Tue, 14 Nov 2017 15:06:41 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Nov 2017 15:06:41 -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 7/7] NFS: Control failed clients through debugfs Date: Tue, 14 Nov 2017 17:06:31 -0600 Message-Id: <20171114230631.14682-8-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 The "failed" debugfs entry can be used to get or set the failed status of a nfs_client. Signed-off-by: Joshua Watt --- fs/nfs/debugfs.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/fs/nfs/debugfs.c b/fs/nfs/debugfs.c index 0195431427c2..7ccf04847660 100644 --- a/fs/nfs/debugfs.c +++ b/fs/nfs/debugfs.c @@ -80,6 +80,56 @@ nfs_server_debugfs_unregister(struct nfs_server *server) server->debugfs = NULL; } +static int +client_failed_show(struct seq_file *f, void *private) +{ + struct nfs_client *client = f->private; + + seq_printf(f, "%c", client->cl_failed ? 'Y' : 'N'); + return 0; +} + +static ssize_t +client_failed_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct seq_file *seq = file->private_data; + struct nfs_client *client = seq->private; + char buf[32]; + size_t buf_size; + bool failed; + int err; + + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + + buf[buf_size] = '\0'; + + err = strtobool(buf, &failed); + if (err) + return err; + + nfs_client_failed(client, failed); + + return count; +} + +static int +client_failed_open(struct inode *inode, struct file *file) +{ + return single_open(file, client_failed_show, inode->i_private); +} + +static const struct file_operations client_failed_fops = { + .owner = THIS_MODULE, + .open = client_failed_open, + .read = seq_read, + .write = client_failed_write, + .llseek = seq_lseek, + .release = single_release +}; + void nfs_client_debugfs_register(struct nfs_client *client) { @@ -99,6 +149,15 @@ nfs_client_debugfs_register(struct nfs_client *client) link_rpc_client("rpc_client", client->cl_rpcclient, client->cl_debugfs); + + if (!debugfs_create_file("failed", 0600, client->cl_debugfs, client, + &client_failed_fops)) + goto out_error; + + return; +out_error: + debugfs_remove_recursive(client->cl_debugfs); + client->cl_debugfs = NULL; } void