From patchwork Sat Sep 7 18:45:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Fields X-Patchwork-Id: 2856591 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 9476FBF43F for ; Sat, 7 Sep 2013 18:46:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5FCE020292 for ; Sat, 7 Sep 2013 18:46:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 45E6F2026C for ; Sat, 7 Sep 2013 18:46:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751515Ab3IGSqM (ORCPT ); Sat, 7 Sep 2013 14:46:12 -0400 Received: from fieldses.org ([174.143.236.118]:50814 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751479Ab3IGSqL (ORCPT ); Sat, 7 Sep 2013 14:46:11 -0400 Received: from bfields by fieldses.org with local (Exim 4.76) (envelope-from ) id 1VINWG-000707-2h; Sat, 07 Sep 2013 14:46:04 -0400 From: "J. Bruce Fields" To: Al Viro Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , "J. Bruce Fields" Subject: [PATCH 2/4] dcache: make __d_shrink callers check d_unhashed() Date: Sat, 7 Sep 2013 14:45:59 -0400 Message-Id: <1378579561-26868-3-git-send-email-bfields@redhat.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1378579561-26868-1-git-send-email-bfields@redhat.com> References: <1378579561-26868-1-git-send-email-bfields@redhat.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=-9.3 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 From: "J. Bruce Fields" __d_shrink only has two callers, one of whom already does the check, so may as well make this the caller's responsibility. Cc: Christoph Hellwig Signed-off-by: J. Bruce Fields --- fs/dcache.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 7208b38..d9e4fba 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -391,23 +391,21 @@ static struct dentry *d_kill(struct dentry *dentry, struct dentry *parent) */ static void __d_shrink(struct dentry *dentry) { - if (!d_unhashed(dentry)) { - struct hlist_bl_head *b; - /* - * Hashed dentries are normally on the dentry hashtable, - * with the exception of those newly allocated by - * d_obtain_alias, which are always IS_ROOT: - */ - if (unlikely(IS_ROOT(dentry))) - b = &dentry->d_sb->s_anon; - else - b = d_hash(dentry->d_parent, dentry->d_name.hash); + struct hlist_bl_head *b; + /* + * Hashed dentries are normally on the dentry hashtable, + * with the exception of those newly allocated by + * d_obtain_alias, which are always IS_ROOT: + */ + if (unlikely(IS_ROOT(dentry))) + b = &dentry->d_sb->s_anon; + else + b = d_hash(dentry->d_parent, dentry->d_name.hash); - hlist_bl_lock(b); - __hlist_bl_del(&dentry->d_hash); - dentry->d_hash.pprev = NULL; - hlist_bl_unlock(b); - } + hlist_bl_lock(b); + __hlist_bl_del(&dentry->d_hash); + dentry->d_hash.pprev = NULL; + hlist_bl_unlock(b); } /** @@ -905,7 +903,8 @@ static void shrink_dcache_for_umount_subtree(struct dentry *dentry) dentry->d_op->d_prune(dentry); dentry_lru_del(dentry); - __d_shrink(dentry); + if (!d_unhashed(dentry)) + __d_shrink(dentry); if (dentry->d_lockref.count != 0) { printk(KERN_ERR