From patchwork Wed Jul 30 12:27:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4648071 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 5E2969F36A for ; Wed, 30 Jul 2014 12:28:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8E2FC20121 for ; Wed, 30 Jul 2014 12:28:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AD00A200E9 for ; Wed, 30 Jul 2014 12:28:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754710AbaG3M2O (ORCPT ); Wed, 30 Jul 2014 08:28:14 -0400 Received: from mail-qg0-f43.google.com ([209.85.192.43]:41469 "EHLO mail-qg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753880AbaG3M2M (ORCPT ); Wed, 30 Jul 2014 08:28:12 -0400 Received: by mail-qg0-f43.google.com with SMTP id a108so1285120qge.2 for ; Wed, 30 Jul 2014 05:28:11 -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=tQYeI/nWIUmbrD3e6otqGF93JNKEZtwyjlitWPaIDns=; b=fMDz/P3JgGSY24iW1ghKIAxVK4j5dr8BlIFF2YTQzpFrj/bjOnfP/cUn6tNc8EkFfV gIuAgFyyGa8Gm2ubkpeCKORcfMS9wd9hKo2vvF+7CTin9rMpZAffTMsP0UcvplHVQrjU kj63k+R5Y2gz/VylIOodM8dElV6SKxKHRW12GbkHDvh30K/KhQhHXX2OMzOJYaKq2AjB sUXOrURKP56Nv2leGAQUpCF79NmEh5sm5uYjxoRXS6pzcOr6Ca1IaygH0L/cqDxkHyLg K+Fh4GHqwtOxSRwAa1OXCPxU7rv1wRR3Phu53R0KXJXnb8oIwZKPLALEKAis2ijxNlEw Z+Og== X-Gm-Message-State: ALoCoQlvCIRo4BHZaXVX0Wfkyhjuzs4Yef8UchylC5zXuFZM3hTIwI9MMDswTC5b3NElPLq8EXB4 X-Received: by 10.224.37.72 with SMTP id w8mr6514276qad.58.1406723291756; Wed, 30 Jul 2014 05:28:11 -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.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jul 2014 05:28:10 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, hch@infradead.org Subject: [PATCH 19/37] nfsd: add a list_head arg to nfsd_foreach_client_lock Date: Wed, 30 Jul 2014 08:27:20 -0400 Message-Id: <1406723258-8512-20-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 In a later patch, we'll want to collect the locks onto a list for later destruction. If "func" is defined and "collect" is defined, then we'll add the lock stateid to the list. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 8cc3a8c1c2a9..b6020e4a2102 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5807,6 +5807,7 @@ static void nfsd_print_count(struct nfs4_client *clp, unsigned int count, } static u64 nfsd_foreach_client_lock(struct nfs4_client *clp, u64 max, + struct list_head *collect, void (*func)(struct nfs4_ol_stateid *)) { struct nfs4_openowner *oop; @@ -5819,8 +5820,12 @@ static u64 nfsd_foreach_client_lock(struct nfs4_client *clp, u64 max, &oop->oo_owner.so_stateids, st_perstateowner) { list_for_each_entry_safe(lst, lst_next, &stp->st_locks, st_locks) { - if (func) + if (func) { func(lst); + if (collect) + list_add(&lst->st_locks, + collect); + } if (++count == max) return count; } @@ -5832,12 +5837,12 @@ static u64 nfsd_foreach_client_lock(struct nfs4_client *clp, u64 max, u64 nfsd_forget_client_locks(struct nfs4_client *clp, u64 max) { - return nfsd_foreach_client_lock(clp, max, release_lock_stateid); + return nfsd_foreach_client_lock(clp, max, NULL, release_lock_stateid); } u64 nfsd_print_client_locks(struct nfs4_client *clp, u64 max) { - u64 count = nfsd_foreach_client_lock(clp, max, NULL); + u64 count = nfsd_foreach_client_lock(clp, max, NULL, NULL); nfsd_print_count(clp, count, "locked files"); return count; }