From patchwork Thu Nov 18 12:44:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boaz Harrosh X-Patchwork-Id: 335981 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 oAICilbG004377 for ; Thu, 18 Nov 2010 12:44:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756020Ab0KRMoq (ORCPT ); Thu, 18 Nov 2010 07:44:46 -0500 Received: from daytona.panasas.com ([67.152.220.89]:40553 "EHLO daytona.panasas.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755557Ab0KRMop (ORCPT ); Thu, 18 Nov 2010 07:44:45 -0500 Received: from fs2.bhalevy.com ([172.17.33.217]) by daytona.panasas.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 18 Nov 2010 07:44:44 -0500 Message-ID: <4CE51FBA.6060806@panasas.com> Date: Thu, 18 Nov 2010 14:44:42 +0200 From: Boaz Harrosh User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.15) Gecko/20101027 Fedora/3.0.10-1.fc12 Thunderbird/3.0.10 MIME-Version: 1.0 To: Benny Halevy CC: linux-nfs@vger.kernel.org, Andy Adamson Subject: Re: [PATCH] SQUASHME: pnfs: move synchronize_rcu out side of spin_lock References: <1290015704-6221-1-git-send-email-bhalevy@panasas.com> In-Reply-To: <1290015704-6221-1-git-send-email-bhalevy@panasas.com> X-OriginalArrivalTime: 18 Nov 2010 12:44:44.0684 (UTC) FILETIME=[606EE4C0:01CB871E] 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, 18 Nov 2010 12:44:47 +0000 (UTC) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 61310c7..5d4e14d 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1598,16 +1598,21 @@ pnfs_unhash_deviceid(struct pnfs_deviceid_cache *c, { struct pnfs_deviceid_node *d; struct hlist_node *n; - long h = nfs4_deviceid_hash(id); + long h; + + spin_lock(&c->dc_lock); + h = nfs4_deviceid_hash(id); dprintk("%s hash %ld\n", __func__, h); hlist_for_each_entry_rcu(d, n, &c->dc_deviceids[h], de_node) if (!memcmp(&d->de_id, id, sizeof(*id))) { hlist_del_rcu(&d->de_node); + spin_unlock(&c->dc_lock); synchronize_rcu(); return d; } + spin_unlock(&c->dc_lock); return NULL; } @@ -1620,11 +1625,10 @@ pnfs_put_deviceid(struct pnfs_deviceid_cache *c, struct pnfs_deviceid_node *devid) { dprintk("%s [%d]\n", __func__, atomic_read(&devid->de_ref)); - if (!atomic_dec_and_lock(&devid->de_ref, &c->dc_lock)) + if (!atomic_dec_and_test(&devid->de_ref)) return; pnfs_unhash_deviceid(c, &devid->de_id); - spin_unlock(&c->dc_lock); c->dc_free_callback(devid); } @@ -1636,9 +1640,7 @@ pnfs_delete_deviceid(struct pnfs_deviceid_cache *c, { struct pnfs_deviceid_node *devid; - spin_lock(&c->dc_lock); devid = pnfs_unhash_deviceid(c, id); - spin_unlock(&c->dc_lock); dprintk("%s [%d]\n", __func__, atomic_read(&devid->de_ref)); if (atomic_dec_and_test(&devid->de_ref))