From patchwork Mon Dec 27 23:46:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J. Bruce Fields" X-Patchwork-Id: 435401 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 oBRNkrV2018391 for ; Mon, 27 Dec 2010 23:46:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752127Ab0L0Xqv (ORCPT ); Mon, 27 Dec 2010 18:46:51 -0500 Received: from fieldses.org ([174.143.236.118]:54027 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752068Ab0L0Xqv (ORCPT ); Mon, 27 Dec 2010 18:46:51 -0500 Received: from bfields by fieldses.org with local (Exim 4.72) (envelope-from ) id 1PXMm2-0006o4-4a; Mon, 27 Dec 2010 18:46:42 -0500 Date: Mon, 27 Dec 2010 18:46:41 -0500 From: "J. Bruce Fields" To: Alexander Viro Cc: Nick Piggin , linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH] fs/dcache: allow __d_obtain_alias() to return unhashed dentries Message-ID: <20101227234641.GA22248@fieldses.org> References: <20101129193248.GA9897@fieldses.org> <20101203223326.GB28763@fieldses.org> <20101213051944.GA8688@amd> <20101214220102.GM24828@fieldses.org> <20101217180022.GB11515@fieldses.org> <20101218020118.GA3179@amd> <20101218161609.GA22150@fieldses.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) 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]); Mon, 27 Dec 2010 23:46:55 +0000 (UTC) diff --git a/fs/dcache.c b/fs/dcache.c index 5ed93cd..5c014a5 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1135,6 +1135,28 @@ static inline struct hlist_head *d_hash(struct dentry *parent, return dentry_hashtable + (hash & D_HASHMASK); } +static struct dentry * __d_find_any_alias(struct inode *inode) +{ + struct dentry *alias; + + if (list_empty(&inode->i_dentry)) + return NULL; + alias = list_first_entry(&inode->i_dentry, struct dentry, d_alias); + __dget_locked(alias); + return alias; +} + +static struct dentry * d_find_any_alias(struct inode *inode) +{ + struct dentry *de; + + spin_lock(&dcache_lock); + de = __d_find_any_alias(inode); + spin_unlock(&dcache_lock); + return de; +} + + /** * d_obtain_alias - find or allocate a dentry for a given inode * @inode: inode to allocate the dentry for @@ -1164,7 +1186,7 @@ struct dentry *d_obtain_alias(struct inode *inode) if (IS_ERR(inode)) return ERR_CAST(inode); - res = d_find_alias(inode); + res = d_find_any_alias(inode); if (res) goto out_iput; @@ -1176,7 +1198,7 @@ struct dentry *d_obtain_alias(struct inode *inode) tmp->d_parent = tmp; /* make sure dput doesn't croak */ spin_lock(&dcache_lock); - res = __d_find_alias(inode, 0); + res = __d_find_any_alias(inode); if (res) { spin_unlock(&dcache_lock); dput(tmp);