Skip to content

Commit 9d35ceb

Browse files
author
Al Viro
committed
udf_rename(): only access the child content on cross-directory rename
We can't really afford locking the source on same-directory rename; currently vfs_rename() tries to do that, but it will have to be changed. The logics in udf_rename() is lazy and goes looking for ".." in source even in same-directory case. It's not hard to get rid of that, leaving that behaviour only for cross-directory case; that VFS can get locks safely (and will keep doing that after the coming changes). Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 9d618d1 commit 9d35ceb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fs/udf/namei.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
766766
struct inode *old_inode = d_inode(old_dentry);
767767
struct inode *new_inode = d_inode(new_dentry);
768768
struct udf_fileident_iter oiter, niter, diriter;
769-
bool has_diriter = false;
769+
bool has_diriter = false, is_dir = false;
770770
int retval;
771771
struct kernel_lb_addr tloc;
772772

@@ -789,6 +789,9 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
789789
if (!empty_dir(new_inode))
790790
goto out_oiter;
791791
}
792+
is_dir = true;
793+
}
794+
if (is_dir && old_dir != new_dir) {
792795
retval = udf_fiiter_find_entry(old_inode, &dotdot_name,
793796
&diriter);
794797
if (retval == -ENOENT) {
@@ -878,7 +881,9 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
878881
udf_dir_entry_len(&diriter.fi));
879882
udf_fiiter_write_fi(&diriter, NULL);
880883
udf_fiiter_release(&diriter);
884+
}
881885

886+
if (is_dir) {
882887
inode_dec_link_count(old_dir);
883888
if (new_inode)
884889
inode_dec_link_count(new_inode);

0 commit comments

Comments
 (0)