Commit 7177a9c4 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Al Viro
Browse files

fs: call rename2 if exists



Christoph Hellwig suggests:

1) make vfs_rename call ->rename2 if it exists instead of ->rename
2) switch all filesystems that you're adding NOREPLACE support for to
   use ->rename2
3) see how many ->rename instances we'll have left after a few
   iterations of 2.
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 2577d92e
...@@ -3455,7 +3455,6 @@ const struct inode_operations ext4_dir_inode_operations = { ...@@ -3455,7 +3455,6 @@ const struct inode_operations ext4_dir_inode_operations = {
.rmdir = ext4_rmdir, .rmdir = ext4_rmdir,
.mknod = ext4_mknod, .mknod = ext4_mknod,
.tmpfile = ext4_tmpfile, .tmpfile = ext4_tmpfile,
.rename = ext4_rename,
.rename2 = ext4_rename2, .rename2 = ext4_rename2,
.setattr = ext4_setattr, .setattr = ext4_setattr,
.setxattr = generic_setxattr, .setxattr = generic_setxattr,
......
...@@ -845,12 +845,6 @@ static int fuse_rename2(struct inode *olddir, struct dentry *oldent, ...@@ -845,12 +845,6 @@ static int fuse_rename2(struct inode *olddir, struct dentry *oldent,
return err; return err;
} }
static int fuse_rename(struct inode *olddir, struct dentry *oldent,
struct inode *newdir, struct dentry *newent)
{
return fuse_rename2(olddir, oldent, newdir, newent, 0);
}
static int fuse_link(struct dentry *entry, struct inode *newdir, static int fuse_link(struct dentry *entry, struct inode *newdir,
struct dentry *newent) struct dentry *newent)
{ {
...@@ -2024,7 +2018,6 @@ static const struct inode_operations fuse_dir_inode_operations = { ...@@ -2024,7 +2018,6 @@ static const struct inode_operations fuse_dir_inode_operations = {
.symlink = fuse_symlink, .symlink = fuse_symlink,
.unlink = fuse_unlink, .unlink = fuse_unlink,
.rmdir = fuse_rmdir, .rmdir = fuse_rmdir,
.rename = fuse_rename,
.rename2 = fuse_rename2, .rename2 = fuse_rename2,
.link = fuse_link, .link = fuse_link,
.setattr = fuse_setattr, .setattr = fuse_setattr,
......
...@@ -4075,7 +4075,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -4075,7 +4075,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
if (error) if (error)
return error; return error;
if (!old_dir->i_op->rename) if (!old_dir->i_op->rename && !old_dir->i_op->rename2)
return -EPERM; return -EPERM;
if (flags && !old_dir->i_op->rename2) if (flags && !old_dir->i_op->rename2)
...@@ -4134,10 +4134,11 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -4134,10 +4134,11 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
if (error) if (error)
goto out; goto out;
} }
if (!flags) { if (!old_dir->i_op->rename2) {
error = old_dir->i_op->rename(old_dir, old_dentry, error = old_dir->i_op->rename(old_dir, old_dentry,
new_dir, new_dentry); new_dir, new_dentry);
} else { } else {
WARN_ON(old_dir->i_op->rename != NULL);
error = old_dir->i_op->rename2(old_dir, old_dentry, error = old_dir->i_op->rename2(old_dir, old_dentry,
new_dir, new_dentry, flags); new_dir, new_dentry, flags);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment