From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from linuxhacker.ru ([217.76.32.60]:35790 "EHLO fiona.linuxhacker.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751721AbcFBX76 (ORCPT ); Thu, 2 Jun 2016 19:59:58 -0400 From: green@linuxhacker.ru To: Al Viro Cc: "J. Bruce Fields" , " Mailing List" , "" , Oleg Drokin Subject: [PATCH] Allow d_splice_alias to accept hashed dentries Date: Thu, 2 Jun 2016 19:59:37 -0400 Message-Id: <1464911977-1499247-1-git-send-email-green@linuxhacker.ru> In-Reply-To: References: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Oleg Drokin The comment at the top of the function already permits it, just take out the assetrtion and update __d_add to be aware of this. Move the BUG_ON to d_add which is the other user of __d_add and presumably we do not want to allow hashed dentries as input there. Signed-off-by: Oleg Drokin --- So seeing how there's only one other __d_add user, I just moved the BUG_ON to d_add and allowed __d_add to not call _d_rehash if the dentry is already hashed. This seems to be working as expected and I don't see any problems with it. Of course I am probably missing some other important consideration ;) fs/dcache.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index ad4a542..0e35049 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2565,7 +2565,8 @@ static inline void __d_add(struct dentry *dentry, struct inode *inode) raw_write_seqcount_end(&dentry->d_seq); __fsnotify_d_instantiate(dentry); } - _d_rehash(dentry); + if (d_unhashed(dentry)) + _d_rehash(dentry); if (dir) end_dir_add(dir, n); spin_unlock(&dentry->d_lock); @@ -2584,6 +2585,8 @@ static inline void __d_add(struct dentry *dentry, struct inode *inode) void d_add(struct dentry *entry, struct inode *inode) { + BUG_ON(!d_unhashed(entry)); + if (inode) { security_d_instantiate(entry, inode); spin_lock(&inode->i_lock); @@ -2986,8 +2989,6 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) if (IS_ERR(inode)) return ERR_CAST(inode); - BUG_ON(!d_unhashed(dentry)); - if (!inode) goto out; -- 2.1.0