From patchwork Thu Dec 9 16:48:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 395092 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB9GmE1W022612 for ; Thu, 9 Dec 2010 16:48:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752185Ab0LIQsc (ORCPT ); Thu, 9 Dec 2010 11:48:32 -0500 Received: from mail-yx0-f174.google.com ([209.85.213.174]:36379 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751807Ab0LIQsb (ORCPT ); Thu, 9 Dec 2010 11:48:31 -0500 Received: by yxt3 with SMTP id 3so1487377yxt.19 for ; Thu, 09 Dec 2010 08:48:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:subject:to:date :message-id:in-reply-to:references:user-agent:mime-version :content-type:content-transfer-encoding; bh=KtFVCVd5M2GlJvC85GRenAGKO0EL8TBKIuf1ujGMsNs=; b=MbkNycUpC5kHzxyh1P7D3wFf5MoVrxNMPPeof6Emqomq2rx+d5Dwqnh9kOXx79/4J8 Qc11kY+ST+T7wuqIPwlCNIx3vUbqIlc0IeyuGo89qgbz/64sjZwcZvVq4i+qBnpiN0Vo 2jIKE2oVJjWVX+dFlPei3YBHR3dTGuKrbcLTQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:subject:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; b=n3uG5Grky5l9IWfwuK7DgfV8PRZbvHU9mF90HAKEAxhgZK31Y+Rsy87xORjE4DdzvO /+aPnVrkuiCC5KLJlmBbIF6u9hendrjE6714E91+ADszFHlSi8pUI4pRiNbI+8lQGjI3 nKDmjM0rQYmwi4rkIaTJAIOgDBQFTa+ruB/Pk= Received: by 10.100.37.18 with SMTP id k18mr7139140ank.235.1291913311058; Thu, 09 Dec 2010 08:48:31 -0800 (PST) Received: from matisse.1015granger.net (adsl-99-26-161-222.dsl.sfldmi.sbcglobal.net [99.26.161.222]) by mx.google.com with ESMTPS id i10sm2144727anh.12.2010.12.09.08.48.29 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 09 Dec 2010 08:48:30 -0800 (PST) From: Chuck Lever Subject: [PATCH 02/11] lockd: reorganize nlm_host_rebooted To: linux-nfs@vger.kernel.org Date: Thu, 09 Dec 2010 11:48:28 -0500 Message-ID: <20101209164828.4513.47494.stgit@matisse.1015granger.net> In-Reply-To: <20101209163555.4513.94435.stgit@matisse.1015granger.net> References: <20101209163555.4513.94435.stgit@matisse.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 09 Dec 2010 16:48:33 +0000 (UTC) diff --git a/fs/lockd/host.c b/fs/lockd/host.c index cada3a1..2dbf139 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c @@ -441,6 +441,31 @@ void nlm_release_host(struct nlm_host *host) } } +static struct nlm_host *next_host_state(struct hlist_head *cache, + struct nsm_handle *nsm, + const struct nlm_reboot *info) +{ + struct nlm_host *host = NULL; + struct hlist_head *chain; + struct hlist_node *pos; + + mutex_lock(&nlm_host_mutex); + for_each_host(host, pos, chain, cache) { + if (host->h_nsmhandle == nsm + && host->h_nsmstate != info->state) { + host->h_nsmstate = info->state; + host->h_state++; + + nlm_get_host(host); + mutex_unlock(&nlm_host_mutex); + goto out; + } + } +out: + mutex_unlock(&nlm_host_mutex); + return host; +} + /** * nlm_host_rebooted - Release all resources held by rebooted host * @info: pointer to decoded results of NLM_SM_NOTIFY call @@ -450,8 +475,6 @@ void nlm_release_host(struct nlm_host *host) */ void nlm_host_rebooted(const struct nlm_reboot *info) { - struct hlist_head *chain; - struct hlist_node *pos; struct nsm_handle *nsm; struct nlm_host *host; @@ -464,30 +487,17 @@ void nlm_host_rebooted(const struct nlm_reboot *info) * lock for this. * To avoid processing a host several times, we match the nsmstate. */ -again: mutex_lock(&nlm_host_mutex); - for_each_host(host, pos, chain, nlm_hosts) { - if (host->h_nsmhandle == nsm - && host->h_nsmstate != info->state) { - host->h_nsmstate = info->state; - host->h_state++; - - nlm_get_host(host); - mutex_unlock(&nlm_host_mutex); - - if (host->h_server) { - /* We're server for this guy, just ditch - * all the locks he held. */ - nlmsvc_free_host_resources(host); - } else { - /* He's the server, initiate lock recovery. */ - nlmclnt_recovery(host); - } - - nlm_release_host(host); - goto again; + while ((host = next_host_state(nlm_hosts, nsm, info)) != NULL) { + if (host->h_server) { + /* We're server for this guy, just ditch + * all the locks he held. */ + nlmsvc_free_host_resources(host); + } else { + /* He's the server, initiate lock recovery. */ + nlmclnt_recovery(host); } + nlm_release_host(host); } - mutex_unlock(&nlm_host_mutex); nsm_release(nsm); }