From patchwork Wed Jul 30 12:27:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4648091 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 04A17C033A for ; Wed, 30 Jul 2014 12:28:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 205B620158 for ; Wed, 30 Jul 2014 12:28:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4728020138 for ; Wed, 30 Jul 2014 12:28:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753834AbaG3M2R (ORCPT ); Wed, 30 Jul 2014 08:28:17 -0400 Received: from mail-qa0-f47.google.com ([209.85.216.47]:34051 "EHLO mail-qa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753429AbaG3M2L (ORCPT ); Wed, 30 Jul 2014 08:28:11 -0400 Received: by mail-qa0-f47.google.com with SMTP id i13so1195391qae.34 for ; Wed, 30 Jul 2014 05:28:10 -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=pvUV9ewr4+Yjnz24BIHzZ90I7kbE9eB0wfLLU275cHo=; b=OCfn9bDxWK6sIMjlFGnI6XIpVq1B6ZpYj04X/rzImSdH3JAEaYstto55wYnIbgrbbP ZhuYxTxuMklsh6E7G7O77+zWyf7Hm5wrcXDUT/fU8tKF5vaWJktKdrfgedkLrdz8zu03 5hzOnGo6dkpYJeyGKyXqBJ6satvOgyzbMTBVPfo4ffid03yRMmbQSK7bdHtI1MpoyztG 2RlWIUefba6sGqBUfXzc88RDJbPtIKJ9/gY1M0HkP71fjtEsp9RYLSugDjRlJ1B7ZctW dkdzvFBmh4M+jNIIbcXbInF1kNHc5Crttr1SZaSdxFwT1nIwKDvLZq/S4KYlXsDugqHr OX6A== X-Gm-Message-State: ALoCoQmg67/OCVbsuCbxXUQQHZikrM1tHkHRBIGegmSbQ6FXcyQYI8BhUqE/p4xrJRsY3fvgqCQz X-Received: by 10.224.103.198 with SMTP id l6mr6098695qao.47.1406723290340; Wed, 30 Jul 2014 05:28:10 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id t23sm2384767qge.13.2014.07.30.05.28.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jul 2014 05:28:09 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, hch@infradead.org Subject: [PATCH 18/37] nfsd: add nfsd_inject_forget_clients Date: Wed, 30 Jul 2014 08:27:19 -0400 Message-Id: <1406723258-8512-19-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1406723258-8512-1-git-send-email-jlayton@primarydata.com> References: <1406723258-8512-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=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 ...which uses the client_lock for protection instead of client_mutex. Also remove nfsd_forget_client as there are no more callers. Signed-off-by: Jeff Layton --- fs/nfsd/fault_inject.c | 3 +-- fs/nfsd/nfs4state.c | 42 ++++++++++++++++++++++++++++-------------- fs/nfsd/state.h | 2 +- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c index 5f3ead0c72fb..76ecdff37ea2 100644 --- a/fs/nfsd/fault_inject.c +++ b/fs/nfsd/fault_inject.c @@ -135,9 +135,8 @@ static struct nfsd_fault_inject_op inject_ops[] = { { .file = "forget_clients", .get = nfsd_inject_print_clients, - .set_val = nfsd_inject_set, + .set_val = nfsd_inject_forget_clients, .set_clnt = nfsd_inject_forget_client, - .forget = nfsd_forget_client, }, { .file = "forget_locks", diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 2dd9819e205b..8cc3a8c1c2a9 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5742,20 +5742,6 @@ nfsd_inject_print_clients(struct nfsd_fault_inject_op *op) return count; } -u64 nfsd_forget_client(struct nfs4_client *clp, u64 max) -{ - __be32 ret; - struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); - - spin_lock(&nn->client_lock); - ret = mark_client_expired_locked(clp); - spin_unlock(&nn->client_lock); - if (ret != nfs_ok) - return 0; - expire_client(clp); - return 1; -} - u64 nfsd_inject_forget_client(struct nfsd_fault_inject_op *op, struct sockaddr_storage *addr, size_t addr_size) @@ -5784,6 +5770,34 @@ nfsd_inject_forget_client(struct nfsd_fault_inject_op *op, return count; } +u64 +nfsd_inject_forget_clients(struct nfsd_fault_inject_op *op, u64 max) +{ + u64 count = 0; + struct nfs4_client *clp, *next; + struct nfsd_net *nn = net_generic(current->nsproxy->net_ns, + nfsd_net_id); + LIST_HEAD(reaplist); + + if (!nfsd_netns_ready(nn)) + return count; + + spin_lock(&nn->client_lock); + list_for_each_entry_safe(clp, next, &nn->client_lru, cl_lru) { + if (mark_client_expired_locked(clp) == nfs_ok) { + list_add(&clp->cl_lru, &reaplist); + if (max != 0 && ++count >= max) + break; + } + } + spin_unlock(&nn->client_lock); + + list_for_each_entry_safe(clp, next, &reaplist, cl_lru) + expire_client(clp); + + return count; +} + 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 e37520e1f767..480fce8d5cc8 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -479,9 +479,9 @@ 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_inject_forget_client(struct nfsd_fault_inject_op *, struct sockaddr_storage *, size_t); +u64 nfsd_inject_forget_clients(struct nfsd_fault_inject_op *, u64); u64 nfsd_forget_client_locks(struct nfs4_client*, u64); u64 nfsd_forget_client_openowners(struct nfs4_client *, u64);