From patchwork Thu Jun 19 14:50:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4384381 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0B5269F390 for ; Thu, 19 Jun 2014 14:53:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1610220384 for ; Thu, 19 Jun 2014 14:53:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1A92820394 for ; Thu, 19 Jun 2014 14:52:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932376AbaFSOw6 (ORCPT ); Thu, 19 Jun 2014 10:52:58 -0400 Received: from mail-qa0-f50.google.com ([209.85.216.50]:61187 "EHLO mail-qa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932295AbaFSOw5 (ORCPT ); Thu, 19 Jun 2014 10:52:57 -0400 Received: by mail-qa0-f50.google.com with SMTP id m5so2025647qaj.37 for ; Thu, 19 Jun 2014 07:52:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=O8sAjMP1HvWSjJJ4NVoT7Sii4OcPczonrlg/Kl/lSXU=; b=UBt4lfX2sD0zmg+plkRD9b7zZpT1Jp5ZdLmwcuR2ptF2lN7ZYHYWmyqPXEYNgK7SbK NvMnzZlwDfSAjh3Gj14c2ds3qMvNB8ocOn+4sDKF94rKjTmdo65WZcP5ahB6fcMfD72w rmmnTIeOhk1/bzNQycFrO0WksSfKPH23zonWaQLQAq/4/WTKV6EhunKyT0TgHICNOhe9 uIBw0L3Cel07VLmrth60htff+TucYBeSbNNAtqSFUKa65wBNCajDoDQnKhQeVlepXQMc I8kOJsI3jHqlTh7r/yVszszfovYvEi34LzBz5u0a1Ah4TRiuJMNs1KM5/6DsJ5YIuwyS u5Ng== X-Gm-Message-State: ALoCoQlzm60jaIE/+DfRnAlRnDZINCcpqPqlpifkuh8lPwhv/wrEFC6C4aOOhe406iZD3DOlTEZk X-Received: by 10.140.18.197 with SMTP id 63mr7221227qgf.105.1403189576900; Thu, 19 Jun 2014 07:52:56 -0700 (PDT) Received: from tlielax.poochiereds.net (cpe-107-015-124-230.nc.res.rr.com. [107.15.124.230]) by mx.google.com with ESMTPSA id r60sm3364044qgd.26.2014.06.19.07.52.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jun 2014 07:52:56 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 083/104] nfsd: add a forget_clients "get" routine with proper locking Date: Thu, 19 Jun 2014 10:50:29 -0400 Message-Id: <1403189450-18729-84-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1403189450-18729-1-git-send-email-jlayton@primarydata.com> References: <1403189450-18729-1-git-send-email-jlayton@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Jeff Layton --- fs/nfsd/fault_inject.c | 3 +-- fs/nfsd/nfs4state.c | 29 +++++++++++++++++++++-------- fs/nfsd/state.h | 4 +++- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c index bbb00dcd926a..bbdd6eddb894 100644 --- a/fs/nfsd/fault_inject.c +++ b/fs/nfsd/fault_inject.c @@ -133,11 +133,10 @@ void nfsd_fault_inject_cleanup(void) static struct nfsd_fault_inject_op inject_ops[] = { { .file = "forget_clients", - .get = nfsd_inject_get, + .get = nfsd_inject_print_clients, .set_val = nfsd_inject_set, .set_clnt = nfsd_inject_set_client, .forget = nfsd_forget_client, - .print = nfsd_print_client, }, { .file = "forget_locks", diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 17fd48561cf8..3ca08358b142 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5570,6 +5570,27 @@ nfs4_check_open_reclaim(clientid_t *clid, } #ifdef CONFIG_NFSD_FAULT_INJECTION +u64 +nfsd_inject_print_clients(struct nfsd_fault_inject_op *op) +{ + struct nfs4_client *clp; + u64 count = 0; + struct nfsd_net *nn = net_generic(current->nsproxy->net_ns, nfsd_net_id); + char buf[INET6_ADDRSTRLEN]; + + if (!nfsd_netns_ready(nn)) + return 0; + + spin_lock(&nn->client_lock); + list_for_each_entry(clp, &nn->client_lru, cl_lru) { + rpc_ntop((struct sockaddr *)&clp->cl_addr, buf, sizeof(buf)); + printk(KERN_INFO "NFS Client: %s\n", buf); + ++count; + } + spin_unlock(&nn->client_lock); + + return count; +} u64 nfsd_forget_client(struct nfs4_client *clp, u64 max) { @@ -5585,14 +5606,6 @@ u64 nfsd_forget_client(struct nfs4_client *clp, u64 max) return 1; } -u64 nfsd_print_client(struct nfs4_client *clp, u64 num) -{ - char buf[INET6_ADDRSTRLEN]; - rpc_ntop((struct sockaddr *)&clp->cl_addr, buf, sizeof(buf)); - printk(KERN_INFO "NFS Client: %s\n", buf); - return 1; -} - static void nfsd_print_count(struct nfs4_client *clp, unsigned int count, const char *type) { diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 880b5acd05f3..083ebd1c9733 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -467,18 +467,20 @@ extern void nfsd4_record_grace_done(struct nfsd_net *nn, time_t boot_time); /* nfs fault injection functions */ #ifdef CONFIG_NFSD_FAULT_INJECTION +struct nfsd_fault_inject_op; + int nfsd_fault_inject_init(void); void nfsd_fault_inject_cleanup(void); u64 nfsd_for_n_state(u64, u64 (*)(struct nfs4_client *, u64)); struct nfs4_client *nfsd_find_client(struct sockaddr_storage *, size_t); +u64 nfsd_inject_print_clients(struct nfsd_fault_inject_op *op); u64 nfsd_forget_client(struct nfs4_client *, u64); u64 nfsd_forget_client_locks(struct nfs4_client*, u64); u64 nfsd_forget_client_openowners(struct nfs4_client *, u64); u64 nfsd_forget_client_delegations(struct nfs4_client *, u64); u64 nfsd_recall_client_delegations(struct nfs4_client *, u64); -u64 nfsd_print_client(struct nfs4_client *, u64); u64 nfsd_print_client_locks(struct nfs4_client *, u64); u64 nfsd_print_client_openowners(struct nfs4_client *, u64); u64 nfsd_print_client_delegations(struct nfs4_client *, u64);