linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfs: call rename2 if exists
@ 2014-05-14 15:27 Miklos Szeredi
  2014-05-14 17:42 ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Miklos Szeredi @ 2014-05-14 15:27 UTC (permalink / raw)
  To: Al Viro; +Cc: Christoph Hellwig, linux-kernel, linux-fsdevel, Stephen Rothwell

Al,

The below patch calls ->rename2() if it exists even for flags == 0.  This will
allow a gradual elimination of ->rename() implementations and finally merging
the two ops.

Please consider pushing this to 3.15, but at least ACK-ing it so I can work on
followup patches for handing RENAME_NOREPLACE in filesystems.

Thanks,
Miklos
----


From: Miklos Szeredi <mszeredi@suse.cz>

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: Miklos Szeredi <mszeredi@suse.cz>
---
 fs/ext4/namei.c |    1 -
 fs/fuse/dir.c   |   26 +++++++++++---------------
 fs/namei.c      |    5 +++--
 3 files changed, 14 insertions(+), 18 deletions(-)

--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -814,13 +814,6 @@ static int fuse_rename_common(struct ino
 	return err;
 }
 
-static int fuse_rename(struct inode *olddir, struct dentry *oldent,
-		       struct inode *newdir, struct dentry *newent)
-{
-	return fuse_rename_common(olddir, oldent, newdir, newent, 0,
-				  FUSE_RENAME, sizeof(struct fuse_rename_in));
-}
-
 static int fuse_rename2(struct inode *olddir, struct dentry *oldent,
 			struct inode *newdir, struct dentry *newent,
 			unsigned int flags)
@@ -831,17 +824,21 @@ static int fuse_rename2(struct inode *ol
 	if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE))
 		return -EINVAL;
 
-	if (fc->no_rename2 || fc->minor < 23)
-		return -EINVAL;
+	if (flags) {
+		if (fc->no_rename2 || fc->minor < 23)
+			return -EINVAL;
 
-	err = fuse_rename_common(olddir, oldent, newdir, newent, flags,
+		err = fuse_rename_common(olddir, oldent, newdir, newent, flags,
 				 FUSE_RENAME2, sizeof(struct fuse_rename2_in));
-	if (err == -ENOSYS) {
-		fc->no_rename2 = 1;
-		err = -EINVAL;
+		if (err == -ENOSYS) {
+			fc->no_rename2 = 1;
+			err = -EINVAL;
+		}
+	} else {
+		err = fuse_rename_common(olddir, oldent, newdir, newent, 0,
+				 FUSE_RENAME, sizeof(struct fuse_rename_in));
 	}
 	return err;
-
 }
 
 static int fuse_link(struct dentry *entry, struct inode *newdir,
@@ -2017,7 +2014,6 @@ static const struct inode_operations fus
 	.symlink	= fuse_symlink,
 	.unlink		= fuse_unlink,
 	.rmdir		= fuse_rmdir,
-	.rename		= fuse_rename,
 	.rename2	= fuse_rename2,
 	.link		= fuse_link,
 	.setattr	= fuse_setattr,
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4073,7 +4073,7 @@ int vfs_rename(struct inode *old_dir, st
 	if (error)
 		return error;
 
-	if (!old_dir->i_op->rename)
+	if (!old_dir->i_op->rename && !old_dir->i_op->rename2)
 		return -EPERM;
 
 	if (flags && !old_dir->i_op->rename2)
@@ -4132,10 +4132,11 @@ int vfs_rename(struct inode *old_dir, st
 		if (error)
 			goto out;
 	}
-	if (!flags) {
+	if (!old_dir->i_op->rename2) {
 		error = old_dir->i_op->rename(old_dir, old_dentry,
 					      new_dir, new_dentry);
 	} else {
+		WARN_ON(old_dir->i_op->rename != NULL);
 		error = old_dir->i_op->rename2(old_dir, old_dentry,
 					       new_dir, new_dentry, flags);
 	}
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -3434,7 +3434,6 @@ const struct inode_operations ext4_dir_i
 	.rmdir		= ext4_rmdir,
 	.mknod		= ext4_mknod,
 	.tmpfile	= ext4_tmpfile,
-	.rename		= ext4_rename,
 	.rename2	= ext4_rename2,
 	.setattr	= ext4_setattr,
 	.setxattr	= generic_setxattr,


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] vfs: call rename2 if exists
  2014-05-14 15:27 [PATCH] vfs: call rename2 if exists Miklos Szeredi
@ 2014-05-14 17:42 ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2014-05-14 17:42 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: Al Viro, Christoph Hellwig, linux-kernel, linux-fsdevel,
	Stephen Rothwell

On Wed, May 14, 2014 at 05:27:20PM +0200, Miklos Szeredi wrote:
> Al,
> 
> The below patch calls ->rename2() if it exists even for flags == 0.  This will
> allow a gradual elimination of ->rename() implementations and finally merging
> the two ops.
> 
> Please consider pushing this to 3.15, but at least ACK-ing it so I can work on
> followup patches for handing RENAME_NOREPLACE in filesystems.

You'll have my ACK at least:

Acked-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] vfs: call rename2 if exists
  2014-05-20  9:22 Miklos Szeredi
@ 2014-07-13 11:48 ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2014-07-13 11:48 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: Linus Torvalds, Al Viro, Christoph Hellwig, linux-kernel, linux-fsdevel

On Tue, May 20, 2014 at 11:22:47AM +0200, Miklos Szeredi wrote:
> Linus,
> 
> Please consider applying this patch to 3.15, so we can move forward with adding
> RENAME_NOREPLACE support to filesystems during the next cycle.

Looks like this didn't go anywhere.  Al, can you at least pick this for
3.17?  Even better would be to just merge rename and rename2 to make
everyones life easier..

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] vfs: call rename2 if exists
@ 2014-05-20  9:22 Miklos Szeredi
  2014-07-13 11:48 ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Miklos Szeredi @ 2014-05-20  9:22 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Al Viro, Christoph Hellwig, linux-kernel, linux-fsdevel

Linus,

Please consider applying this patch to 3.15, so we can move forward with adding
RENAME_NOREPLACE support to filesystems during the next cycle.

Thanks,
Miklos

---
From: Miklos Szeredi <mszeredi@suse.cz>

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: Miklos Szeredi <mszeredi@suse.cz>
Acked-by: Christoph Hellwig <hch@lst.de>
---
 fs/ext4/namei.c |    1 -
 fs/fuse/dir.c   |   26 +++++++++++---------------
 fs/namei.c      |    5 +++--
 3 files changed, 14 insertions(+), 18 deletions(-)

--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -814,13 +814,6 @@ static int fuse_rename_common(struct ino
 	return err;
 }
 
-static int fuse_rename(struct inode *olddir, struct dentry *oldent,
-		       struct inode *newdir, struct dentry *newent)
-{
-	return fuse_rename_common(olddir, oldent, newdir, newent, 0,
-				  FUSE_RENAME, sizeof(struct fuse_rename_in));
-}
-
 static int fuse_rename2(struct inode *olddir, struct dentry *oldent,
 			struct inode *newdir, struct dentry *newent,
 			unsigned int flags)
@@ -831,17 +824,21 @@ static int fuse_rename2(struct inode *ol
 	if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE))
 		return -EINVAL;
 
-	if (fc->no_rename2 || fc->minor < 23)
-		return -EINVAL;
+	if (flags) {
+		if (fc->no_rename2 || fc->minor < 23)
+			return -EINVAL;
 
-	err = fuse_rename_common(olddir, oldent, newdir, newent, flags,
+		err = fuse_rename_common(olddir, oldent, newdir, newent, flags,
 				 FUSE_RENAME2, sizeof(struct fuse_rename2_in));
-	if (err == -ENOSYS) {
-		fc->no_rename2 = 1;
-		err = -EINVAL;
+		if (err == -ENOSYS) {
+			fc->no_rename2 = 1;
+			err = -EINVAL;
+		}
+	} else {
+		err = fuse_rename_common(olddir, oldent, newdir, newent, 0,
+				 FUSE_RENAME, sizeof(struct fuse_rename_in));
 	}
 	return err;
-
 }
 
 static int fuse_link(struct dentry *entry, struct inode *newdir,
@@ -2017,7 +2014,6 @@ static const struct inode_operations fus
 	.symlink	= fuse_symlink,
 	.unlink		= fuse_unlink,
 	.rmdir		= fuse_rmdir,
-	.rename		= fuse_rename,
 	.rename2	= fuse_rename2,
 	.link		= fuse_link,
 	.setattr	= fuse_setattr,
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4073,7 +4073,7 @@ int vfs_rename(struct inode *old_dir, st
 	if (error)
 		return error;
 
-	if (!old_dir->i_op->rename)
+	if (!old_dir->i_op->rename && !old_dir->i_op->rename2)
 		return -EPERM;
 
 	if (flags && !old_dir->i_op->rename2)
@@ -4132,10 +4132,11 @@ int vfs_rename(struct inode *old_dir, st
 		if (error)
 			goto out;
 	}
-	if (!flags) {
+	if (!old_dir->i_op->rename2) {
 		error = old_dir->i_op->rename(old_dir, old_dentry,
 					      new_dir, new_dentry);
 	} else {
+		WARN_ON(old_dir->i_op->rename != NULL);
 		error = old_dir->i_op->rename2(old_dir, old_dentry,
 					       new_dir, new_dentry, flags);
 	}
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -3434,7 +3434,6 @@ const struct inode_operations ext4_dir_i
 	.rmdir		= ext4_rmdir,
 	.mknod		= ext4_mknod,
 	.tmpfile	= ext4_tmpfile,
-	.rename		= ext4_rename,
 	.rename2	= ext4_rename2,
 	.setattr	= ext4_setattr,
 	.setxattr	= generic_setxattr,

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-13 11:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-14 15:27 [PATCH] vfs: call rename2 if exists Miklos Szeredi
2014-05-14 17:42 ` Christoph Hellwig
2014-05-20  9:22 Miklos Szeredi
2014-07-13 11:48 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).