From mboxrd@z Thu Jan 1 00:00:00 1970 From: akpm@linux-foundation.org Subject: [patch 1/7] vfs: fix vfs_rename_dir for FS_RENAME_DOES_D_MOVE filesystems Date: Tue, 27 Apr 2010 14:23:54 -0700 Message-ID: <201004272123.o3RLNsDK020894@imap1.linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Cc: linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, mszeredi@suse.cz, hch@lst.de, mark.fasheh@oracle.com, sage@newdream.net, trond.myklebust@fys.uio.no, zach.brown@oracle.com To: viro@zeniv.linux.org.uk Return-path: Received: from smtp1.linux-foundation.org ([140.211.169.13]:58826 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757072Ab0D0VYb (ORCPT ); Tue, 27 Apr 2010 17:24:31 -0400 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Miklos Szeredi vfs_rename_dir() doesn't properly account for filesystems with FS_RENAME_DOES_D_MOVE. If new_dentry has a target inode attached, it unhashes the new_dentry prior to the rename() iop and rehashes it after, but doesn't account for the possibility that rename() may have swapped {old,new}_dentry. For FS_RENAME_DOES_D_MOVE filesystems, it rehashes new_dentry (now the old renamed-from name, which d_move() expected to go away), such that a subsequent lookup will find it. This was caught by the recently posted POSIX fstest suite, rename/10.t test 62 (and others) on ceph. The bug was introduced by: commit 349457ccf2592c14bdf13b6706170ae2e94931b1 "[PATCH] Allow file systems to manually d_move() inside of ->rename()" Fix by not rehashing the new dentry. Rehashing used to be needed by d_move() but isn't anymore. Reported-by: Sage Weil Cc: Zach Brown Signed-off-by: Miklos Szeredi Cc: Mark Fasheh Cc: Trond Myklebust Cc: Al Viro Cc: Christoph Hellwig Signed-off-by: Andrew Morton --- fs/namei.c | 2 -- 1 file changed, 2 deletions(-) diff -puN fs/namei.c~vfs-fix-vfs_rename_dir-for-fs_rename_does_d_move-filesystems fs/namei.c --- a/fs/namei.c~vfs-fix-vfs_rename_dir-for-fs_rename_does_d_move-filesystems +++ a/fs/namei.c @@ -2583,8 +2583,6 @@ static int vfs_rename_dir(struct inode * if (!error) target->i_flags |= S_DEAD; mutex_unlock(&target->i_mutex); - if (d_unhashed(new_dentry)) - d_rehash(new_dentry); dput(new_dentry); } if (!error) _