linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] vfs: finish rename -> rename2 conversion
@ 2016-08-23 14:05 Miklos Szeredi
  2016-08-23 14:05 ` [PATCH 1/7] ncpfs: fix unused variable warning Miklos Szeredi
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: Miklos Szeredi @ 2016-08-23 14:05 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: linux-kernel, Al Viro, Eric Van Hensbergen, David Howells,
	Ilya Dryomov, Jan Harkes, Tyler Hicks, Boaz Harrosh,
	Greg Kroah-Hartman, Oleg Drokin, Trond Myklebust, Mark Fasheh,
	Mike Marshall, Alexei Starovoitov, Jan Kara, Theodore Ts'o,
	Jaegeuk Kim, OGAWA Hirofumi, Mikulas Patocka, David Woodhouse,
	Dave Kleikamp, Ryusuke Konishi, Bob Copeland, Christoph Hellwig,
	Richard Weinberger

This series gets rid of the duplicate interfaces for rename.  The only
difference between the two that the new, i_op->rename2() has an added flags
argument.  This needs to be handled in each instance.

For 21 local filesystems the RENAME_NOREPLACE flag can be supported "for
free", just by moving to the new interface and allowing this flag.  The
remaining 12 distributed filesystems are converted too, which only allow
zero flags.

Git tree is here.

  git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git#rename2

Thanks,
Miklos
---

Miklos Szeredi (7):
  ncpfs: fix unused variable warning
  fs: support RENAME_NOREPLACE for local filesystems
  libfs: support RENAME_NOREPLACE in simple_rename()
  fs: make remaining filesystems use .rename2
  vfs: remove unused i_op->rename
  fs: rename "rename2" i_op to "rename"
  vfs: add note about i_op->rename changes to porting

 Documentation/filesystems/Locking           |  8 ++------
 Documentation/filesystems/directory-locking |  2 +-
 Documentation/filesystems/porting           |  4 ++++
 Documentation/filesystems/vfs.txt           |  9 ++-------
 drivers/staging/lustre/lustre/llite/namei.c |  8 ++++++--
 fs/9p/v9fs.h                                |  3 ++-
 fs/9p/vfs_inode.c                           |  6 +++++-
 fs/affs/affs.h                              |  3 ++-
 fs/affs/namei.c                             |  6 +++++-
 fs/afs/dir.c                                |  9 +++++++--
 fs/bad_inode.c                              |  2 +-
 fs/bfs/dir.c                                |  6 +++++-
 fs/btrfs/inode.c                            |  2 +-
 fs/cachefiles/namei.c                       |  3 +--
 fs/ceph/dir.c                               |  6 +++++-
 fs/cifs/cifsfs.c                            |  2 +-
 fs/coda/dir.c                               |  6 +++++-
 fs/debugfs/inode.c                          |  2 +-
 fs/ecryptfs/inode.c                         |  6 +++++-
 fs/exofs/namei.c                            |  8 ++++++--
 fs/ext2/namei.c                             |  6 +++++-
 fs/ext4/namei.c                             |  2 +-
 fs/f2fs/namei.c                             |  2 +-
 fs/fat/namei_msdos.c                        |  6 +++++-
 fs/fat/namei_vfat.c                         |  6 +++++-
 fs/fuse/dir.c                               |  2 +-
 fs/gfs2/inode.c                             |  2 +-
 fs/hfs/dir.c                                |  6 +++++-
 fs/hfsplus/dir.c                            |  6 +++++-
 fs/hostfs/hostfs_kern.c                     |  2 +-
 fs/hpfs/namei.c                             |  6 +++++-
 fs/jffs2/dir.c                              |  9 +++++++--
 fs/jfs/namei.c                              |  5 ++++-
 fs/kernfs/dir.c                             |  6 +++++-
 fs/libfs.c                                  |  6 +++++-
 fs/logfs/dir.c                              |  6 +++++-
 fs/minix/namei.c                            |  6 +++++-
 fs/namei.c                                  | 15 +++------------
 fs/ncpfs/dir.c                              | 11 +++++++----
 fs/nfs/dir.c                                |  6 +++++-
 fs/nfs/internal.h                           |  3 ++-
 fs/nilfs2/namei.c                           |  6 +++++-
 fs/ocfs2/namei.c                            |  6 +++++-
 fs/omfs/dir.c                               |  6 +++++-
 fs/orangefs/namei.c                         |  6 +++++-
 fs/overlayfs/dir.c                          |  2 +-
 fs/overlayfs/overlayfs.h                    |  4 ++--
 fs/reiserfs/namei.c                         |  6 +++++-
 fs/sysv/namei.c                             |  6 +++++-
 fs/ubifs/dir.c                              |  8 ++++++--
 fs/udf/namei.c                              |  6 +++++-
 fs/ufs/namei.c                              |  6 +++++-
 fs/xfs/xfs_iops.c                           |  4 ++--
 include/linux/fs.h                          |  5 ++---
 mm/shmem.c                                  |  2 +-
 security/tomoyo/realpath.c                  |  4 ++--
 56 files changed, 206 insertions(+), 91 deletions(-)

-- 
2.5.5

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

* [PATCH 1/7] ncpfs: fix unused variable warning
  2016-08-23 14:05 [PATCH 0/7] vfs: finish rename -> rename2 conversion Miklos Szeredi
@ 2016-08-23 14:05 ` Miklos Szeredi
  2016-08-23 14:05 ` [PATCH 2/7] fs: support RENAME_NOREPLACE for local filesystems Miklos Szeredi
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Miklos Szeredi @ 2016-08-23 14:05 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, Al Viro

Without CONFIG_NCPFS_NLS the following warning is seen:

fs/ncpfs/dir.c: In function 'ncp_hash_dentry':
fs/ncpfs/dir.c:136:23: warning: unused variable 'sb' [-Wunused-variable]
   struct super_block *sb = dentry->d_sb;

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
 fs/ncpfs/dir.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index 17de5c13dfae..f5b594e2457c 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -133,12 +133,11 @@ ncp_hash_dentry(const struct dentry *dentry, struct qstr *this)
 		return 0;
 
 	if (!ncp_case_sensitive(inode)) {
-		struct super_block *sb = dentry->d_sb;
 		struct nls_table *t;
 		unsigned long hash;
 		int i;
 
-		t = NCP_IO_TABLE(sb);
+		t = NCP_IO_TABLE(dentry->d_sb);
 		hash = init_name_hash(dentry);
 		for (i=0; i<this->len ; i++)
 			hash = partial_name_hash(ncp_tolower(t, this->name[i]),
-- 
2.5.5

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

* [PATCH 2/7] fs: support RENAME_NOREPLACE for local filesystems
  2016-08-23 14:05 [PATCH 0/7] vfs: finish rename -> rename2 conversion Miklos Szeredi
  2016-08-23 14:05 ` [PATCH 1/7] ncpfs: fix unused variable warning Miklos Szeredi
@ 2016-08-23 14:05 ` Miklos Szeredi
  2016-08-23 21:48   ` Richard Weinberger
                     ` (2 more replies)
  2016-08-23 14:05 ` [PATCH 3/7] libfs: support RENAME_NOREPLACE in simple_rename() Miklos Szeredi
                   ` (5 subsequent siblings)
  7 siblings, 3 replies; 17+ messages in thread
From: Miklos Szeredi @ 2016-08-23 14:05 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: linux-kernel, Al Viro, Jan Kara, Theodore Ts'o, Jaegeuk Kim,
	OGAWA Hirofumi, Mikulas Patocka, David Woodhouse, Dave Kleikamp,
	Ryusuke Konishi, Bob Copeland, Christoph Hellwig,
	Richard Weinberger

This is trivial to do:

 - add flags argument to foo_rename()
 - check if flags doesn't have any other than RENAME_NOREPLACE
 - assign foo_rename() to .rename2 instead of .rename

Filesystems converted:

affs, bfs, ext2, hfs, hfsplus, jffs2, jfs, logfs, minix, msdos, nilfs2,
omfs, reiserfs, sysvfs, ubifs, udf, ufs, vfat.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Mikulas Patocka <mpatocka@redhat.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Dave Kleikamp <shaggy@kernel.org>
Cc: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Cc: Bob Copeland <me@bobcopeland.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Richard Weinberger <richard@nod.at>
---
 fs/affs/affs.h       |  3 ++-
 fs/affs/dir.c        |  2 +-
 fs/affs/namei.c      |  6 +++++-
 fs/bfs/dir.c         |  8 ++++++--
 fs/ext2/namei.c      |  8 ++++++--
 fs/fat/namei_msdos.c |  8 ++++++--
 fs/fat/namei_vfat.c  |  8 ++++++--
 fs/hfs/dir.c         |  8 ++++++--
 fs/hfsplus/dir.c     |  8 ++++++--
 fs/hpfs/namei.c      |  8 ++++++--
 fs/jffs2/dir.c       | 11 ++++++++---
 fs/jfs/namei.c       |  7 +++++--
 fs/logfs/dir.c       |  8 ++++++--
 fs/minix/namei.c     |  8 ++++++--
 fs/nilfs2/namei.c    |  8 ++++++--
 fs/omfs/dir.c        |  8 ++++++--
 fs/reiserfs/namei.c  |  8 ++++++--
 fs/sysv/namei.c      |  8 ++++++--
 fs/ubifs/dir.c       |  8 ++++++--
 fs/udf/namei.c       |  8 ++++++--
 fs/ufs/namei.c       |  8 ++++++--
 21 files changed, 117 insertions(+), 40 deletions(-)

diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index cc2b2efc9211..2f088773f1c0 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -173,7 +173,8 @@ extern int	affs_link(struct dentry *olddentry, struct inode *dir,
 extern int	affs_symlink(struct inode *dir, struct dentry *dentry,
 			     const char *symname);
 extern int	affs_rename(struct inode *old_dir, struct dentry *old_dentry,
-			    struct inode *new_dir, struct dentry *new_dentry);
+			    struct inode *new_dir, struct dentry *new_dentry,
+			    unsigned int flags);
 
 /* inode.c */
 
diff --git a/fs/affs/dir.c b/fs/affs/dir.c
index f1e7294381c5..8f127c239472 100644
--- a/fs/affs/dir.c
+++ b/fs/affs/dir.c
@@ -35,7 +35,7 @@ const struct inode_operations affs_dir_inode_operations = {
 	.symlink	= affs_symlink,
 	.mkdir		= affs_mkdir,
 	.rmdir		= affs_rmdir,
-	.rename		= affs_rename,
+	.rename2	= affs_rename,
 	.setattr	= affs_notify_change,
 };
 
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index a2d68f828d53..29186d29a3b6 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -414,12 +414,16 @@ affs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
 
 int
 affs_rename(struct inode *old_dir, struct dentry *old_dentry,
-	    struct inode *new_dir, struct dentry *new_dentry)
+	    struct inode *new_dir, struct dentry *new_dentry,
+	    unsigned int flags)
 {
 	struct super_block *sb = old_dir->i_sb;
 	struct buffer_head *bh = NULL;
 	int retval;
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	pr_debug("%s(old=%lu,\"%pd\" to new=%lu,\"%pd\")\n", __func__,
 		 old_dir->i_ino, old_dentry, new_dir->i_ino, new_dentry);
 
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index 34a5bc2f1290..9d5f875e85d0 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -207,7 +207,8 @@ out_brelse:
 }
 
 static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry,
-			struct inode *new_dir, struct dentry *new_dentry)
+		      struct inode *new_dir, struct dentry *new_dentry,
+		      unsigned int flags)
 {
 	struct inode *old_inode, *new_inode;
 	struct buffer_head *old_bh, *new_bh;
@@ -215,6 +216,9 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	struct bfs_sb_info *info;
 	int error = -ENOENT;
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	old_bh = new_bh = NULL;
 	old_inode = d_inode(old_dentry);
 	if (S_ISDIR(old_inode->i_mode))
@@ -270,7 +274,7 @@ const struct inode_operations bfs_dir_inops = {
 	.lookup			= bfs_lookup,
 	.link			= bfs_link,
 	.unlink			= bfs_unlink,
-	.rename			= bfs_rename,
+	.rename2		= bfs_rename,
 };
 
 static int bfs_add_entry(struct inode *dir, const unsigned char *name,
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index d446203127fc..38fac85ff786 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -328,7 +328,8 @@ static int ext2_rmdir (struct inode * dir, struct dentry *dentry)
 }
 
 static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
-	struct inode * new_dir,	struct dentry * new_dentry )
+			struct inode * new_dir,	struct dentry * new_dentry,
+			unsigned int flags)
 {
 	struct inode * old_inode = d_inode(old_dentry);
 	struct inode * new_inode = d_inode(new_dentry);
@@ -338,6 +339,9 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
 	struct ext2_dir_entry_2 * old_de;
 	int err;
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	err = dquot_initialize(old_dir);
 	if (err)
 		goto out;
@@ -426,7 +430,7 @@ const struct inode_operations ext2_dir_inode_operations = {
 	.mkdir		= ext2_mkdir,
 	.rmdir		= ext2_rmdir,
 	.mknod		= ext2_mknod,
-	.rename		= ext2_rename,
+	.rename2	= ext2_rename,
 #ifdef CONFIG_EXT2_FS_XATTR
 	.setxattr	= generic_setxattr,
 	.getxattr	= generic_getxattr,
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
index 664655b2c55f..6c814699d5d5 100644
--- a/fs/fat/namei_msdos.c
+++ b/fs/fat/namei_msdos.c
@@ -596,12 +596,16 @@ error_inode:
 
 /***** Rename, a wrapper for rename_same_dir & rename_diff_dir */
 static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry,
-			struct inode *new_dir, struct dentry *new_dentry)
+			struct inode *new_dir, struct dentry *new_dentry,
+			unsigned int flags)
 {
 	struct super_block *sb = old_dir->i_sb;
 	unsigned char old_msdos_name[MSDOS_NAME], new_msdos_name[MSDOS_NAME];
 	int err, is_hid;
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	mutex_lock(&MSDOS_SB(sb)->s_lock);
 
 	err = msdos_format_name(old_dentry->d_name.name,
@@ -633,7 +637,7 @@ static const struct inode_operations msdos_dir_inode_operations = {
 	.unlink		= msdos_unlink,
 	.mkdir		= msdos_mkdir,
 	.rmdir		= msdos_rmdir,
-	.rename		= msdos_rename,
+	.rename2	= msdos_rename,
 	.setattr	= fat_setattr,
 	.getattr	= fat_getattr,
 };
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index 92b7363dafa9..ce8986f3918a 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -903,7 +903,8 @@ out:
 }
 
 static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
-		       struct inode *new_dir, struct dentry *new_dentry)
+		       struct inode *new_dir, struct dentry *new_dentry,
+		       unsigned int flags)
 {
 	struct buffer_head *dotdot_bh;
 	struct msdos_dir_entry *dotdot_de;
@@ -914,6 +915,9 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
 	int err, is_dir, update_dotdot, corrupt = 0;
 	struct super_block *sb = old_dir->i_sb;
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	old_sinfo.bh = sinfo.bh = dotdot_bh = NULL;
 	old_inode = d_inode(old_dentry);
 	new_inode = d_inode(new_dentry);
@@ -1036,7 +1040,7 @@ static const struct inode_operations vfat_dir_inode_operations = {
 	.unlink		= vfat_unlink,
 	.mkdir		= vfat_mkdir,
 	.rmdir		= vfat_rmdir,
-	.rename		= vfat_rename,
+	.rename2	= vfat_rename,
 	.setattr	= fat_setattr,
 	.getattr	= fat_getattr,
 };
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index 163190ecc0d2..d5ce9fcad10f 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -286,10 +286,14 @@ static int hfs_remove(struct inode *dir, struct dentry *dentry)
  * XXX: how do you handle must_be dir?
  */
 static int hfs_rename(struct inode *old_dir, struct dentry *old_dentry,
-		      struct inode *new_dir, struct dentry *new_dentry)
+		      struct inode *new_dir, struct dentry *new_dentry,
+		      unsigned int flags)
 {
 	int res;
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	/* Unlink destination if it already exists */
 	if (d_really_is_positive(new_dentry)) {
 		res = hfs_remove(new_dir, new_dentry);
@@ -320,6 +324,6 @@ const struct inode_operations hfs_dir_inode_operations = {
 	.unlink		= hfs_remove,
 	.mkdir		= hfs_mkdir,
 	.rmdir		= hfs_remove,
-	.rename		= hfs_rename,
+	.rename2	= hfs_rename,
 	.setattr	= hfs_inode_setattr,
 };
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 42e128661dc1..ca64a75f12b3 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -530,10 +530,14 @@ static int hfsplus_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 }
 
 static int hfsplus_rename(struct inode *old_dir, struct dentry *old_dentry,
-			  struct inode *new_dir, struct dentry *new_dentry)
+			  struct inode *new_dir, struct dentry *new_dentry,
+			  unsigned int flags)
 {
 	int res;
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	/* Unlink destination if it already exists */
 	if (d_really_is_positive(new_dentry)) {
 		if (d_is_dir(new_dentry))
@@ -561,7 +565,7 @@ const struct inode_operations hfsplus_dir_inode_operations = {
 	.rmdir			= hfsplus_rmdir,
 	.symlink		= hfsplus_symlink,
 	.mknod			= hfsplus_mknod,
-	.rename			= hfsplus_rename,
+	.rename2		= hfsplus_rename,
 	.setxattr		= generic_setxattr,
 	.getxattr		= generic_getxattr,
 	.listxattr		= hfsplus_listxattr,
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index bb8d67e2740a..3c5c1a75569d 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -507,7 +507,8 @@ const struct address_space_operations hpfs_symlink_aops = {
 };
 	
 static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
-		struct inode *new_dir, struct dentry *new_dentry)
+		       struct inode *new_dir, struct dentry *new_dentry,
+		       unsigned int flags)
 {
 	const unsigned char *old_name = old_dentry->d_name.name;
 	unsigned old_len = old_dentry->d_name.len;
@@ -524,6 +525,9 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	struct fnode *fnode;
 	int err;
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	if ((err = hpfs_chk_name(new_name, &new_len))) return err;
 	err = 0;
 	hpfs_adjust_length(old_name, &old_len);
@@ -618,6 +622,6 @@ const struct inode_operations hpfs_dir_iops =
 	.mkdir		= hpfs_mkdir,
 	.rmdir		= hpfs_rmdir,
 	.mknod		= hpfs_mknod,
-	.rename		= hpfs_rename,
+	.rename2	= hpfs_rename,
 	.setattr	= hpfs_setattr,
 };
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 30eb33ff8189..11e711b12ccf 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -35,7 +35,8 @@ static int jffs2_mkdir (struct inode *,struct dentry *,umode_t);
 static int jffs2_rmdir (struct inode *,struct dentry *);
 static int jffs2_mknod (struct inode *,struct dentry *,umode_t,dev_t);
 static int jffs2_rename (struct inode *, struct dentry *,
-			 struct inode *, struct dentry *);
+			 struct inode *, struct dentry *,
+			 unsigned int);
 
 const struct file_operations jffs2_dir_operations =
 {
@@ -57,7 +58,7 @@ const struct inode_operations jffs2_dir_inode_operations =
 	.mkdir =	jffs2_mkdir,
 	.rmdir =	jffs2_rmdir,
 	.mknod =	jffs2_mknod,
-	.rename =	jffs2_rename,
+	.rename2 =	jffs2_rename,
 	.get_acl =	jffs2_get_acl,
 	.set_acl =	jffs2_set_acl,
 	.setattr =	jffs2_setattr,
@@ -759,7 +760,8 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, umode_t mode
 }
 
 static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
-			 struct inode *new_dir_i, struct dentry *new_dentry)
+			 struct inode *new_dir_i, struct dentry *new_dentry,
+			 unsigned int flags)
 {
 	int ret;
 	struct jffs2_sb_info *c = JFFS2_SB_INFO(old_dir_i->i_sb);
@@ -767,6 +769,9 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
 	uint8_t type;
 	uint32_t now;
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	/* The VFS will check for us and prevent trying to rename a
 	 * file over a directory and vice versa, but if it's a directory,
 	 * the VFS can't check whether the victim is empty. The filesystem
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 814b0c58016c..ee1aa32f7c24 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -1078,7 +1078,8 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
  * FUNCTION:	rename a file or directory
  */
 static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
-	       struct inode *new_dir, struct dentry *new_dentry)
+		      struct inode *new_dir, struct dentry *new_dentry,
+		      unsigned int flags)
 {
 	struct btstack btstack;
 	ino_t ino;
@@ -1097,6 +1098,8 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	s64 new_size = 0;
 	int commit_flag;
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
 
 	jfs_info("jfs_rename: %pd %pd", old_dentry, new_dentry);
 
@@ -1536,7 +1539,7 @@ const struct inode_operations jfs_dir_inode_operations = {
 	.mkdir		= jfs_mkdir,
 	.rmdir		= jfs_rmdir,
 	.mknod		= jfs_mknod,
-	.rename		= jfs_rename,
+	.rename2	= jfs_rename,
 	.setxattr	= generic_setxattr,
 	.getxattr	= generic_getxattr,
 	.listxattr	= jfs_listxattr,
diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c
index 9568064ecadf..57f2da17a905 100644
--- a/fs/logfs/dir.c
+++ b/fs/logfs/dir.c
@@ -718,8 +718,12 @@ out:
 }
 
 static int logfs_rename(struct inode *old_dir, struct dentry *old_dentry,
-			struct inode *new_dir, struct dentry *new_dentry)
+			struct inode *new_dir, struct dentry *new_dentry,
+			unsigned int flags)
 {
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	if (d_really_is_positive(new_dentry))
 		return logfs_rename_target(old_dir, old_dentry,
 					   new_dir, new_dentry);
@@ -783,7 +787,7 @@ const struct inode_operations logfs_dir_iops = {
 	.lookup		= logfs_lookup,
 	.mkdir		= logfs_mkdir,
 	.mknod		= logfs_mknod,
-	.rename		= logfs_rename,
+	.rename2	= logfs_rename,
 	.rmdir		= logfs_rmdir,
 	.symlink	= logfs_symlink,
 	.unlink		= logfs_unlink,
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index 2887d1d95ce2..6dc210c0e3ce 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -185,7 +185,8 @@ static int minix_rmdir(struct inode * dir, struct dentry *dentry)
 }
 
 static int minix_rename(struct inode * old_dir, struct dentry *old_dentry,
-			   struct inode * new_dir, struct dentry *new_dentry)
+			struct inode * new_dir, struct dentry *new_dentry,
+			unsigned int flags)
 {
 	struct inode * old_inode = d_inode(old_dentry);
 	struct inode * new_inode = d_inode(new_dentry);
@@ -195,6 +196,9 @@ static int minix_rename(struct inode * old_dir, struct dentry *old_dentry,
 	struct minix_dir_entry * old_de;
 	int err = -ENOENT;
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	old_de = minix_find_entry(old_dentry, &old_page);
 	if (!old_de)
 		goto out;
@@ -264,7 +268,7 @@ const struct inode_operations minix_dir_inode_operations = {
 	.mkdir		= minix_mkdir,
 	.rmdir		= minix_rmdir,
 	.mknod		= minix_mknod,
-	.rename		= minix_rename,
+	.rename2	= minix_rename,
 	.getattr	= minix_getattr,
 	.tmpfile	= minix_tmpfile,
 };
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index dbcf1dc93a51..8540c13ef374 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -350,7 +350,8 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry)
 }
 
 static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
-			struct inode *new_dir,	struct dentry *new_dentry)
+			struct inode *new_dir,	struct dentry *new_dentry,
+			unsigned int flags)
 {
 	struct inode *old_inode = d_inode(old_dentry);
 	struct inode *new_inode = d_inode(new_dentry);
@@ -361,6 +362,9 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	struct nilfs_transaction_info ti;
 	int err;
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	err = nilfs_transaction_begin(old_dir->i_sb, &ti, 1);
 	if (unlikely(err))
 		return err;
@@ -552,7 +556,7 @@ const struct inode_operations nilfs_dir_inode_operations = {
 	.mkdir		= nilfs_mkdir,
 	.rmdir		= nilfs_rmdir,
 	.mknod		= nilfs_mknod,
-	.rename		= nilfs_rename,
+	.rename2	= nilfs_rename,
 	.setattr	= nilfs_setattr,
 	.permission	= nilfs_permission,
 	.fiemap		= nilfs_fiemap,
diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
index c8cbf3b60645..417511bbe362 100644
--- a/fs/omfs/dir.c
+++ b/fs/omfs/dir.c
@@ -371,12 +371,16 @@ static bool omfs_fill_chain(struct inode *dir, struct dir_context *ctx,
 }
 
 static int omfs_rename(struct inode *old_dir, struct dentry *old_dentry,
-		struct inode *new_dir, struct dentry *new_dentry)
+		       struct inode *new_dir, struct dentry *new_dentry,
+		       unsigned int flags)
 {
 	struct inode *new_inode = d_inode(new_dentry);
 	struct inode *old_inode = d_inode(old_dentry);
 	int err;
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	if (new_inode) {
 		/* overwriting existing file/dir */
 		err = omfs_remove(new_dir, new_dentry);
@@ -444,7 +448,7 @@ static int omfs_readdir(struct file *file, struct dir_context *ctx)
 const struct inode_operations omfs_dir_inops = {
 	.lookup = omfs_lookup,
 	.mkdir = omfs_mkdir,
-	.rename = omfs_rename,
+	.rename2 = omfs_rename,
 	.create = omfs_create,
 	.unlink = omfs_remove,
 	.rmdir = omfs_remove,
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index 8a36696d6df9..21b4b7138985 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -1306,7 +1306,8 @@ static void set_ino_in_dir_entry(struct reiserfs_dir_entry *de,
  * get_empty_nodes or its clones
  */
 static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
-			   struct inode *new_dir, struct dentry *new_dentry)
+			   struct inode *new_dir, struct dentry *new_dentry,
+			   unsigned int flags)
 {
 	int retval;
 	INITIALIZE_PATH(old_entry_path);
@@ -1321,6 +1322,9 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	unsigned long savelink = 1;
 	struct timespec ctime;
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	/*
 	 * three balancings: (1) old name removal, (2) new name insertion
 	 * and (3) maybe "save" link insertion
@@ -1648,7 +1652,7 @@ const struct inode_operations reiserfs_dir_inode_operations = {
 	.mkdir = reiserfs_mkdir,
 	.rmdir = reiserfs_rmdir,
 	.mknod = reiserfs_mknod,
-	.rename = reiserfs_rename,
+	.rename2 = reiserfs_rename,
 	.setattr = reiserfs_setattr,
 	.setxattr = generic_setxattr,
 	.getxattr = generic_getxattr,
diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c
index a42de45ce40d..765d79de1217 100644
--- a/fs/sysv/namei.c
+++ b/fs/sysv/namei.c
@@ -206,7 +206,8 @@ static int sysv_rmdir(struct inode * dir, struct dentry * dentry)
  * higher-level routines.
  */
 static int sysv_rename(struct inode * old_dir, struct dentry * old_dentry,
-		  struct inode * new_dir, struct dentry * new_dentry)
+		       struct inode * new_dir, struct dentry * new_dentry,
+		       unsigned int flags)
 {
 	struct inode * old_inode = d_inode(old_dentry);
 	struct inode * new_inode = d_inode(new_dentry);
@@ -216,6 +217,9 @@ static int sysv_rename(struct inode * old_dir, struct dentry * old_dentry,
 	struct sysv_dir_entry * old_de;
 	int err = -ENOENT;
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	old_de = sysv_find_entry(old_dentry, &old_page);
 	if (!old_de)
 		goto out;
@@ -285,6 +289,6 @@ const struct inode_operations sysv_dir_inode_operations = {
 	.mkdir		= sysv_mkdir,
 	.rmdir		= sysv_rmdir,
 	.mknod		= sysv_mknod,
-	.rename		= sysv_rename,
+	.rename2	= sysv_rename,
 	.getattr	= sysv_getattr,
 };
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 4b86d3a738e1..23d1ebabc688 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -966,7 +966,8 @@ static void unlock_3_inodes(struct inode *inode1, struct inode *inode2,
 }
 
 static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
-			struct inode *new_dir, struct dentry *new_dentry)
+			struct inode *new_dir, struct dentry *new_dentry,
+			unsigned int flags)
 {
 	struct ubifs_info *c = old_dir->i_sb->s_fs_info;
 	struct inode *old_inode = d_inode(old_dentry);
@@ -984,6 +985,9 @@ static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	struct timespec time;
 	unsigned int uninitialized_var(saved_nlink);
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	/*
 	 * Budget request settings: deletion direntry, new direntry, removing
 	 * the old inode, and changing old and new parent directory inodes.
@@ -1179,7 +1183,7 @@ const struct inode_operations ubifs_dir_inode_operations = {
 	.mkdir       = ubifs_mkdir,
 	.rmdir       = ubifs_rmdir,
 	.mknod       = ubifs_mknod,
-	.rename      = ubifs_rename,
+	.rename2     = ubifs_rename,
 	.setattr     = ubifs_setattr,
 	.getattr     = ubifs_getattr,
 	.setxattr    = generic_setxattr,
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index c3e5c9679371..ca2ec0061802 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -1093,7 +1093,8 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
  * higher-level routines.
  */
 static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
-		      struct inode *new_dir, struct dentry *new_dentry)
+		      struct inode *new_dir, struct dentry *new_dentry,
+		      unsigned int flags)
 {
 	struct inode *old_inode = d_inode(old_dentry);
 	struct inode *new_inode = d_inode(new_dentry);
@@ -1105,6 +1106,9 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
 	struct kernel_lb_addr tloc;
 	struct udf_inode_info *old_iinfo = UDF_I(old_inode);
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	ofi = udf_find_entry(old_dir, &old_dentry->d_name, &ofibh, &ocfi);
 	if (IS_ERR(ofi)) {
 		retval = PTR_ERR(ofi);
@@ -1353,6 +1357,6 @@ const struct inode_operations udf_dir_inode_operations = {
 	.mkdir				= udf_mkdir,
 	.rmdir				= udf_rmdir,
 	.mknod				= udf_mknod,
-	.rename				= udf_rename,
+	.rename2			= udf_rename,
 	.tmpfile			= udf_tmpfile,
 };
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index a1559f762805..719c9c9b83d8 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -245,7 +245,8 @@ static int ufs_rmdir (struct inode * dir, struct dentry *dentry)
 }
 
 static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry,
-		      struct inode *new_dir, struct dentry *new_dentry)
+		      struct inode *new_dir, struct dentry *new_dentry,
+		      unsigned int flags)
 {
 	struct inode *old_inode = d_inode(old_dentry);
 	struct inode *new_inode = d_inode(new_dentry);
@@ -255,6 +256,9 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	struct ufs_dir_entry *old_de;
 	int err = -ENOENT;
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	old_de = ufs_find_entry(old_dir, &old_dentry->d_name, &old_page);
 	if (!old_de)
 		goto out;
@@ -333,5 +337,5 @@ const struct inode_operations ufs_dir_inode_operations = {
 	.mkdir		= ufs_mkdir,
 	.rmdir		= ufs_rmdir,
 	.mknod		= ufs_mknod,
-	.rename		= ufs_rename,
+	.rename2	= ufs_rename,
 };
-- 
2.5.5

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

* [PATCH 3/7] libfs: support RENAME_NOREPLACE in simple_rename()
  2016-08-23 14:05 [PATCH 0/7] vfs: finish rename -> rename2 conversion Miklos Szeredi
  2016-08-23 14:05 ` [PATCH 1/7] ncpfs: fix unused variable warning Miklos Szeredi
  2016-08-23 14:05 ` [PATCH 2/7] fs: support RENAME_NOREPLACE for local filesystems Miklos Szeredi
@ 2016-08-23 14:05 ` Miklos Szeredi
  2016-08-23 14:47   ` Greg Kroah-Hartman
  2016-08-23 14:05 ` [PATCH 4/7] fs: make remaining filesystems use .rename2 Miklos Szeredi
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Miklos Szeredi @ 2016-08-23 14:05 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: linux-kernel, Al Viro, Alexei Starovoitov, Greg Kroah-Hartman

This is trivial to do:

 - add flags argument to simple_rename()
 - check if flags doesn't have any other than RENAME_NOREPLACE
 - assign simple_rename() to .rename2 instead of .rename

Filesystems converted:

hugetlbfs, ramfs, bpf.

Debugfs uses simple_rename() to implement debugfs_rename(), which is for
debugfs instances to rename files internally, not for userspace filesystem
access.  For this case pass zero flags to simple_rename().

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/debugfs/inode.c   | 2 +-
 fs/hugetlbfs/inode.c | 2 +-
 fs/libfs.c           | 6 +++++-
 fs/ramfs/inode.c     | 2 +-
 include/linux/fs.h   | 3 ++-
 kernel/bpf/inode.c   | 2 +-
 6 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 72361baf9da7..5ac27c9de669 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -748,7 +748,7 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
 	old_name = fsnotify_oldname_init(old_dentry->d_name.name);
 
 	error = simple_rename(d_inode(old_dir), old_dentry, d_inode(new_dir),
-		dentry);
+			      dentry, 0);
 	if (error) {
 		fsnotify_oldname_free(old_name);
 		goto exit;
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 4ea71eba40a5..50cd7475a942 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -988,7 +988,7 @@ static const struct inode_operations hugetlbfs_dir_inode_operations = {
 	.mkdir		= hugetlbfs_mkdir,
 	.rmdir		= simple_rmdir,
 	.mknod		= hugetlbfs_mknod,
-	.rename		= simple_rename,
+	.rename2	= simple_rename,
 	.setattr	= hugetlbfs_setattr,
 };
 
diff --git a/fs/libfs.c b/fs/libfs.c
index 74dc8b9e7f53..4758353b2d41 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -349,11 +349,15 @@ int simple_rmdir(struct inode *dir, struct dentry *dentry)
 EXPORT_SYMBOL(simple_rmdir);
 
 int simple_rename(struct inode *old_dir, struct dentry *old_dentry,
-		struct inode *new_dir, struct dentry *new_dentry)
+		  struct inode *new_dir, struct dentry *new_dentry,
+		  unsigned int flags)
 {
 	struct inode *inode = d_inode(old_dentry);
 	int they_are_dirs = d_is_dir(old_dentry);
 
+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+
 	if (!simple_empty(new_dentry))
 		return -ENOTEMPTY;
 
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 1ab6e6c2e60e..c2aa068ff974 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -146,7 +146,7 @@ static const struct inode_operations ramfs_dir_inode_operations = {
 	.mkdir		= ramfs_mkdir,
 	.rmdir		= simple_rmdir,
 	.mknod		= ramfs_mknod,
-	.rename		= simple_rename,
+	.rename2	= simple_rename,
 };
 
 static const struct super_operations ramfs_ops = {
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 3523bf62f328..8aebcfc42f26 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2949,7 +2949,8 @@ extern int simple_open(struct inode *inode, struct file *file);
 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
 extern int simple_unlink(struct inode *, struct dentry *);
 extern int simple_rmdir(struct inode *, struct dentry *);
-extern int simple_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
+extern int simple_rename(struct inode *, struct dentry *,
+			 struct inode *, struct dentry *, unsigned int);
 extern int noop_fsync(struct file *, loff_t, loff_t, int);
 extern int simple_empty(struct dentry *);
 extern int simple_readpage(struct file *file, struct page *page);
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 5967b870a895..c92fd8936d33 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -189,7 +189,7 @@ static const struct inode_operations bpf_dir_iops = {
 	.mknod		= bpf_mkobj,
 	.mkdir		= bpf_mkdir,
 	.rmdir		= simple_rmdir,
-	.rename		= simple_rename,
+	.rename2	= simple_rename,
 	.link		= simple_link,
 	.unlink		= simple_unlink,
 };
-- 
2.5.5

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

* [PATCH 4/7] fs: make remaining filesystems use .rename2
  2016-08-23 14:05 [PATCH 0/7] vfs: finish rename -> rename2 conversion Miklos Szeredi
                   ` (2 preceding siblings ...)
  2016-08-23 14:05 ` [PATCH 3/7] libfs: support RENAME_NOREPLACE in simple_rename() Miklos Szeredi
@ 2016-08-23 14:05 ` Miklos Szeredi
  2016-08-23 14:47   ` Greg Kroah-Hartman
  2016-08-23 16:24   ` Boaz Harrosh
  2016-08-23 14:05 ` [PATCH 5/7] vfs: remove unused i_op->rename Miklos Szeredi
                   ` (3 subsequent siblings)
  7 siblings, 2 replies; 17+ messages in thread
From: Miklos Szeredi @ 2016-08-23 14:05 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: linux-kernel, Al Viro, Eric Van Hensbergen, David Howells,
	Ilya Dryomov, Jan Harkes, Tyler Hicks, Boaz Harrosh,
	Greg Kroah-Hartman, Oleg Drokin, Trond Myklebust, Mark Fasheh,
	Mike Marshall

This is trivial to do:

 - add flags argument to foo_rename()
 - check if flags is zero
 - assign foo_rename() to .rename2 instead of .rename

This doesn't mean it's impossible to support RENAME_NOREPLACE for these
filesystems, but it is not trivial, like for local filesystems.
RENAME_NOREPLACE must guarantee atomicity (i.e. it shouldn't be possible
for a file to be created on one host while it is overwritten by rename on
another host).

Filesystems converted:

9p, afs, ceph, coda, ecryptfs, exofs, kernfs, lustre, ncpfs, nfs, ocfs2,
orangefs.

After this, we can get rid of the duplicate interfaces for rename.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: Jan Harkes <jaharkes@cs.cmu.edu>
Cc: Tyler Hicks <tyhicks@canonical.com>
Cc: Boaz Harrosh <ooo@electrozaur.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Oleg Drokin <oleg.drokin@intel.com>
Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Mike Marshall <hubcap@omnibond.com>
---
 drivers/staging/lustre/lustre/llite/namei.c |  8 ++++++--
 fs/9p/v9fs.h                                |  3 ++-
 fs/9p/vfs_inode.c                           | 10 +++++++---
 fs/9p/vfs_inode_dotl.c                      |  2 +-
 fs/afs/dir.c                                | 11 ++++++++---
 fs/ceph/dir.c                               | 10 +++++++---
 fs/coda/dir.c                               |  8 ++++++--
 fs/ecryptfs/inode.c                         |  8 ++++++--
 fs/exofs/namei.c                            |  8 ++++++--
 fs/kernfs/dir.c                             |  8 ++++++--
 fs/ncpfs/dir.c                              | 10 +++++++---
 fs/nfs/dir.c                                |  6 +++++-
 fs/nfs/internal.h                           |  3 ++-
 fs/nfs/nfs3proc.c                           |  2 +-
 fs/nfs/nfs4proc.c                           |  2 +-
 fs/nfs/proc.c                               |  2 +-
 fs/ocfs2/namei.c                            |  8 ++++++--
 fs/orangefs/namei.c                         |  8 ++++++--
 18 files changed, 84 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index 3664bfd0178b..fd0beac14afd 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -1045,13 +1045,17 @@ out:
 }
 
 static int ll_rename(struct inode *src, struct dentry *src_dchild,
-		     struct inode *tgt, struct dentry *tgt_dchild)
+		     struct inode *tgt, struct dentry *tgt_dchild,
+		     unsigned int flags)
 {
 	struct ptlrpc_request *request = NULL;
 	struct ll_sb_info *sbi = ll_i2sbi(src);
 	struct md_op_data *op_data;
 	int err;
 
+	if (flags)
+		return -EINVAL;
+
 	CDEBUG(D_VFSTRACE,
 	       "VFS Op:oldname=%pd, src_dir="DFID"(%p), newname=%pd, tgt_dir="DFID"(%p)\n",
 	       src_dchild, PFID(ll_inode2fid(src)), src,
@@ -1097,7 +1101,7 @@ const struct inode_operations ll_dir_inode_operations = {
 	.rmdir	      = ll_rmdir,
 	.symlink	    = ll_symlink,
 	.link	       = ll_link,
-	.rename	     = ll_rename,
+	.rename2	= ll_rename,
 	.setattr	    = ll_setattr,
 	.getattr	    = ll_getattr,
 	.permission	 = ll_inode_permission,
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index 6877050384a1..443d12e02043 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -148,7 +148,8 @@ extern struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
 extern int v9fs_vfs_unlink(struct inode *i, struct dentry *d);
 extern int v9fs_vfs_rmdir(struct inode *i, struct dentry *d);
 extern int v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
-			struct inode *new_dir, struct dentry *new_dentry);
+			   struct inode *new_dir, struct dentry *new_dentry,
+			   unsigned int flags);
 extern struct inode *v9fs_inode_from_fid(struct v9fs_session_info *v9ses,
 					 struct p9_fid *fid,
 					 struct super_block *sb, int new);
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 8b1999b528e9..50ab1a615207 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -955,7 +955,8 @@ int v9fs_vfs_rmdir(struct inode *i, struct dentry *d)
 
 int
 v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
-		struct inode *new_dir, struct dentry *new_dentry)
+		struct inode *new_dir, struct dentry *new_dentry,
+		unsigned int flags)
 {
 	int retval;
 	struct inode *old_inode;
@@ -966,6 +967,9 @@ v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	struct p9_fid *newdirfid;
 	struct p9_wstat wstat;
 
+	if (flags)
+		return -EINVAL;
+
 	p9_debug(P9_DEBUG_VFS, "\n");
 	retval = 0;
 	old_inode = d_inode(old_dentry);
@@ -1436,7 +1440,7 @@ static const struct inode_operations v9fs_dir_inode_operations_dotu = {
 	.mkdir = v9fs_vfs_mkdir,
 	.rmdir = v9fs_vfs_rmdir,
 	.mknod = v9fs_vfs_mknod,
-	.rename = v9fs_vfs_rename,
+	.rename2 = v9fs_vfs_rename,
 	.getattr = v9fs_vfs_getattr,
 	.setattr = v9fs_vfs_setattr,
 };
@@ -1449,7 +1453,7 @@ static const struct inode_operations v9fs_dir_inode_operations = {
 	.mkdir = v9fs_vfs_mkdir,
 	.rmdir = v9fs_vfs_rmdir,
 	.mknod = v9fs_vfs_mknod,
-	.rename = v9fs_vfs_rename,
+	.rename2 = v9fs_vfs_rename,
 	.getattr = v9fs_vfs_getattr,
 	.setattr = v9fs_vfs_setattr,
 };
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index eeabcb0bad12..8164be972b5c 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -964,7 +964,7 @@ const struct inode_operations v9fs_dir_inode_operations_dotl = {
 	.mkdir = v9fs_vfs_mkdir_dotl,
 	.rmdir = v9fs_vfs_rmdir,
 	.mknod = v9fs_vfs_mknod_dotl,
-	.rename = v9fs_vfs_rename,
+	.rename2 = v9fs_vfs_rename,
 	.getattr = v9fs_vfs_getattr_dotl,
 	.setattr = v9fs_vfs_setattr_dotl,
 	.setxattr = generic_setxattr,
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index eba541004d90..381b7d0b6751 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -38,7 +38,8 @@ static int afs_link(struct dentry *from, struct inode *dir,
 static int afs_symlink(struct inode *dir, struct dentry *dentry,
 		       const char *content);
 static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
-		      struct inode *new_dir, struct dentry *new_dentry);
+		      struct inode *new_dir, struct dentry *new_dentry,
+		      unsigned int flags);
 
 const struct file_operations afs_dir_file_operations = {
 	.open		= afs_dir_open,
@@ -56,7 +57,7 @@ const struct inode_operations afs_dir_inode_operations = {
 	.symlink	= afs_symlink,
 	.mkdir		= afs_mkdir,
 	.rmdir		= afs_rmdir,
-	.rename		= afs_rename,
+	.rename2	= afs_rename,
 	.permission	= afs_permission,
 	.getattr	= afs_getattr,
 	.setattr	= afs_setattr,
@@ -1083,12 +1084,16 @@ error:
  * rename a file in an AFS filesystem and/or move it between directories
  */
 static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
-		      struct inode *new_dir, struct dentry *new_dentry)
+		      struct inode *new_dir, struct dentry *new_dentry,
+		      unsigned int flags)
 {
 	struct afs_vnode *orig_dvnode, *new_dvnode, *vnode;
 	struct key *key;
 	int ret;
 
+	if (flags)
+		return -EINVAL;
+
 	vnode = AFS_FS_I(d_inode(old_dentry));
 	orig_dvnode = AFS_FS_I(old_dir);
 	new_dvnode = AFS_FS_I(new_dir);
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index c64a0b794d49..3fbeeb8bae69 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1061,7 +1061,8 @@ out:
 }
 
 static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry,
-		       struct inode *new_dir, struct dentry *new_dentry)
+		       struct inode *new_dir, struct dentry *new_dentry,
+		       unsigned int flags)
 {
 	struct ceph_fs_client *fsc = ceph_sb_to_client(old_dir->i_sb);
 	struct ceph_mds_client *mdsc = fsc->mdsc;
@@ -1069,6 +1070,9 @@ static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry,
 	int op = CEPH_MDS_OP_RENAME;
 	int err;
 
+	if (flags)
+		return -EINVAL;
+
 	if (ceph_snap(old_dir) != ceph_snap(new_dir))
 		return -EXDEV;
 	if (ceph_snap(old_dir) != CEPH_NOSNAP) {
@@ -1498,7 +1502,7 @@ const struct inode_operations ceph_dir_iops = {
 	.link = ceph_link,
 	.unlink = ceph_unlink,
 	.rmdir = ceph_unlink,
-	.rename = ceph_rename,
+	.rename2 = ceph_rename,
 	.create = ceph_create,
 	.atomic_open = ceph_atomic_open,
 };
@@ -1509,7 +1513,7 @@ const struct inode_operations ceph_snapdir_iops = {
 	.getattr = ceph_getattr,
 	.mkdir = ceph_mkdir,
 	.rmdir = ceph_unlink,
-	.rename = ceph_rename,
+	.rename2 = ceph_rename,
 };
 
 const struct dentry_operations ceph_dentry_ops = {
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 6fb8672c0892..5d79c26b0484 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -291,7 +291,8 @@ static int coda_rmdir(struct inode *dir, struct dentry *de)
 
 /* rename */
 static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
-		       struct inode *new_dir, struct dentry *new_dentry)
+		       struct inode *new_dir, struct dentry *new_dentry,
+		       unsigned int flags)
 {
 	const char *old_name = old_dentry->d_name.name;
 	const char *new_name = new_dentry->d_name.name;
@@ -299,6 +300,9 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
 	int new_length = new_dentry->d_name.len;
 	int error;
 
+	if (flags)
+		return -EINVAL;
+
 	error = venus_rename(old_dir->i_sb, coda_i2f(old_dir),
 			     coda_i2f(new_dir), old_length, new_length,
 			     (const char *) old_name, (const char *)new_name);
@@ -569,7 +573,7 @@ const struct inode_operations coda_dir_inode_operations = {
 	.mkdir		= coda_mkdir,
 	.rmdir		= coda_rmdir,
 	.mknod		= CODA_EIO_ERROR,
-	.rename		= coda_rename,
+	.rename2	= coda_rename,
 	.permission	= coda_permission,
 	.getattr	= coda_getattr,
 	.setattr	= coda_setattr,
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 9d153b6a1d72..f3ff7c4d384c 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -577,7 +577,8 @@ out:
 
 static int
 ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
-		struct inode *new_dir, struct dentry *new_dentry)
+		struct inode *new_dir, struct dentry *new_dentry,
+		unsigned int flags)
 {
 	int rc;
 	struct dentry *lower_old_dentry;
@@ -587,6 +588,9 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	struct dentry *trap = NULL;
 	struct inode *target_inode;
 
+	if (flags)
+		return -EINVAL;
+
 	lower_old_dentry = ecryptfs_dentry_to_lower(old_dentry);
 	lower_new_dentry = ecryptfs_dentry_to_lower(new_dentry);
 	dget(lower_old_dentry);
@@ -1104,7 +1108,7 @@ const struct inode_operations ecryptfs_dir_iops = {
 	.mkdir = ecryptfs_mkdir,
 	.rmdir = ecryptfs_rmdir,
 	.mknod = ecryptfs_mknod,
-	.rename = ecryptfs_rename,
+	.rename2 = ecryptfs_rename,
 	.permission = ecryptfs_permission,
 	.setattr = ecryptfs_setattr,
 	.setxattr = ecryptfs_setxattr,
diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c
index 622a686bb08b..897280163f3c 100644
--- a/fs/exofs/namei.c
+++ b/fs/exofs/namei.c
@@ -227,7 +227,8 @@ static int exofs_rmdir(struct inode *dir, struct dentry *dentry)
 }
 
 static int exofs_rename(struct inode *old_dir, struct dentry *old_dentry,
-		struct inode *new_dir, struct dentry *new_dentry)
+			struct inode *new_dir, struct dentry *new_dentry,
+			unsigned int flags)
 {
 	struct inode *old_inode = d_inode(old_dentry);
 	struct inode *new_inode = d_inode(new_dentry);
@@ -237,6 +238,9 @@ static int exofs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	struct exofs_dir_entry *old_de;
 	int err = -ENOENT;
 
+	if (flags)
+		return -EINVAL;
+
 	old_de = exofs_find_entry(old_dir, old_dentry, &old_page);
 	if (!old_de)
 		goto out;
@@ -310,7 +314,7 @@ const struct inode_operations exofs_dir_inode_operations = {
 	.mkdir  	= exofs_mkdir,
 	.rmdir  	= exofs_rmdir,
 	.mknod  	= exofs_mknod,
-	.rename 	= exofs_rename,
+	.rename2	= exofs_rename,
 	.setattr	= exofs_setattr,
 };
 
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index e57174d43683..c7e23ca945ab 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -1096,13 +1096,17 @@ static int kernfs_iop_rmdir(struct inode *dir, struct dentry *dentry)
 }
 
 static int kernfs_iop_rename(struct inode *old_dir, struct dentry *old_dentry,
-			     struct inode *new_dir, struct dentry *new_dentry)
+			     struct inode *new_dir, struct dentry *new_dentry,
+			     unsigned int flags)
 {
 	struct kernfs_node *kn  = old_dentry->d_fsdata;
 	struct kernfs_node *new_parent = new_dir->i_private;
 	struct kernfs_syscall_ops *scops = kernfs_root(kn)->syscall_ops;
 	int ret;
 
+	if (flags)
+		return -EINVAL;
+
 	if (!scops || !scops->rename)
 		return -EPERM;
 
@@ -1133,7 +1137,7 @@ const struct inode_operations kernfs_dir_iops = {
 
 	.mkdir		= kernfs_iop_mkdir,
 	.rmdir		= kernfs_iop_rmdir,
-	.rename		= kernfs_iop_rename,
+	.rename2	= kernfs_iop_rename,
 };
 
 static struct kernfs_node *kernfs_leftmost_descendant(struct kernfs_node *pos)
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index f5b594e2457c..a2d3738df4af 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -36,7 +36,7 @@ static int ncp_unlink(struct inode *, struct dentry *);
 static int ncp_mkdir(struct inode *, struct dentry *, umode_t);
 static int ncp_rmdir(struct inode *, struct dentry *);
 static int ncp_rename(struct inode *, struct dentry *,
-	  	      struct inode *, struct dentry *);
+		      struct inode *, struct dentry *, unsigned int);
 static int ncp_mknod(struct inode * dir, struct dentry *dentry,
 		     umode_t mode, dev_t rdev);
 #if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS)
@@ -65,7 +65,7 @@ const struct inode_operations ncp_dir_inode_operations =
 	.mkdir		= ncp_mkdir,
 	.rmdir		= ncp_rmdir,
 	.mknod		= ncp_mknod,
-	.rename		= ncp_rename,
+	.rename2	= ncp_rename,
 	.setattr	= ncp_notify_change,
 };
 
@@ -1105,13 +1105,17 @@ static int ncp_unlink(struct inode *dir, struct dentry *dentry)
 }
 
 static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry,
-		      struct inode *new_dir, struct dentry *new_dentry)
+		      struct inode *new_dir, struct dentry *new_dentry,
+		      unsigned int flags)
 {
 	struct ncp_server *server = NCP_SERVER(old_dir);
 	int error;
 	int old_len, new_len;
 	__u8 __old_name[NCP_MAXPATHLEN + 1], __new_name[NCP_MAXPATHLEN + 1];
 
+	if (flags)
+		return -EINVAL;
+
 	ncp_dbg(1, "%pd2 to %pd2\n", old_dentry, new_dentry);
 
 	ncp_age_dentry(server, old_dentry);
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 177fefb26c18..06e0bf092ba9 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2013,7 +2013,8 @@ EXPORT_SYMBOL_GPL(nfs_link);
  * the rename.
  */
 int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
-		      struct inode *new_dir, struct dentry *new_dentry)
+	       struct inode *new_dir, struct dentry *new_dentry,
+	       unsigned int flags)
 {
 	struct inode *old_inode = d_inode(old_dentry);
 	struct inode *new_inode = d_inode(new_dentry);
@@ -2021,6 +2022,9 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	struct rpc_task *task;
 	int error = -EBUSY;
 
+	if (flags)
+		return -EINVAL;
+
 	dfprintk(VFS, "NFS: rename(%pd2 -> %pd2, ct=%d)\n",
 		 old_dentry, new_dentry,
 		 d_count(new_dentry));
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 7ce5e023c3c3..330ba1b6a794 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -356,7 +356,8 @@ int nfs_unlink(struct inode *, struct dentry *);
 int nfs_symlink(struct inode *, struct dentry *, const char *);
 int nfs_link(struct dentry *, struct inode *, struct dentry *);
 int nfs_mknod(struct inode *, struct dentry *, umode_t, dev_t);
-int nfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
+int nfs_rename(struct inode *, struct dentry *,
+	       struct inode *, struct dentry *, unsigned int);
 
 /* file.c */
 int nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync);
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index 698be9361280..a85fdae4a51f 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -893,7 +893,7 @@ static const struct inode_operations nfs3_dir_inode_operations = {
 	.mkdir		= nfs_mkdir,
 	.rmdir		= nfs_rmdir,
 	.mknod		= nfs_mknod,
-	.rename		= nfs_rename,
+	.rename2	= nfs_rename,
 	.permission	= nfs_permission,
 	.getattr	= nfs_getattr,
 	.setattr	= nfs_setattr,
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 1949bbd806eb..7c217fd22214 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -8867,7 +8867,7 @@ static const struct inode_operations nfs4_dir_inode_operations = {
 	.mkdir		= nfs_mkdir,
 	.rmdir		= nfs_rmdir,
 	.mknod		= nfs_mknod,
-	.rename		= nfs_rename,
+	.rename2	= nfs_rename,
 	.permission	= nfs_permission,
 	.getattr	= nfs_getattr,
 	.setattr	= nfs_setattr,
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index b7bca8303989..380d0b787983 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -685,7 +685,7 @@ static const struct inode_operations nfs_dir_inode_operations = {
 	.mkdir		= nfs_mkdir,
 	.rmdir		= nfs_rmdir,
 	.mknod		= nfs_mknod,
-	.rename		= nfs_rename,
+	.rename2	= nfs_rename,
 	.permission	= nfs_permission,
 	.getattr	= nfs_getattr,
 	.setattr	= nfs_setattr,
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index a8f1225e6d9b..1040c10a9493 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1203,7 +1203,8 @@ static void ocfs2_double_unlock(struct inode *inode1, struct inode *inode2)
 static int ocfs2_rename(struct inode *old_dir,
 			struct dentry *old_dentry,
 			struct inode *new_dir,
-			struct dentry *new_dentry)
+			struct dentry *new_dentry,
+			unsigned int flags)
 {
 	int status = 0, rename_lock = 0, parents_locked = 0, target_exists = 0;
 	int old_child_locked = 0, new_child_locked = 0, update_dot_dot = 0;
@@ -1228,6 +1229,9 @@ static int ocfs2_rename(struct inode *old_dir,
 	struct ocfs2_dir_lookup_result target_insert = { NULL, };
 	bool should_add_orphan = false;
 
+	if (flags)
+		return -EINVAL;
+
 	/* At some point it might be nice to break this function up a
 	 * bit. */
 
@@ -2909,7 +2913,7 @@ const struct inode_operations ocfs2_dir_iops = {
 	.symlink	= ocfs2_symlink,
 	.mkdir		= ocfs2_mkdir,
 	.mknod		= ocfs2_mknod,
-	.rename		= ocfs2_rename,
+	.rename2	= ocfs2_rename,
 	.setattr	= ocfs2_setattr,
 	.getattr	= ocfs2_getattr,
 	.permission	= ocfs2_permission,
diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
index 62c525936ee8..810d43635dfb 100644
--- a/fs/orangefs/namei.c
+++ b/fs/orangefs/namei.c
@@ -409,11 +409,15 @@ out:
 static int orangefs_rename(struct inode *old_dir,
 			struct dentry *old_dentry,
 			struct inode *new_dir,
-			struct dentry *new_dentry)
+			struct dentry *new_dentry,
+			unsigned int flags)
 {
 	struct orangefs_kernel_op_s *new_op;
 	int ret;
 
+	if (flags)
+		return -EINVAL;
+
 	gossip_debug(GOSSIP_NAME_DEBUG,
 		     "orangefs_rename: called (%pd2 => %pd2) ct=%d\n",
 		     old_dentry, new_dentry, d_count(new_dentry));
@@ -459,7 +463,7 @@ const struct inode_operations orangefs_dir_inode_operations = {
 	.symlink = orangefs_symlink,
 	.mkdir = orangefs_mkdir,
 	.rmdir = orangefs_unlink,
-	.rename = orangefs_rename,
+	.rename2 = orangefs_rename,
 	.setattr = orangefs_setattr,
 	.getattr = orangefs_getattr,
 	.setxattr = generic_setxattr,
-- 
2.5.5

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

* [PATCH 5/7] vfs: remove unused i_op->rename
  2016-08-23 14:05 [PATCH 0/7] vfs: finish rename -> rename2 conversion Miklos Szeredi
                   ` (3 preceding siblings ...)
  2016-08-23 14:05 ` [PATCH 4/7] fs: make remaining filesystems use .rename2 Miklos Szeredi
@ 2016-08-23 14:05 ` Miklos Szeredi
  2016-08-23 14:05 ` [PATCH 6/7] fs: rename "rename2" i_op to "rename" Miklos Szeredi
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Miklos Szeredi @ 2016-08-23 14:05 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, Al Viro

No in-tree uses remain.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
 Documentation/filesystems/Locking           |  6 +-----
 Documentation/filesystems/directory-locking |  2 +-
 Documentation/filesystems/vfs.txt           |  9 ++-------
 fs/cachefiles/namei.c                       |  3 +--
 fs/namei.c                                  | 15 +++------------
 include/linux/fs.h                          |  2 --
 security/tomoyo/realpath.c                  |  4 ++--
 7 files changed, 10 insertions(+), 31 deletions(-)

diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index d30fb2cb5066..da320bc08b9e 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -50,8 +50,6 @@ prototypes:
 	int (*mkdir) (struct inode *,struct dentry *,umode_t);
 	int (*rmdir) (struct inode *,struct dentry *);
 	int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t);
-	int (*rename) (struct inode *, struct dentry *,
-			struct inode *, struct dentry *);
 	int (*rename2) (struct inode *, struct dentry *,
 			struct inode *, struct dentry *, unsigned int);
 	int (*readlink) (struct dentry *, char __user *,int);
@@ -83,7 +81,6 @@ symlink:	yes
 mkdir:		yes
 unlink:		yes (both)
 rmdir:		yes (both)	(see below)
-rename:		yes (all)	(see below)
 rename2:	yes (all)	(see below)
 readlink:	no
 get_link:	no
@@ -102,8 +99,7 @@ tmpfile:	no
 
 	Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on
 victim.
-	cross-directory ->rename() and rename2() has (per-superblock)
-->s_vfs_rename_sem.
+	cross-directory ->rename2() has (per-superblock) ->s_vfs_rename_sem.
 
 See Documentation/filesystems/directory-locking for more detailed discussion
 of the locking scheme for directory operations.
diff --git a/Documentation/filesystems/directory-locking b/Documentation/filesystems/directory-locking
index c314badbcfc6..4e32cb961e5b 100644
--- a/Documentation/filesystems/directory-locking
+++ b/Documentation/filesystems/directory-locking
@@ -19,7 +19,7 @@ locks victim and calls the method.  Locks are exclusive.
 
 4) rename() that is _not_ cross-directory.  Locking rules: caller locks
 the parent and finds source and target.  In case of exchange (with
-RENAME_EXCHANGE in rename2() flags argument) lock both.  In any case,
+RENAME_EXCHANGE in flags argument) lock both.  In any case,
 if the target already exists, lock it.  If the source is a non-directory,
 lock it.  If we need to lock both, lock them in inode pointer order.
 Then call the method.  All locks are exclusive.
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index 9ace359d6cc5..c641e0c37a07 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -345,8 +345,6 @@ struct inode_operations {
 	int (*mkdir) (struct inode *,struct dentry *,umode_t);
 	int (*rmdir) (struct inode *,struct dentry *);
 	int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t);
-	int (*rename) (struct inode *, struct dentry *,
-			struct inode *, struct dentry *);
 	int (*rename2) (struct inode *, struct dentry *,
 			struct inode *, struct dentry *, unsigned int);
 	int (*readlink) (struct dentry *, char __user *,int);
@@ -416,11 +414,8 @@ otherwise noted.
   rename: called by the rename(2) system call to rename the object to
 	have the parent and name given by the second inode and dentry.
 
-  rename2: this has an additional flags argument compared to rename.
-	If no flags are supported by the filesystem then this method
-	need not be implemented.  If some flags are supported then the
-	filesystem must return -EINVAL for any unsupported or unknown
-	flags.  Currently the following flags are implemented:
+	The filesystem must return -EINVAL for any unsupported or
+	unknown	flags.  Currently the following flags are implemented:
 	(1) RENAME_NOREPLACE: this flag indicates that if the target
 	of the rename exists the rename should fail with -EEXIST
 	instead of replacing the target.  The VFS already checks for
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index 3f7c2cd41f8f..02e1507812de 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -804,8 +804,7 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
 	    !d_backing_inode(subdir)->i_op->lookup ||
 	    !d_backing_inode(subdir)->i_op->mkdir ||
 	    !d_backing_inode(subdir)->i_op->create ||
-	    (!d_backing_inode(subdir)->i_op->rename &&
-	     !d_backing_inode(subdir)->i_op->rename2) ||
+	    !d_backing_inode(subdir)->i_op->rename2 ||
 	    !d_backing_inode(subdir)->i_op->rmdir ||
 	    !d_backing_inode(subdir)->i_op->unlink)
 		goto check_error;
diff --git a/fs/namei.c b/fs/namei.c
index adb04146df09..02803bd6cbad 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4369,12 +4369,9 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	if (error)
 		return error;
 
-	if (!old_dir->i_op->rename && !old_dir->i_op->rename2)
+	if (!old_dir->i_op->rename2)
 		return -EPERM;
 
-	if (flags && !old_dir->i_op->rename2)
-		return -EINVAL;
-
 	/*
 	 * If we are going to change the parent - check write permissions,
 	 * we'll need to flip '..'.
@@ -4428,14 +4425,8 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 		if (error)
 			goto out;
 	}
-	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);
-	}
+	error = old_dir->i_op->rename2(old_dir, old_dentry,
+				       new_dir, new_dentry, flags);
 	if (error)
 		goto out;
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 8aebcfc42f26..5a69b2e357a5 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1731,8 +1731,6 @@ struct inode_operations {
 	int (*mkdir) (struct inode *,struct dentry *,umode_t);
 	int (*rmdir) (struct inode *,struct dentry *);
 	int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t);
-	int (*rename) (struct inode *, struct dentry *,
-			struct inode *, struct dentry *);
 	int (*rename2) (struct inode *, struct dentry *,
 			struct inode *, struct dentry *, unsigned int);
 	int (*setattr) (struct dentry *, struct iattr *);
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c
index 5077f1968841..38bcdbc06bb2 100644
--- a/security/tomoyo/realpath.c
+++ b/security/tomoyo/realpath.c
@@ -173,7 +173,7 @@ static char *tomoyo_get_local_path(struct dentry *dentry, char * const buffer,
 		 * Use filesystem name if filesystem does not support rename()
 		 * operation.
 		 */
-		if (!inode->i_op->rename && !inode->i_op->rename2)
+		if (!inode->i_op->rename2)
 			goto prepend_filesystem_name;
 	}
 	/* Prepend device name. */
@@ -283,7 +283,7 @@ char *tomoyo_realpath_from_path(const struct path *path)
 		 * or dentry without vfsmount.
 		 */
 		if (!path->mnt ||
-		    (!inode->i_op->rename && !inode->i_op->rename2))
+		    (!inode->i_op->rename2))
 			pos = tomoyo_get_local_path(path->dentry, buf,
 						    buf_len - 1);
 		/* Get absolute name for the rest. */
-- 
2.5.5

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

* [PATCH 6/7] fs: rename "rename2" i_op to "rename"
  2016-08-23 14:05 [PATCH 0/7] vfs: finish rename -> rename2 conversion Miklos Szeredi
                   ` (4 preceding siblings ...)
  2016-08-23 14:05 ` [PATCH 5/7] vfs: remove unused i_op->rename Miklos Szeredi
@ 2016-08-23 14:05 ` Miklos Szeredi
  2016-08-23 14:05 ` [PATCH 7/7] vfs: add note about i_op->rename changes to porting Miklos Szeredi
  2016-08-23 15:36 ` [PATCH 4/7] fs: make remaining filesystems use .rename2 David Howells
  7 siblings, 0 replies; 17+ messages in thread
From: Miklos Szeredi @ 2016-08-23 14:05 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, Al Viro

Generated patch:

sed -i "s/\.rename2\t/\.rename\t\t/" `git grep -wl rename2`
sed -i "s/\brename2\b/rename/g" `git grep -wl rename2`

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
 Documentation/filesystems/Locking           | 6 +++---
 Documentation/filesystems/vfs.txt           | 2 +-
 drivers/staging/lustre/lustre/llite/namei.c | 2 +-
 fs/9p/vfs_inode.c                           | 4 ++--
 fs/9p/vfs_inode_dotl.c                      | 2 +-
 fs/affs/dir.c                               | 2 +-
 fs/afs/dir.c                                | 2 +-
 fs/bad_inode.c                              | 2 +-
 fs/bfs/dir.c                                | 2 +-
 fs/btrfs/inode.c                            | 2 +-
 fs/cachefiles/namei.c                       | 2 +-
 fs/ceph/dir.c                               | 4 ++--
 fs/cifs/cifsfs.c                            | 2 +-
 fs/coda/dir.c                               | 2 +-
 fs/ecryptfs/inode.c                         | 2 +-
 fs/exofs/namei.c                            | 2 +-
 fs/ext2/namei.c                             | 2 +-
 fs/ext4/namei.c                             | 2 +-
 fs/f2fs/namei.c                             | 2 +-
 fs/fat/namei_msdos.c                        | 2 +-
 fs/fat/namei_vfat.c                         | 2 +-
 fs/fuse/dir.c                               | 2 +-
 fs/gfs2/inode.c                             | 2 +-
 fs/hfs/dir.c                                | 2 +-
 fs/hfsplus/dir.c                            | 2 +-
 fs/hostfs/hostfs_kern.c                     | 2 +-
 fs/hpfs/namei.c                             | 2 +-
 fs/hugetlbfs/inode.c                        | 2 +-
 fs/jffs2/dir.c                              | 2 +-
 fs/jfs/namei.c                              | 2 +-
 fs/kernfs/dir.c                             | 2 +-
 fs/logfs/dir.c                              | 2 +-
 fs/minix/namei.c                            | 2 +-
 fs/namei.c                                  | 4 ++--
 fs/ncpfs/dir.c                              | 2 +-
 fs/nfs/nfs3proc.c                           | 2 +-
 fs/nfs/nfs4proc.c                           | 2 +-
 fs/nfs/proc.c                               | 2 +-
 fs/nilfs2/namei.c                           | 2 +-
 fs/ocfs2/namei.c                            | 2 +-
 fs/omfs/dir.c                               | 2 +-
 fs/orangefs/namei.c                         | 2 +-
 fs/overlayfs/dir.c                          | 2 +-
 fs/overlayfs/overlayfs.h                    | 4 ++--
 fs/ramfs/inode.c                            | 2 +-
 fs/reiserfs/namei.c                         | 2 +-
 fs/sysv/namei.c                             | 2 +-
 fs/ubifs/dir.c                              | 2 +-
 fs/udf/namei.c                              | 2 +-
 fs/ufs/namei.c                              | 2 +-
 fs/xfs/xfs_iops.c                           | 4 ++--
 include/linux/fs.h                          | 2 +-
 kernel/bpf/inode.c                          | 2 +-
 mm/shmem.c                                  | 2 +-
 security/tomoyo/realpath.c                  | 4 ++--
 55 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index da320bc08b9e..fe15682e8acd 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -50,7 +50,7 @@ prototypes:
 	int (*mkdir) (struct inode *,struct dentry *,umode_t);
 	int (*rmdir) (struct inode *,struct dentry *);
 	int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t);
-	int (*rename2) (struct inode *, struct dentry *,
+	int (*rename) (struct inode *, struct dentry *,
 			struct inode *, struct dentry *, unsigned int);
 	int (*readlink) (struct dentry *, char __user *,int);
 	const char *(*get_link) (struct dentry *, struct inode *, void **);
@@ -81,7 +81,7 @@ symlink:	yes
 mkdir:		yes
 unlink:		yes (both)
 rmdir:		yes (both)	(see below)
-rename2:	yes (all)	(see below)
+rename:	yes (all)	(see below)
 readlink:	no
 get_link:	no
 setattr:	yes
@@ -99,7 +99,7 @@ tmpfile:	no
 
 	Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on
 victim.
-	cross-directory ->rename2() has (per-superblock) ->s_vfs_rename_sem.
+	cross-directory ->rename() has (per-superblock) ->s_vfs_rename_sem.
 
 See Documentation/filesystems/directory-locking for more detailed discussion
 of the locking scheme for directory operations.
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index c641e0c37a07..b6bfa0bc02f8 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -345,7 +345,7 @@ struct inode_operations {
 	int (*mkdir) (struct inode *,struct dentry *,umode_t);
 	int (*rmdir) (struct inode *,struct dentry *);
 	int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t);
-	int (*rename2) (struct inode *, struct dentry *,
+	int (*rename) (struct inode *, struct dentry *,
 			struct inode *, struct dentry *, unsigned int);
 	int (*readlink) (struct dentry *, char __user *,int);
 	const char *(*get_link) (struct dentry *, struct inode *,
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index fd0beac14afd..3eaaa87b5bf5 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -1101,7 +1101,7 @@ const struct inode_operations ll_dir_inode_operations = {
 	.rmdir	      = ll_rmdir,
 	.symlink	    = ll_symlink,
 	.link	       = ll_link,
-	.rename2	= ll_rename,
+	.rename		= ll_rename,
 	.setattr	    = ll_setattr,
 	.getattr	    = ll_getattr,
 	.permission	 = ll_inode_permission,
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 50ab1a615207..0ad3c6c712b8 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -1440,7 +1440,7 @@ static const struct inode_operations v9fs_dir_inode_operations_dotu = {
 	.mkdir = v9fs_vfs_mkdir,
 	.rmdir = v9fs_vfs_rmdir,
 	.mknod = v9fs_vfs_mknod,
-	.rename2 = v9fs_vfs_rename,
+	.rename = v9fs_vfs_rename,
 	.getattr = v9fs_vfs_getattr,
 	.setattr = v9fs_vfs_setattr,
 };
@@ -1453,7 +1453,7 @@ static const struct inode_operations v9fs_dir_inode_operations = {
 	.mkdir = v9fs_vfs_mkdir,
 	.rmdir = v9fs_vfs_rmdir,
 	.mknod = v9fs_vfs_mknod,
-	.rename2 = v9fs_vfs_rename,
+	.rename = v9fs_vfs_rename,
 	.getattr = v9fs_vfs_getattr,
 	.setattr = v9fs_vfs_setattr,
 };
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 8164be972b5c..eeabcb0bad12 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -964,7 +964,7 @@ const struct inode_operations v9fs_dir_inode_operations_dotl = {
 	.mkdir = v9fs_vfs_mkdir_dotl,
 	.rmdir = v9fs_vfs_rmdir,
 	.mknod = v9fs_vfs_mknod_dotl,
-	.rename2 = v9fs_vfs_rename,
+	.rename = v9fs_vfs_rename,
 	.getattr = v9fs_vfs_getattr_dotl,
 	.setattr = v9fs_vfs_setattr_dotl,
 	.setxattr = generic_setxattr,
diff --git a/fs/affs/dir.c b/fs/affs/dir.c
index 8f127c239472..f1e7294381c5 100644
--- a/fs/affs/dir.c
+++ b/fs/affs/dir.c
@@ -35,7 +35,7 @@ const struct inode_operations affs_dir_inode_operations = {
 	.symlink	= affs_symlink,
 	.mkdir		= affs_mkdir,
 	.rmdir		= affs_rmdir,
-	.rename2	= affs_rename,
+	.rename		= affs_rename,
 	.setattr	= affs_notify_change,
 };
 
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 381b7d0b6751..51a241e09fbb 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -57,7 +57,7 @@ const struct inode_operations afs_dir_inode_operations = {
 	.symlink	= afs_symlink,
 	.mkdir		= afs_mkdir,
 	.rmdir		= afs_rmdir,
-	.rename2	= afs_rename,
+	.rename		= afs_rename,
 	.permission	= afs_permission,
 	.getattr	= afs_getattr,
 	.setattr	= afs_setattr,
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 3ba385eaa26e..536d2a387267 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -133,7 +133,7 @@ static const struct inode_operations bad_inode_ops =
 	.mkdir		= bad_inode_mkdir,
 	.rmdir		= bad_inode_rmdir,
 	.mknod		= bad_inode_mknod,
-	.rename2	= bad_inode_rename2,
+	.rename		= bad_inode_rename2,
 	.readlink	= bad_inode_readlink,
 	/* follow_link must be no-op, otherwise unmounting this inode
 	   won't work */
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index 9d5f875e85d0..5e3369f7cd9d 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -274,7 +274,7 @@ const struct inode_operations bfs_dir_inops = {
 	.lookup			= bfs_lookup,
 	.link			= bfs_link,
 	.unlink			= bfs_unlink,
-	.rename2		= bfs_rename,
+	.rename			= bfs_rename,
 };
 
 static int bfs_add_entry(struct inode *dir, const unsigned char *name,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 08dfc57e2270..e9b83efbb793 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -10549,7 +10549,7 @@ static const struct inode_operations btrfs_dir_inode_operations = {
 	.link		= btrfs_link,
 	.mkdir		= btrfs_mkdir,
 	.rmdir		= btrfs_rmdir,
-	.rename2	= btrfs_rename2,
+	.rename		= btrfs_rename2,
 	.symlink	= btrfs_symlink,
 	.setattr	= btrfs_setattr,
 	.mknod		= btrfs_mknod,
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index 02e1507812de..9828850d88de 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -804,7 +804,7 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
 	    !d_backing_inode(subdir)->i_op->lookup ||
 	    !d_backing_inode(subdir)->i_op->mkdir ||
 	    !d_backing_inode(subdir)->i_op->create ||
-	    !d_backing_inode(subdir)->i_op->rename2 ||
+	    !d_backing_inode(subdir)->i_op->rename ||
 	    !d_backing_inode(subdir)->i_op->rmdir ||
 	    !d_backing_inode(subdir)->i_op->unlink)
 		goto check_error;
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 3fbeeb8bae69..3ce77402f8b1 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1502,7 +1502,7 @@ const struct inode_operations ceph_dir_iops = {
 	.link = ceph_link,
 	.unlink = ceph_unlink,
 	.rmdir = ceph_unlink,
-	.rename2 = ceph_rename,
+	.rename = ceph_rename,
 	.create = ceph_create,
 	.atomic_open = ceph_atomic_open,
 };
@@ -1513,7 +1513,7 @@ const struct inode_operations ceph_snapdir_iops = {
 	.getattr = ceph_getattr,
 	.mkdir = ceph_mkdir,
 	.rmdir = ceph_unlink,
-	.rename2 = ceph_rename,
+	.rename = ceph_rename,
 };
 
 const struct dentry_operations ceph_dentry_ops = {
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 6bbec5e784cd..95cc33bcb90f 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -901,7 +901,7 @@ const struct inode_operations cifs_dir_inode_ops = {
 	.link = cifs_hardlink,
 	.mkdir = cifs_mkdir,
 	.rmdir = cifs_rmdir,
-	.rename2 = cifs_rename2,
+	.rename = cifs_rename2,
 	.permission = cifs_permission,
 	.setattr = cifs_setattr,
 	.symlink = cifs_symlink,
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 5d79c26b0484..82aceaef8e4e 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -573,7 +573,7 @@ const struct inode_operations coda_dir_inode_operations = {
 	.mkdir		= coda_mkdir,
 	.rmdir		= coda_rmdir,
 	.mknod		= CODA_EIO_ERROR,
-	.rename2	= coda_rename,
+	.rename		= coda_rename,
 	.permission	= coda_permission,
 	.getattr	= coda_getattr,
 	.setattr	= coda_setattr,
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index f3ff7c4d384c..fe83c1050048 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -1108,7 +1108,7 @@ const struct inode_operations ecryptfs_dir_iops = {
 	.mkdir = ecryptfs_mkdir,
 	.rmdir = ecryptfs_rmdir,
 	.mknod = ecryptfs_mknod,
-	.rename2 = ecryptfs_rename,
+	.rename = ecryptfs_rename,
 	.permission = ecryptfs_permission,
 	.setattr = ecryptfs_setattr,
 	.setxattr = ecryptfs_setxattr,
diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c
index 897280163f3c..3a6017cbfca9 100644
--- a/fs/exofs/namei.c
+++ b/fs/exofs/namei.c
@@ -314,7 +314,7 @@ const struct inode_operations exofs_dir_inode_operations = {
 	.mkdir  	= exofs_mkdir,
 	.rmdir  	= exofs_rmdir,
 	.mknod  	= exofs_mknod,
-	.rename2	= exofs_rename,
+	.rename		= exofs_rename,
 	.setattr	= exofs_setattr,
 };
 
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index 38fac85ff786..be32e20a2b88 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -430,7 +430,7 @@ const struct inode_operations ext2_dir_inode_operations = {
 	.mkdir		= ext2_mkdir,
 	.rmdir		= ext2_rmdir,
 	.mknod		= ext2_mknod,
-	.rename2	= ext2_rename,
+	.rename		= ext2_rename,
 #ifdef CONFIG_EXT2_FS_XATTR
 	.setxattr	= generic_setxattr,
 	.getxattr	= generic_getxattr,
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 34c0142caf6a..0464e2c0d3fd 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -3880,7 +3880,7 @@ const struct inode_operations ext4_dir_inode_operations = {
 	.rmdir		= ext4_rmdir,
 	.mknod		= ext4_mknod,
 	.tmpfile	= ext4_tmpfile,
-	.rename2	= ext4_rename2,
+	.rename		= ext4_rename2,
 	.setattr	= ext4_setattr,
 	.setxattr	= generic_setxattr,
 	.getxattr	= generic_getxattr,
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 73fa356f8fbb..08e3d1d7a500 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -1093,7 +1093,7 @@ const struct inode_operations f2fs_dir_inode_operations = {
 	.mkdir		= f2fs_mkdir,
 	.rmdir		= f2fs_rmdir,
 	.mknod		= f2fs_mknod,
-	.rename2	= f2fs_rename2,
+	.rename		= f2fs_rename2,
 	.tmpfile	= f2fs_tmpfile,
 	.getattr	= f2fs_getattr,
 	.setattr	= f2fs_setattr,
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
index 6c814699d5d5..a8f6aa969948 100644
--- a/fs/fat/namei_msdos.c
+++ b/fs/fat/namei_msdos.c
@@ -637,7 +637,7 @@ static const struct inode_operations msdos_dir_inode_operations = {
 	.unlink		= msdos_unlink,
 	.mkdir		= msdos_mkdir,
 	.rmdir		= msdos_rmdir,
-	.rename2	= msdos_rename,
+	.rename		= msdos_rename,
 	.setattr	= fat_setattr,
 	.getattr	= fat_getattr,
 };
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index ce8986f3918a..c5e48b8631cc 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -1040,7 +1040,7 @@ static const struct inode_operations vfat_dir_inode_operations = {
 	.unlink		= vfat_unlink,
 	.mkdir		= vfat_mkdir,
 	.rmdir		= vfat_rmdir,
-	.rename2	= vfat_rename,
+	.rename		= vfat_rename,
 	.setattr	= fat_setattr,
 	.getattr	= fat_getattr,
 };
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index c47b7780ce37..4bfeaa70815f 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1876,7 +1876,7 @@ static const struct inode_operations fuse_dir_inode_operations = {
 	.symlink	= fuse_symlink,
 	.unlink		= fuse_unlink,
 	.rmdir		= fuse_rmdir,
-	.rename2	= fuse_rename2,
+	.rename		= fuse_rename2,
 	.link		= fuse_link,
 	.setattr	= fuse_setattr,
 	.create		= fuse_create,
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index e4da0ecd3285..56825cc8ab87 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -2054,7 +2054,7 @@ const struct inode_operations gfs2_dir_iops = {
 	.mkdir = gfs2_mkdir,
 	.rmdir = gfs2_unlink,
 	.mknod = gfs2_mknod,
-	.rename2 = gfs2_rename2,
+	.rename = gfs2_rename2,
 	.permission = gfs2_permission,
 	.setattr = gfs2_setattr,
 	.getattr = gfs2_getattr,
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index d5ce9fcad10f..4f7a1b64e251 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -324,6 +324,6 @@ const struct inode_operations hfs_dir_inode_operations = {
 	.unlink		= hfs_remove,
 	.mkdir		= hfs_mkdir,
 	.rmdir		= hfs_remove,
-	.rename2	= hfs_rename,
+	.rename		= hfs_rename,
 	.setattr	= hfs_inode_setattr,
 };
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index ca64a75f12b3..063577958126 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -565,7 +565,7 @@ const struct inode_operations hfsplus_dir_inode_operations = {
 	.rmdir			= hfsplus_rmdir,
 	.symlink		= hfsplus_symlink,
 	.mknod			= hfsplus_mknod,
-	.rename2		= hfsplus_rename,
+	.rename			= hfsplus_rename,
 	.setxattr		= generic_setxattr,
 	.getxattr		= generic_getxattr,
 	.listxattr		= hfsplus_listxattr,
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 90e46cd752fe..530606169e49 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -885,7 +885,7 @@ static const struct inode_operations hostfs_dir_iops = {
 	.mkdir		= hostfs_mkdir,
 	.rmdir		= hostfs_rmdir,
 	.mknod		= hostfs_mknod,
-	.rename2	= hostfs_rename2,
+	.rename		= hostfs_rename2,
 	.permission	= hostfs_permission,
 	.setattr	= hostfs_setattr,
 };
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index 3c5c1a75569d..f30c14414518 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -622,6 +622,6 @@ const struct inode_operations hpfs_dir_iops =
 	.mkdir		= hpfs_mkdir,
 	.rmdir		= hpfs_rmdir,
 	.mknod		= hpfs_mknod,
-	.rename2	= hpfs_rename,
+	.rename		= hpfs_rename,
 	.setattr	= hpfs_setattr,
 };
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 50cd7475a942..4ea71eba40a5 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -988,7 +988,7 @@ static const struct inode_operations hugetlbfs_dir_inode_operations = {
 	.mkdir		= hugetlbfs_mkdir,
 	.rmdir		= simple_rmdir,
 	.mknod		= hugetlbfs_mknod,
-	.rename2	= simple_rename,
+	.rename		= simple_rename,
 	.setattr	= hugetlbfs_setattr,
 };
 
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 11e711b12ccf..d957734a2adb 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -58,7 +58,7 @@ const struct inode_operations jffs2_dir_inode_operations =
 	.mkdir =	jffs2_mkdir,
 	.rmdir =	jffs2_rmdir,
 	.mknod =	jffs2_mknod,
-	.rename2 =	jffs2_rename,
+	.rename =	jffs2_rename,
 	.get_acl =	jffs2_get_acl,
 	.set_acl =	jffs2_set_acl,
 	.setattr =	jffs2_setattr,
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index ee1aa32f7c24..1d88df6ae81b 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -1539,7 +1539,7 @@ const struct inode_operations jfs_dir_inode_operations = {
 	.mkdir		= jfs_mkdir,
 	.rmdir		= jfs_rmdir,
 	.mknod		= jfs_mknod,
-	.rename2	= jfs_rename,
+	.rename		= jfs_rename,
 	.setxattr	= generic_setxattr,
 	.getxattr	= generic_getxattr,
 	.listxattr	= jfs_listxattr,
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index c7e23ca945ab..390390212b43 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -1137,7 +1137,7 @@ const struct inode_operations kernfs_dir_iops = {
 
 	.mkdir		= kernfs_iop_mkdir,
 	.rmdir		= kernfs_iop_rmdir,
-	.rename2	= kernfs_iop_rename,
+	.rename		= kernfs_iop_rename,
 };
 
 static struct kernfs_node *kernfs_leftmost_descendant(struct kernfs_node *pos)
diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c
index 57f2da17a905..be37b907e65a 100644
--- a/fs/logfs/dir.c
+++ b/fs/logfs/dir.c
@@ -787,7 +787,7 @@ const struct inode_operations logfs_dir_iops = {
 	.lookup		= logfs_lookup,
 	.mkdir		= logfs_mkdir,
 	.mknod		= logfs_mknod,
-	.rename2	= logfs_rename,
+	.rename		= logfs_rename,
 	.rmdir		= logfs_rmdir,
 	.symlink	= logfs_symlink,
 	.unlink		= logfs_unlink,
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index 6dc210c0e3ce..f7811d508104 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -268,7 +268,7 @@ const struct inode_operations minix_dir_inode_operations = {
 	.mkdir		= minix_mkdir,
 	.rmdir		= minix_rmdir,
 	.mknod		= minix_mknod,
-	.rename2	= minix_rename,
+	.rename		= minix_rename,
 	.getattr	= minix_getattr,
 	.tmpfile	= minix_tmpfile,
 };
diff --git a/fs/namei.c b/fs/namei.c
index 02803bd6cbad..cf3fc8db909c 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4369,7 +4369,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	if (error)
 		return error;
 
-	if (!old_dir->i_op->rename2)
+	if (!old_dir->i_op->rename)
 		return -EPERM;
 
 	/*
@@ -4425,7 +4425,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 		if (error)
 			goto out;
 	}
-	error = old_dir->i_op->rename2(old_dir, old_dentry,
+	error = old_dir->i_op->rename(old_dir, old_dentry,
 				       new_dir, new_dentry, flags);
 	if (error)
 		goto out;
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index a2d3738df4af..6df2a3827574 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -65,7 +65,7 @@ const struct inode_operations ncp_dir_inode_operations =
 	.mkdir		= ncp_mkdir,
 	.rmdir		= ncp_rmdir,
 	.mknod		= ncp_mknod,
-	.rename2	= ncp_rename,
+	.rename		= ncp_rename,
 	.setattr	= ncp_notify_change,
 };
 
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index a85fdae4a51f..698be9361280 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -893,7 +893,7 @@ static const struct inode_operations nfs3_dir_inode_operations = {
 	.mkdir		= nfs_mkdir,
 	.rmdir		= nfs_rmdir,
 	.mknod		= nfs_mknod,
-	.rename2	= nfs_rename,
+	.rename		= nfs_rename,
 	.permission	= nfs_permission,
 	.getattr	= nfs_getattr,
 	.setattr	= nfs_setattr,
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 7c217fd22214..1949bbd806eb 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -8867,7 +8867,7 @@ static const struct inode_operations nfs4_dir_inode_operations = {
 	.mkdir		= nfs_mkdir,
 	.rmdir		= nfs_rmdir,
 	.mknod		= nfs_mknod,
-	.rename2	= nfs_rename,
+	.rename		= nfs_rename,
 	.permission	= nfs_permission,
 	.getattr	= nfs_getattr,
 	.setattr	= nfs_setattr,
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index 380d0b787983..b7bca8303989 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -685,7 +685,7 @@ static const struct inode_operations nfs_dir_inode_operations = {
 	.mkdir		= nfs_mkdir,
 	.rmdir		= nfs_rmdir,
 	.mknod		= nfs_mknod,
-	.rename2	= nfs_rename,
+	.rename		= nfs_rename,
 	.permission	= nfs_permission,
 	.getattr	= nfs_getattr,
 	.setattr	= nfs_setattr,
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index 8540c13ef374..ea94049c3e79 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -556,7 +556,7 @@ const struct inode_operations nilfs_dir_inode_operations = {
 	.mkdir		= nilfs_mkdir,
 	.rmdir		= nilfs_rmdir,
 	.mknod		= nilfs_mknod,
-	.rename2	= nilfs_rename,
+	.rename		= nilfs_rename,
 	.setattr	= nilfs_setattr,
 	.permission	= nilfs_permission,
 	.fiemap		= nilfs_fiemap,
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 1040c10a9493..7fb6a7f023e7 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -2913,7 +2913,7 @@ const struct inode_operations ocfs2_dir_iops = {
 	.symlink	= ocfs2_symlink,
 	.mkdir		= ocfs2_mkdir,
 	.mknod		= ocfs2_mknod,
-	.rename2	= ocfs2_rename,
+	.rename		= ocfs2_rename,
 	.setattr	= ocfs2_setattr,
 	.getattr	= ocfs2_getattr,
 	.permission	= ocfs2_permission,
diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
index 417511bbe362..e81f06be5e7b 100644
--- a/fs/omfs/dir.c
+++ b/fs/omfs/dir.c
@@ -448,7 +448,7 @@ static int omfs_readdir(struct file *file, struct dir_context *ctx)
 const struct inode_operations omfs_dir_inops = {
 	.lookup = omfs_lookup,
 	.mkdir = omfs_mkdir,
-	.rename2 = omfs_rename,
+	.rename = omfs_rename,
 	.create = omfs_create,
 	.unlink = omfs_remove,
 	.rmdir = omfs_remove,
diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
index 810d43635dfb..5f015c58bfa2 100644
--- a/fs/orangefs/namei.c
+++ b/fs/orangefs/namei.c
@@ -463,7 +463,7 @@ const struct inode_operations orangefs_dir_inode_operations = {
 	.symlink = orangefs_symlink,
 	.mkdir = orangefs_mkdir,
 	.rmdir = orangefs_unlink,
-	.rename2 = orangefs_rename,
+	.rename = orangefs_rename,
 	.setattr = orangefs_setattr,
 	.getattr = orangefs_getattr,
 	.setxattr = generic_setxattr,
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 12bcd07b9e32..46cadb211478 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -942,7 +942,7 @@ const struct inode_operations ovl_dir_inode_operations = {
 	.symlink	= ovl_symlink,
 	.unlink		= ovl_unlink,
 	.rmdir		= ovl_rmdir,
-	.rename2	= ovl_rename2,
+	.rename		= ovl_rename2,
 	.link		= ovl_link,
 	.setattr	= ovl_setattr,
 	.create		= ovl_create,
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index e4f5c9536bfe..013c8397c050 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -114,13 +114,13 @@ static inline int ovl_do_rename(struct inode *olddir, struct dentry *olddentry,
 {
 	int err;
 
-	pr_debug("rename2(%pd2, %pd2, 0x%x)\n",
+	pr_debug("rename(%pd2, %pd2, 0x%x)\n",
 		 olddentry, newdentry, flags);
 
 	err = vfs_rename(olddir, olddentry, newdir, newdentry, NULL, flags);
 
 	if (err) {
-		pr_debug("...rename2(%pd2, %pd2, ...) = %i\n",
+		pr_debug("...rename(%pd2, %pd2, ...) = %i\n",
 			 olddentry, newdentry, err);
 	}
 	return err;
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index c2aa068ff974..1ab6e6c2e60e 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -146,7 +146,7 @@ static const struct inode_operations ramfs_dir_inode_operations = {
 	.mkdir		= ramfs_mkdir,
 	.rmdir		= simple_rmdir,
 	.mknod		= ramfs_mknod,
-	.rename2	= simple_rename,
+	.rename		= simple_rename,
 };
 
 static const struct super_operations ramfs_ops = {
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index 21b4b7138985..586260ed81c9 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -1652,7 +1652,7 @@ const struct inode_operations reiserfs_dir_inode_operations = {
 	.mkdir = reiserfs_mkdir,
 	.rmdir = reiserfs_rmdir,
 	.mknod = reiserfs_mknod,
-	.rename2 = reiserfs_rename,
+	.rename = reiserfs_rename,
 	.setattr = reiserfs_setattr,
 	.setxattr = generic_setxattr,
 	.getxattr = generic_getxattr,
diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c
index 765d79de1217..30bf6780985a 100644
--- a/fs/sysv/namei.c
+++ b/fs/sysv/namei.c
@@ -289,6 +289,6 @@ const struct inode_operations sysv_dir_inode_operations = {
 	.mkdir		= sysv_mkdir,
 	.rmdir		= sysv_rmdir,
 	.mknod		= sysv_mknod,
-	.rename2	= sysv_rename,
+	.rename		= sysv_rename,
 	.getattr	= sysv_getattr,
 };
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 23d1ebabc688..e10e9a00cfc3 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1183,7 +1183,7 @@ const struct inode_operations ubifs_dir_inode_operations = {
 	.mkdir       = ubifs_mkdir,
 	.rmdir       = ubifs_rmdir,
 	.mknod       = ubifs_mknod,
-	.rename2     = ubifs_rename,
+	.rename     = ubifs_rename,
 	.setattr     = ubifs_setattr,
 	.getattr     = ubifs_getattr,
 	.setxattr    = generic_setxattr,
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index ca2ec0061802..17e9d4af3010 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -1357,6 +1357,6 @@ const struct inode_operations udf_dir_inode_operations = {
 	.mkdir				= udf_mkdir,
 	.rmdir				= udf_rmdir,
 	.mknod				= udf_mknod,
-	.rename2			= udf_rename,
+	.rename				= udf_rename,
 	.tmpfile			= udf_tmpfile,
 };
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index 719c9c9b83d8..f2f11c382b6d 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -337,5 +337,5 @@ const struct inode_operations ufs_dir_inode_operations = {
 	.mkdir		= ufs_mkdir,
 	.rmdir		= ufs_rmdir,
 	.mknod		= ufs_mknod,
-	.rename2	= ufs_rename,
+	.rename		= ufs_rename,
 };
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index ab820f84ed50..2595b8818458 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -1052,7 +1052,7 @@ static const struct inode_operations xfs_dir_inode_operations = {
 	 */
 	.rmdir			= xfs_vn_unlink,
 	.mknod			= xfs_vn_mknod,
-	.rename2		= xfs_vn_rename,
+	.rename			= xfs_vn_rename,
 	.get_acl		= xfs_get_acl,
 	.set_acl		= xfs_set_acl,
 	.getattr		= xfs_vn_getattr,
@@ -1080,7 +1080,7 @@ static const struct inode_operations xfs_dir_ci_inode_operations = {
 	 */
 	.rmdir			= xfs_vn_unlink,
 	.mknod			= xfs_vn_mknod,
-	.rename2		= xfs_vn_rename,
+	.rename			= xfs_vn_rename,
 	.get_acl		= xfs_get_acl,
 	.set_acl		= xfs_set_acl,
 	.getattr		= xfs_vn_getattr,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5a69b2e357a5..b30b37ca10bb 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1731,7 +1731,7 @@ struct inode_operations {
 	int (*mkdir) (struct inode *,struct dentry *,umode_t);
 	int (*rmdir) (struct inode *,struct dentry *);
 	int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t);
-	int (*rename2) (struct inode *, struct dentry *,
+	int (*rename) (struct inode *, struct dentry *,
 			struct inode *, struct dentry *, unsigned int);
 	int (*setattr) (struct dentry *, struct iattr *);
 	int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index c92fd8936d33..5967b870a895 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -189,7 +189,7 @@ static const struct inode_operations bpf_dir_iops = {
 	.mknod		= bpf_mkobj,
 	.mkdir		= bpf_mkdir,
 	.rmdir		= simple_rmdir,
-	.rename2	= simple_rename,
+	.rename		= simple_rename,
 	.link		= simple_link,
 	.unlink		= simple_unlink,
 };
diff --git a/mm/shmem.c b/mm/shmem.c
index fd8b2b5741b1..ac35ebd23662 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3813,7 +3813,7 @@ static const struct inode_operations shmem_dir_inode_operations = {
 	.mkdir		= shmem_mkdir,
 	.rmdir		= shmem_rmdir,
 	.mknod		= shmem_mknod,
-	.rename2	= shmem_rename2,
+	.rename		= shmem_rename2,
 	.tmpfile	= shmem_tmpfile,
 #endif
 #ifdef CONFIG_TMPFS_XATTR
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c
index 38bcdbc06bb2..a97b275ca3af 100644
--- a/security/tomoyo/realpath.c
+++ b/security/tomoyo/realpath.c
@@ -173,7 +173,7 @@ static char *tomoyo_get_local_path(struct dentry *dentry, char * const buffer,
 		 * Use filesystem name if filesystem does not support rename()
 		 * operation.
 		 */
-		if (!inode->i_op->rename2)
+		if (!inode->i_op->rename)
 			goto prepend_filesystem_name;
 	}
 	/* Prepend device name. */
@@ -283,7 +283,7 @@ char *tomoyo_realpath_from_path(const struct path *path)
 		 * or dentry without vfsmount.
 		 */
 		if (!path->mnt ||
-		    (!inode->i_op->rename2))
+		    (!inode->i_op->rename))
 			pos = tomoyo_get_local_path(path->dentry, buf,
 						    buf_len - 1);
 		/* Get absolute name for the rest. */
-- 
2.5.5

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

* [PATCH 7/7] vfs: add note about i_op->rename changes to porting
  2016-08-23 14:05 [PATCH 0/7] vfs: finish rename -> rename2 conversion Miklos Szeredi
                   ` (5 preceding siblings ...)
  2016-08-23 14:05 ` [PATCH 6/7] fs: rename "rename2" i_op to "rename" Miklos Szeredi
@ 2016-08-23 14:05 ` Miklos Szeredi
  2016-08-23 15:36 ` [PATCH 4/7] fs: make remaining filesystems use .rename2 David Howells
  7 siblings, 0 replies; 17+ messages in thread
From: Miklos Szeredi @ 2016-08-23 14:05 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, Al Viro

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
 Documentation/filesystems/porting | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting
index b1bd05ea66b2..1ab28d9b612a 100644
--- a/Documentation/filesystems/porting
+++ b/Documentation/filesystems/porting
@@ -592,3 +592,7 @@ in your dentry operations instead.
 	work just as well; if it's something more complicated, use dentry->d_parent.
 	Just be careful not to assume that fetching it more than once will yield
 	the same value - in RCU mode it could change under you.
+--
+[mandatory]
+	->rename() has an added flags argument.  Any flags not handled by the
+        filesystem should result in EINVAL being returned.
-- 
2.5.5

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

* Re: [PATCH 3/7] libfs: support RENAME_NOREPLACE in simple_rename()
  2016-08-23 14:05 ` [PATCH 3/7] libfs: support RENAME_NOREPLACE in simple_rename() Miklos Szeredi
@ 2016-08-23 14:47   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 17+ messages in thread
From: Greg Kroah-Hartman @ 2016-08-23 14:47 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: linux-fsdevel, linux-kernel, Al Viro, Alexei Starovoitov

On Tue, Aug 23, 2016 at 04:05:28PM +0200, Miklos Szeredi wrote:
> This is trivial to do:
> 
>  - add flags argument to simple_rename()
>  - check if flags doesn't have any other than RENAME_NOREPLACE
>  - assign simple_rename() to .rename2 instead of .rename
> 
> Filesystems converted:
> 
> hugetlbfs, ramfs, bpf.
> 
> Debugfs uses simple_rename() to implement debugfs_rename(), which is for
> debugfs instances to rename files internally, not for userspace filesystem
> access.  For this case pass zero flags to simple_rename().
> 
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

* Re: [PATCH 4/7] fs: make remaining filesystems use .rename2
  2016-08-23 14:05 ` [PATCH 4/7] fs: make remaining filesystems use .rename2 Miklos Szeredi
@ 2016-08-23 14:47   ` Greg Kroah-Hartman
  2016-08-23 17:30     ` Mike Marshall
  2016-08-23 16:24   ` Boaz Harrosh
  1 sibling, 1 reply; 17+ messages in thread
From: Greg Kroah-Hartman @ 2016-08-23 14:47 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: linux-fsdevel, linux-kernel, Al Viro, Eric Van Hensbergen,
	David Howells, Ilya Dryomov, Jan Harkes, Tyler Hicks,
	Boaz Harrosh, Oleg Drokin, Trond Myklebust, Mark Fasheh,
	Mike Marshall

On Tue, Aug 23, 2016 at 04:05:29PM +0200, Miklos Szeredi wrote:
> This is trivial to do:
> 
>  - add flags argument to foo_rename()
>  - check if flags is zero
>  - assign foo_rename() to .rename2 instead of .rename
> 
> This doesn't mean it's impossible to support RENAME_NOREPLACE for these
> filesystems, but it is not trivial, like for local filesystems.
> RENAME_NOREPLACE must guarantee atomicity (i.e. it shouldn't be possible
> for a file to be created on one host while it is overwritten by rename on
> another host).
> 
> Filesystems converted:
> 
> 9p, afs, ceph, coda, ecryptfs, exofs, kernfs, lustre, ncpfs, nfs, ocfs2,
> orangefs.
> 
> After this, we can get rid of the duplicate interfaces for rename.
> 
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
> Cc: Eric Van Hensbergen <ericvh@gmail.com>
> Cc: David Howells <dhowells@redhat.com>
> Cc: Ilya Dryomov <idryomov@gmail.com>
> Cc: Jan Harkes <jaharkes@cs.cmu.edu>
> Cc: Tyler Hicks <tyhicks@canonical.com>
> Cc: Boaz Harrosh <ooo@electrozaur.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Oleg Drokin <oleg.drokin@intel.com>
> Cc: Trond Myklebust <trond.myklebust@primarydata.com>
> Cc: Mark Fasheh <mfasheh@suse.com>
> Cc: Mike Marshall <hubcap@omnibond.com>

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

* Re: [PATCH 4/7] fs: make remaining filesystems use .rename2
  2016-08-23 14:05 [PATCH 0/7] vfs: finish rename -> rename2 conversion Miklos Szeredi
                   ` (6 preceding siblings ...)
  2016-08-23 14:05 ` [PATCH 7/7] vfs: add note about i_op->rename changes to porting Miklos Szeredi
@ 2016-08-23 15:36 ` David Howells
  7 siblings, 0 replies; 17+ messages in thread
From: David Howells @ 2016-08-23 15:36 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: dhowells, linux-fsdevel, linux-kernel, Al Viro,
	Eric Van Hensbergen, Ilya Dryomov, Jan Harkes, Tyler Hicks,
	Boaz Harrosh, Greg Kroah-Hartman, Oleg Drokin, Trond Myklebust,
	Mark Fasheh, Mike Marshall

Miklos Szeredi <mszeredi@redhat.com> wrote:

> This is trivial to do:
> 
>  - add flags argument to foo_rename()
>  - check if flags is zero
>  - assign foo_rename() to .rename2 instead of .rename
> 
> This doesn't mean it's impossible to support RENAME_NOREPLACE for these
> filesystems, but it is not trivial, like for local filesystems.
> RENAME_NOREPLACE must guarantee atomicity (i.e. it shouldn't be possible
> for a file to be created on one host while it is overwritten by rename on
> another host).
> 
> Filesystems converted:
> 
> 9p, afs, ceph, coda, ecryptfs, exofs, kernfs, lustre, ncpfs, nfs, ocfs2,
> orangefs.
> 
> After this, we can get rid of the duplicate interfaces for rename.
> 
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
> Cc: Eric Van Hensbergen <ericvh@gmail.com>
> Cc: Ilya Dryomov <idryomov@gmail.com>
> Cc: Jan Harkes <jaharkes@cs.cmu.edu>
> Cc: Tyler Hicks <tyhicks@canonical.com>
> Cc: Boaz Harrosh <ooo@electrozaur.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Oleg Drokin <oleg.drokin@intel.com>
> Cc: Trond Myklebust <trond.myklebust@primarydata.com>
> Cc: Mark Fasheh <mfasheh@suse.com>
> Cc: Mike Marshall <hubcap@omnibond.com>

Acked-by: David Howells <dhowells@redhat.com> [AFS]

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

* Re: [PATCH 4/7] fs: make remaining filesystems use .rename2
  2016-08-23 14:05 ` [PATCH 4/7] fs: make remaining filesystems use .rename2 Miklos Szeredi
  2016-08-23 14:47   ` Greg Kroah-Hartman
@ 2016-08-23 16:24   ` Boaz Harrosh
  2016-08-23 16:29     ` Boaz Harrosh
  1 sibling, 1 reply; 17+ messages in thread
From: Boaz Harrosh @ 2016-08-23 16:24 UTC (permalink / raw)
  To: Miklos Szeredi, linux-fsdevel
  Cc: linux-kernel, Al Viro, Eric Van Hensbergen, David Howells,
	Ilya Dryomov, Jan Harkes, Tyler Hicks, Greg Kroah-Hartman,
	Oleg Drokin, Trond Myklebust, Mark Fasheh, Mike Marshall

On 08/23/2016 05:05 PM, Miklos Szeredi wrote:
> This is trivial to do:
> 
>  - add flags argument to foo_rename()
>  - check if flags is zero
>  - assign foo_rename() to .rename2 instead of .rename
> 
> This doesn't mean it's impossible to support RENAME_NOREPLACE for these
> filesystems, but it is not trivial, like for local filesystems.
> RENAME_NOREPLACE must guarantee atomicity (i.e. it shouldn't be possible
> for a file to be created on one host while it is overwritten by rename on
> another host).
> 
> Filesystems converted:
> 
> 9p, afs, ceph, coda, ecryptfs, exofs, kernfs, lustre, ncpfs, nfs, ocfs2,
> orangefs.
> 
> After this, we can get rid of the duplicate interfaces for rename.
> 
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
> Cc: Eric Van Hensbergen <ericvh@gmail.com>
> Cc: David Howells <dhowells@redhat.com>
> Cc: Ilya Dryomov <idryomov@gmail.com>
> Cc: Jan Harkes <jaharkes@cs.cmu.edu>
> Cc: Tyler Hicks <tyhicks@canonical.com>
> Cc: Boaz Harrosh <ooo@electrozaur.com>

Hi exofs is not a distributed file system in the nfs-client 
sense. All meta-data operations happen on the single exofs mount.
The distribution of an exofs cluster is done by an NFSD-like daemon
that supports pNFS, and an std pNFS-client.
So the code you see below is just the same as an ext4 FS with
a raid of iscsi devices below it. (Even if then later this FS is
exported by an NFSD server)

That said it is fine as is don't sweat over this unused FS so:
ACK-by: Boaz Harrosh <ooo@electrozaur.com>

<>

> diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c
> index 622a686bb08b..897280163f3c 100644
> --- a/fs/exofs/namei.c
> +++ b/fs/exofs/namei.c
> @@ -227,7 +227,8 @@ static int exofs_rmdir(struct inode *dir, struct dentry *dentry)
>  }
>  
>  static int exofs_rename(struct inode *old_dir, struct dentry *old_dentry,
> -		struct inode *new_dir, struct dentry *new_dentry)
> +			struct inode *new_dir, struct dentry *new_dentry,
> +			unsigned int flags)
>  {
>  	struct inode *old_inode = d_inode(old_dentry);
>  	struct inode *new_inode = d_inode(new_dentry);
> @@ -237,6 +238,9 @@ static int exofs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	struct exofs_dir_entry *old_de;
>  	int err = -ENOENT;
>  
> +	if (flags)
> +		return -EINVAL;
> +
>  	old_de = exofs_find_entry(old_dir, old_dentry, &old_page);
>  	if (!old_de)
>  		goto out;
> @@ -310,7 +314,7 @@ const struct inode_operations exofs_dir_inode_operations = {
>  	.mkdir  	= exofs_mkdir,
>  	.rmdir  	= exofs_rmdir,
>  	.mknod  	= exofs_mknod,
> -	.rename 	= exofs_rename,
> +	.rename2	= exofs_rename,
>  	.setattr	= exofs_setattr,
>  };
>  
<>

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

* Re: [PATCH 4/7] fs: make remaining filesystems use .rename2
  2016-08-23 16:24   ` Boaz Harrosh
@ 2016-08-23 16:29     ` Boaz Harrosh
  0 siblings, 0 replies; 17+ messages in thread
From: Boaz Harrosh @ 2016-08-23 16:29 UTC (permalink / raw)
  To: Miklos Szeredi, linux-fsdevel
  Cc: linux-kernel, Al Viro, Eric Van Hensbergen, David Howells,
	Ilya Dryomov, Jan Harkes, Tyler Hicks, Greg Kroah-Hartman,
	Oleg Drokin, Trond Myklebust, Mark Fasheh, Mike Marshall

On 08/23/2016 07:24 PM, Boaz Harrosh wrote:
> On 08/23/2016 05:05 PM, Miklos Szeredi wrote:
>> This is trivial to do:
>>
>>  - add flags argument to foo_rename()
>>  - check if flags is zero
>>  - assign foo_rename() to .rename2 instead of .rename
>>
>> This doesn't mean it's impossible to support RENAME_NOREPLACE for these
>> filesystems, but it is not trivial, like for local filesystems.
>> RENAME_NOREPLACE must guarantee atomicity (i.e. it shouldn't be possible
>> for a file to be created on one host while it is overwritten by rename on
>> another host).
>>
>> Filesystems converted:
>>
>> 9p, afs, ceph, coda, ecryptfs, exofs, kernfs, lustre, ncpfs, nfs, ocfs2,
>> orangefs.
>>
>> After this, we can get rid of the duplicate interfaces for rename.
>>
>> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
>> Cc: Eric Van Hensbergen <ericvh@gmail.com>
>> Cc: David Howells <dhowells@redhat.com>
>> Cc: Ilya Dryomov <idryomov@gmail.com>
>> Cc: Jan Harkes <jaharkes@cs.cmu.edu>
>> Cc: Tyler Hicks <tyhicks@canonical.com>
>> Cc: Boaz Harrosh <ooo@electrozaur.com>
> 
> Hi exofs is not a distributed file system in the nfs-client 
> sense. All meta-data operations happen on the single exofs mount.
> The distribution of an exofs cluster is done by an NFSD-like daemon
> that supports pNFS, and an std pNFS-client.
> So the code you see below is just the same as an ext4 FS with
> a raid of iscsi devices below it. (Even if then later this FS is
> exported by an NFSD server)
> 
> That said it is fine as is don't sweat over this unused FS so:
> ACK-by: Boaz Harrosh <ooo@electrozaur.com>
> 
> <>
> 
>> diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c
>> index 622a686bb08b..897280163f3c 100644
>> --- a/fs/exofs/namei.c
>> +++ b/fs/exofs/namei.c
>> @@ -227,7 +227,8 @@ static int exofs_rmdir(struct inode *dir, struct dentry *dentry)
>>  }
>>  
>>  static int exofs_rename(struct inode *old_dir, struct dentry *old_dentry,
>> -		struct inode *new_dir, struct dentry *new_dentry)
>> +			struct inode *new_dir, struct dentry *new_dentry,
>> +			unsigned int flags)
>>  {
>>  	struct inode *old_inode = d_inode(old_dentry);
>>  	struct inode *new_inode = d_inode(new_dentry);
>> @@ -237,6 +238,9 @@ static int exofs_rename(struct inode *old_dir, struct dentry *old_dentry,
>>  	struct exofs_dir_entry *old_de;
>>  	int err = -ENOENT;
>>  
>> +	if (flags)
>> +		return -EINVAL;
>> +

+	if (flags & ~RENAME_NOREPLACE)
+		return -EINVAL;
+

And move to the other patch if you feel like it

>>  	old_de = exofs_find_entry(old_dir, old_dentry, &old_page);
>>  	if (!old_de)
>>  		goto out;
>> @@ -310,7 +314,7 @@ const struct inode_operations exofs_dir_inode_operations = {
>>  	.mkdir  	= exofs_mkdir,
>>  	.rmdir  	= exofs_rmdir,
>>  	.mknod  	= exofs_mknod,
>> -	.rename 	= exofs_rename,
>> +	.rename2	= exofs_rename,
>>  	.setattr	= exofs_setattr,
>>  };
>>  
> <>
> 

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

* Re: [PATCH 4/7] fs: make remaining filesystems use .rename2
  2016-08-23 14:47   ` Greg Kroah-Hartman
@ 2016-08-23 17:30     ` Mike Marshall
  0 siblings, 0 replies; 17+ messages in thread
From: Mike Marshall @ 2016-08-23 17:30 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Miklos Szeredi, linux-fsdevel, LKML, Al Viro,
	Eric Van Hensbergen, David Howells, Ilya Dryomov, Jan Harkes,
	Tyler Hicks, Boaz Harrosh, Oleg Drokin, Trond Myklebust,
	Mark Fasheh

I looked at this in today's linux-next and ran a few renames through...

Acked-by:: Mike Marshall <hubcap@omnibond.com>

On Tue, Aug 23, 2016 at 10:47 AM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Tue, Aug 23, 2016 at 04:05:29PM +0200, Miklos Szeredi wrote:
>> This is trivial to do:
>>
>>  - add flags argument to foo_rename()
>>  - check if flags is zero
>>  - assign foo_rename() to .rename2 instead of .rename
>>
>> This doesn't mean it's impossible to support RENAME_NOREPLACE for these
>> filesystems, but it is not trivial, like for local filesystems.
>> RENAME_NOREPLACE must guarantee atomicity (i.e. it shouldn't be possible
>> for a file to be created on one host while it is overwritten by rename on
>> another host).
>>
>> Filesystems converted:
>>
>> 9p, afs, ceph, coda, ecryptfs, exofs, kernfs, lustre, ncpfs, nfs, ocfs2,
>> orangefs.
>>
>> After this, we can get rid of the duplicate interfaces for rename.
>>
>> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
>> Cc: Eric Van Hensbergen <ericvh@gmail.com>
>> Cc: David Howells <dhowells@redhat.com>
>> Cc: Ilya Dryomov <idryomov@gmail.com>
>> Cc: Jan Harkes <jaharkes@cs.cmu.edu>
>> Cc: Tyler Hicks <tyhicks@canonical.com>
>> Cc: Boaz Harrosh <ooo@electrozaur.com>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: Oleg Drokin <oleg.drokin@intel.com>
>> Cc: Trond Myklebust <trond.myklebust@primarydata.com>
>> Cc: Mark Fasheh <mfasheh@suse.com>
>> Cc: Mike Marshall <hubcap@omnibond.com>
>
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

* Re: [PATCH 2/7] fs: support RENAME_NOREPLACE for local filesystems
  2016-08-23 14:05 ` [PATCH 2/7] fs: support RENAME_NOREPLACE for local filesystems Miklos Szeredi
@ 2016-08-23 21:48   ` Richard Weinberger
  2016-08-25 12:52   ` Bob Copeland
  2016-09-08 13:55   ` Jan Kara
  2 siblings, 0 replies; 17+ messages in thread
From: Richard Weinberger @ 2016-08-23 21:48 UTC (permalink / raw)
  To: Miklos Szeredi, linux-fsdevel
  Cc: linux-kernel, Al Viro, Jan Kara, Theodore Ts'o, Jaegeuk Kim,
	OGAWA Hirofumi, Mikulas Patocka, David Woodhouse, Dave Kleikamp,
	Ryusuke Konishi, Bob Copeland, Christoph Hellwig

Miklos,

On 23.08.2016 16:05, Miklos Szeredi wrote:
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index 4b86d3a738e1..23d1ebabc688 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -966,7 +966,8 @@ static void unlock_3_inodes(struct inode *inode1, struct inode *inode2,
>  }
>  
>  static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
> -			struct inode *new_dir, struct dentry *new_dentry)
> +			struct inode *new_dir, struct dentry *new_dentry,
> +			unsigned int flags)
>  {
>  	struct ubifs_info *c = old_dir->i_sb->s_fs_info;
>  	struct inode *old_inode = d_inode(old_dentry);
> @@ -984,6 +985,9 @@ static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	struct timespec time;
>  	unsigned int uninitialized_var(saved_nlink);
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	/*
>  	 * Budget request settings: deletion direntry, new direntry, removing
>  	 * the old inode, and changing old and new parent directory inodes.
> @@ -1179,7 +1183,7 @@ const struct inode_operations ubifs_dir_inode_operations = {
>  	.mkdir       = ubifs_mkdir,
>  	.rmdir       = ubifs_rmdir,
>  	.mknod       = ubifs_mknod,
> -	.rename      = ubifs_rename,
> +	.rename2     = ubifs_rename,
>  	.setattr     = ubifs_setattr,
>  	.getattr     = ubifs_getattr,
>  	.setxattr    = generic_setxattr,

For UBIFS,
Acked-by: Richard Weinberger <richard@nod.at>

Thanks,,
//richard

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

* Re: [PATCH 2/7] fs: support RENAME_NOREPLACE for local filesystems
  2016-08-23 14:05 ` [PATCH 2/7] fs: support RENAME_NOREPLACE for local filesystems Miklos Szeredi
  2016-08-23 21:48   ` Richard Weinberger
@ 2016-08-25 12:52   ` Bob Copeland
  2016-09-08 13:55   ` Jan Kara
  2 siblings, 0 replies; 17+ messages in thread
From: Bob Copeland @ 2016-08-25 12:52 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: linux-fsdevel, linux-kernel, Al Viro, Jan Kara,
	Theodore Ts'o, Jaegeuk Kim, OGAWA Hirofumi, Mikulas Patocka,
	David Woodhouse, Dave Kleikamp, Ryusuke Konishi,
	Christoph Hellwig, Richard Weinberger

On Tue, Aug 23, 2016 at 04:05:27PM +0200, Miklos Szeredi wrote:
omfs/dir.c b/fs/omfs/dir.c
> index c8cbf3b60645..417511bbe362 100644
> --- a/fs/omfs/dir.c
> +++ b/fs/omfs/dir.c
> @@ -371,12 +371,16 @@ static bool omfs_fill_chain(struct inode *dir, struct dir_context *ctx,
>  }
>  
>  static int omfs_rename(struct inode *old_dir, struct dentry *old_dentry,
> -		struct inode *new_dir, struct dentry *new_dentry)
> +		       struct inode *new_dir, struct dentry *new_dentry,
> +		       unsigned int flags)
>  {
>  	struct inode *new_inode = d_inode(new_dentry);
>  	struct inode *old_inode = d_inode(old_dentry);
>  	int err;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	if (new_inode) {
>  		/* overwriting existing file/dir */
>  		err = omfs_remove(new_dir, new_dentry);
> @@ -444,7 +448,7 @@ static int omfs_readdir(struct file *file, struct dir_context *ctx)

omfs changes look fine.

Acked-by: Bob Copeland <me@bobcopeland.com>

-- 
Bob Copeland %% http://bobcopeland.com/

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

* Re: [PATCH 2/7] fs: support RENAME_NOREPLACE for local filesystems
  2016-08-23 14:05 ` [PATCH 2/7] fs: support RENAME_NOREPLACE for local filesystems Miklos Szeredi
  2016-08-23 21:48   ` Richard Weinberger
  2016-08-25 12:52   ` Bob Copeland
@ 2016-09-08 13:55   ` Jan Kara
  2 siblings, 0 replies; 17+ messages in thread
From: Jan Kara @ 2016-09-08 13:55 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: linux-fsdevel, linux-kernel, Al Viro, Jan Kara,
	Theodore Ts'o, Jaegeuk Kim, OGAWA Hirofumi, Mikulas Patocka,
	David Woodhouse, Dave Kleikamp, Ryusuke Konishi, Bob Copeland,
	Christoph Hellwig, Richard Weinberger

On Tue 23-08-16 16:05:27, Miklos Szeredi wrote:
> This is trivial to do:
> 
>  - add flags argument to foo_rename()
>  - check if flags doesn't have any other than RENAME_NOREPLACE
>  - assign foo_rename() to .rename2 instead of .rename
> 
> Filesystems converted:
> 
> affs, bfs, ext2, hfs, hfsplus, jffs2, jfs, logfs, minix, msdos, nilfs2,
> omfs, reiserfs, sysvfs, ubifs, udf, ufs, vfat.

ext2, UDF, and reiserfs changes look fine. You can add:

Acked-by: Jan Kara <jack@suse.cz>

								Honza
> 
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
> Cc: Jan Kara <jack@suse.cz>
> Cc: Theodore Ts'o <tytso@mit.edu>
> Cc: Jaegeuk Kim <jaegeuk@kernel.org>
> Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
> Cc: Mikulas Patocka <mpatocka@redhat.com>
> Cc: David Woodhouse <dwmw2@infradead.org>
> Cc: Dave Kleikamp <shaggy@kernel.org>
> Cc: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
> Cc: Bob Copeland <me@bobcopeland.com>
> Cc: Christoph Hellwig <hch@infradead.org>
> Cc: Richard Weinberger <richard@nod.at>
> ---
>  fs/affs/affs.h       |  3 ++-
>  fs/affs/dir.c        |  2 +-
>  fs/affs/namei.c      |  6 +++++-
>  fs/bfs/dir.c         |  8 ++++++--
>  fs/ext2/namei.c      |  8 ++++++--
>  fs/fat/namei_msdos.c |  8 ++++++--
>  fs/fat/namei_vfat.c  |  8 ++++++--
>  fs/hfs/dir.c         |  8 ++++++--
>  fs/hfsplus/dir.c     |  8 ++++++--
>  fs/hpfs/namei.c      |  8 ++++++--
>  fs/jffs2/dir.c       | 11 ++++++++---
>  fs/jfs/namei.c       |  7 +++++--
>  fs/logfs/dir.c       |  8 ++++++--
>  fs/minix/namei.c     |  8 ++++++--
>  fs/nilfs2/namei.c    |  8 ++++++--
>  fs/omfs/dir.c        |  8 ++++++--
>  fs/reiserfs/namei.c  |  8 ++++++--
>  fs/sysv/namei.c      |  8 ++++++--
>  fs/ubifs/dir.c       |  8 ++++++--
>  fs/udf/namei.c       |  8 ++++++--
>  fs/ufs/namei.c       |  8 ++++++--
>  21 files changed, 117 insertions(+), 40 deletions(-)
> 
> diff --git a/fs/affs/affs.h b/fs/affs/affs.h
> index cc2b2efc9211..2f088773f1c0 100644
> --- a/fs/affs/affs.h
> +++ b/fs/affs/affs.h
> @@ -173,7 +173,8 @@ extern int	affs_link(struct dentry *olddentry, struct inode *dir,
>  extern int	affs_symlink(struct inode *dir, struct dentry *dentry,
>  			     const char *symname);
>  extern int	affs_rename(struct inode *old_dir, struct dentry *old_dentry,
> -			    struct inode *new_dir, struct dentry *new_dentry);
> +			    struct inode *new_dir, struct dentry *new_dentry,
> +			    unsigned int flags);
>  
>  /* inode.c */
>  
> diff --git a/fs/affs/dir.c b/fs/affs/dir.c
> index f1e7294381c5..8f127c239472 100644
> --- a/fs/affs/dir.c
> +++ b/fs/affs/dir.c
> @@ -35,7 +35,7 @@ const struct inode_operations affs_dir_inode_operations = {
>  	.symlink	= affs_symlink,
>  	.mkdir		= affs_mkdir,
>  	.rmdir		= affs_rmdir,
> -	.rename		= affs_rename,
> +	.rename2	= affs_rename,
>  	.setattr	= affs_notify_change,
>  };
>  
> diff --git a/fs/affs/namei.c b/fs/affs/namei.c
> index a2d68f828d53..29186d29a3b6 100644
> --- a/fs/affs/namei.c
> +++ b/fs/affs/namei.c
> @@ -414,12 +414,16 @@ affs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
>  
>  int
>  affs_rename(struct inode *old_dir, struct dentry *old_dentry,
> -	    struct inode *new_dir, struct dentry *new_dentry)
> +	    struct inode *new_dir, struct dentry *new_dentry,
> +	    unsigned int flags)
>  {
>  	struct super_block *sb = old_dir->i_sb;
>  	struct buffer_head *bh = NULL;
>  	int retval;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	pr_debug("%s(old=%lu,\"%pd\" to new=%lu,\"%pd\")\n", __func__,
>  		 old_dir->i_ino, old_dentry, new_dir->i_ino, new_dentry);
>  
> diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
> index 34a5bc2f1290..9d5f875e85d0 100644
> --- a/fs/bfs/dir.c
> +++ b/fs/bfs/dir.c
> @@ -207,7 +207,8 @@ out_brelse:
>  }
>  
>  static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry,
> -			struct inode *new_dir, struct dentry *new_dentry)
> +		      struct inode *new_dir, struct dentry *new_dentry,
> +		      unsigned int flags)
>  {
>  	struct inode *old_inode, *new_inode;
>  	struct buffer_head *old_bh, *new_bh;
> @@ -215,6 +216,9 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	struct bfs_sb_info *info;
>  	int error = -ENOENT;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	old_bh = new_bh = NULL;
>  	old_inode = d_inode(old_dentry);
>  	if (S_ISDIR(old_inode->i_mode))
> @@ -270,7 +274,7 @@ const struct inode_operations bfs_dir_inops = {
>  	.lookup			= bfs_lookup,
>  	.link			= bfs_link,
>  	.unlink			= bfs_unlink,
> -	.rename			= bfs_rename,
> +	.rename2		= bfs_rename,
>  };
>  
>  static int bfs_add_entry(struct inode *dir, const unsigned char *name,
> diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
> index d446203127fc..38fac85ff786 100644
> --- a/fs/ext2/namei.c
> +++ b/fs/ext2/namei.c
> @@ -328,7 +328,8 @@ static int ext2_rmdir (struct inode * dir, struct dentry *dentry)
>  }
>  
>  static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
> -	struct inode * new_dir,	struct dentry * new_dentry )
> +			struct inode * new_dir,	struct dentry * new_dentry,
> +			unsigned int flags)
>  {
>  	struct inode * old_inode = d_inode(old_dentry);
>  	struct inode * new_inode = d_inode(new_dentry);
> @@ -338,6 +339,9 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
>  	struct ext2_dir_entry_2 * old_de;
>  	int err;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	err = dquot_initialize(old_dir);
>  	if (err)
>  		goto out;
> @@ -426,7 +430,7 @@ const struct inode_operations ext2_dir_inode_operations = {
>  	.mkdir		= ext2_mkdir,
>  	.rmdir		= ext2_rmdir,
>  	.mknod		= ext2_mknod,
> -	.rename		= ext2_rename,
> +	.rename2	= ext2_rename,
>  #ifdef CONFIG_EXT2_FS_XATTR
>  	.setxattr	= generic_setxattr,
>  	.getxattr	= generic_getxattr,
> diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
> index 664655b2c55f..6c814699d5d5 100644
> --- a/fs/fat/namei_msdos.c
> +++ b/fs/fat/namei_msdos.c
> @@ -596,12 +596,16 @@ error_inode:
>  
>  /***** Rename, a wrapper for rename_same_dir & rename_diff_dir */
>  static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry,
> -			struct inode *new_dir, struct dentry *new_dentry)
> +			struct inode *new_dir, struct dentry *new_dentry,
> +			unsigned int flags)
>  {
>  	struct super_block *sb = old_dir->i_sb;
>  	unsigned char old_msdos_name[MSDOS_NAME], new_msdos_name[MSDOS_NAME];
>  	int err, is_hid;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	mutex_lock(&MSDOS_SB(sb)->s_lock);
>  
>  	err = msdos_format_name(old_dentry->d_name.name,
> @@ -633,7 +637,7 @@ static const struct inode_operations msdos_dir_inode_operations = {
>  	.unlink		= msdos_unlink,
>  	.mkdir		= msdos_mkdir,
>  	.rmdir		= msdos_rmdir,
> -	.rename		= msdos_rename,
> +	.rename2	= msdos_rename,
>  	.setattr	= fat_setattr,
>  	.getattr	= fat_getattr,
>  };
> diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
> index 92b7363dafa9..ce8986f3918a 100644
> --- a/fs/fat/namei_vfat.c
> +++ b/fs/fat/namei_vfat.c
> @@ -903,7 +903,8 @@ out:
>  }
>  
>  static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
> -		       struct inode *new_dir, struct dentry *new_dentry)
> +		       struct inode *new_dir, struct dentry *new_dentry,
> +		       unsigned int flags)
>  {
>  	struct buffer_head *dotdot_bh;
>  	struct msdos_dir_entry *dotdot_de;
> @@ -914,6 +915,9 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	int err, is_dir, update_dotdot, corrupt = 0;
>  	struct super_block *sb = old_dir->i_sb;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	old_sinfo.bh = sinfo.bh = dotdot_bh = NULL;
>  	old_inode = d_inode(old_dentry);
>  	new_inode = d_inode(new_dentry);
> @@ -1036,7 +1040,7 @@ static const struct inode_operations vfat_dir_inode_operations = {
>  	.unlink		= vfat_unlink,
>  	.mkdir		= vfat_mkdir,
>  	.rmdir		= vfat_rmdir,
> -	.rename		= vfat_rename,
> +	.rename2	= vfat_rename,
>  	.setattr	= fat_setattr,
>  	.getattr	= fat_getattr,
>  };
> diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
> index 163190ecc0d2..d5ce9fcad10f 100644
> --- a/fs/hfs/dir.c
> +++ b/fs/hfs/dir.c
> @@ -286,10 +286,14 @@ static int hfs_remove(struct inode *dir, struct dentry *dentry)
>   * XXX: how do you handle must_be dir?
>   */
>  static int hfs_rename(struct inode *old_dir, struct dentry *old_dentry,
> -		      struct inode *new_dir, struct dentry *new_dentry)
> +		      struct inode *new_dir, struct dentry *new_dentry,
> +		      unsigned int flags)
>  {
>  	int res;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	/* Unlink destination if it already exists */
>  	if (d_really_is_positive(new_dentry)) {
>  		res = hfs_remove(new_dir, new_dentry);
> @@ -320,6 +324,6 @@ const struct inode_operations hfs_dir_inode_operations = {
>  	.unlink		= hfs_remove,
>  	.mkdir		= hfs_mkdir,
>  	.rmdir		= hfs_remove,
> -	.rename		= hfs_rename,
> +	.rename2	= hfs_rename,
>  	.setattr	= hfs_inode_setattr,
>  };
> diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
> index 42e128661dc1..ca64a75f12b3 100644
> --- a/fs/hfsplus/dir.c
> +++ b/fs/hfsplus/dir.c
> @@ -530,10 +530,14 @@ static int hfsplus_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
>  }
>  
>  static int hfsplus_rename(struct inode *old_dir, struct dentry *old_dentry,
> -			  struct inode *new_dir, struct dentry *new_dentry)
> +			  struct inode *new_dir, struct dentry *new_dentry,
> +			  unsigned int flags)
>  {
>  	int res;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	/* Unlink destination if it already exists */
>  	if (d_really_is_positive(new_dentry)) {
>  		if (d_is_dir(new_dentry))
> @@ -561,7 +565,7 @@ const struct inode_operations hfsplus_dir_inode_operations = {
>  	.rmdir			= hfsplus_rmdir,
>  	.symlink		= hfsplus_symlink,
>  	.mknod			= hfsplus_mknod,
> -	.rename			= hfsplus_rename,
> +	.rename2		= hfsplus_rename,
>  	.setxattr		= generic_setxattr,
>  	.getxattr		= generic_getxattr,
>  	.listxattr		= hfsplus_listxattr,
> diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
> index bb8d67e2740a..3c5c1a75569d 100644
> --- a/fs/hpfs/namei.c
> +++ b/fs/hpfs/namei.c
> @@ -507,7 +507,8 @@ const struct address_space_operations hpfs_symlink_aops = {
>  };
>  	
>  static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
> -		struct inode *new_dir, struct dentry *new_dentry)
> +		       struct inode *new_dir, struct dentry *new_dentry,
> +		       unsigned int flags)
>  {
>  	const unsigned char *old_name = old_dentry->d_name.name;
>  	unsigned old_len = old_dentry->d_name.len;
> @@ -524,6 +525,9 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	struct fnode *fnode;
>  	int err;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	if ((err = hpfs_chk_name(new_name, &new_len))) return err;
>  	err = 0;
>  	hpfs_adjust_length(old_name, &old_len);
> @@ -618,6 +622,6 @@ const struct inode_operations hpfs_dir_iops =
>  	.mkdir		= hpfs_mkdir,
>  	.rmdir		= hpfs_rmdir,
>  	.mknod		= hpfs_mknod,
> -	.rename		= hpfs_rename,
> +	.rename2	= hpfs_rename,
>  	.setattr	= hpfs_setattr,
>  };
> diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
> index 30eb33ff8189..11e711b12ccf 100644
> --- a/fs/jffs2/dir.c
> +++ b/fs/jffs2/dir.c
> @@ -35,7 +35,8 @@ static int jffs2_mkdir (struct inode *,struct dentry *,umode_t);
>  static int jffs2_rmdir (struct inode *,struct dentry *);
>  static int jffs2_mknod (struct inode *,struct dentry *,umode_t,dev_t);
>  static int jffs2_rename (struct inode *, struct dentry *,
> -			 struct inode *, struct dentry *);
> +			 struct inode *, struct dentry *,
> +			 unsigned int);
>  
>  const struct file_operations jffs2_dir_operations =
>  {
> @@ -57,7 +58,7 @@ const struct inode_operations jffs2_dir_inode_operations =
>  	.mkdir =	jffs2_mkdir,
>  	.rmdir =	jffs2_rmdir,
>  	.mknod =	jffs2_mknod,
> -	.rename =	jffs2_rename,
> +	.rename2 =	jffs2_rename,
>  	.get_acl =	jffs2_get_acl,
>  	.set_acl =	jffs2_set_acl,
>  	.setattr =	jffs2_setattr,
> @@ -759,7 +760,8 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, umode_t mode
>  }
>  
>  static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
> -			 struct inode *new_dir_i, struct dentry *new_dentry)
> +			 struct inode *new_dir_i, struct dentry *new_dentry,
> +			 unsigned int flags)
>  {
>  	int ret;
>  	struct jffs2_sb_info *c = JFFS2_SB_INFO(old_dir_i->i_sb);
> @@ -767,6 +769,9 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
>  	uint8_t type;
>  	uint32_t now;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	/* The VFS will check for us and prevent trying to rename a
>  	 * file over a directory and vice versa, but if it's a directory,
>  	 * the VFS can't check whether the victim is empty. The filesystem
> diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
> index 814b0c58016c..ee1aa32f7c24 100644
> --- a/fs/jfs/namei.c
> +++ b/fs/jfs/namei.c
> @@ -1078,7 +1078,8 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
>   * FUNCTION:	rename a file or directory
>   */
>  static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
> -	       struct inode *new_dir, struct dentry *new_dentry)
> +		      struct inode *new_dir, struct dentry *new_dentry,
> +		      unsigned int flags)
>  {
>  	struct btstack btstack;
>  	ino_t ino;
> @@ -1097,6 +1098,8 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	s64 new_size = 0;
>  	int commit_flag;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
>  
>  	jfs_info("jfs_rename: %pd %pd", old_dentry, new_dentry);
>  
> @@ -1536,7 +1539,7 @@ const struct inode_operations jfs_dir_inode_operations = {
>  	.mkdir		= jfs_mkdir,
>  	.rmdir		= jfs_rmdir,
>  	.mknod		= jfs_mknod,
> -	.rename		= jfs_rename,
> +	.rename2	= jfs_rename,
>  	.setxattr	= generic_setxattr,
>  	.getxattr	= generic_getxattr,
>  	.listxattr	= jfs_listxattr,
> diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c
> index 9568064ecadf..57f2da17a905 100644
> --- a/fs/logfs/dir.c
> +++ b/fs/logfs/dir.c
> @@ -718,8 +718,12 @@ out:
>  }
>  
>  static int logfs_rename(struct inode *old_dir, struct dentry *old_dentry,
> -			struct inode *new_dir, struct dentry *new_dentry)
> +			struct inode *new_dir, struct dentry *new_dentry,
> +			unsigned int flags)
>  {
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	if (d_really_is_positive(new_dentry))
>  		return logfs_rename_target(old_dir, old_dentry,
>  					   new_dir, new_dentry);
> @@ -783,7 +787,7 @@ const struct inode_operations logfs_dir_iops = {
>  	.lookup		= logfs_lookup,
>  	.mkdir		= logfs_mkdir,
>  	.mknod		= logfs_mknod,
> -	.rename		= logfs_rename,
> +	.rename2	= logfs_rename,
>  	.rmdir		= logfs_rmdir,
>  	.symlink	= logfs_symlink,
>  	.unlink		= logfs_unlink,
> diff --git a/fs/minix/namei.c b/fs/minix/namei.c
> index 2887d1d95ce2..6dc210c0e3ce 100644
> --- a/fs/minix/namei.c
> +++ b/fs/minix/namei.c
> @@ -185,7 +185,8 @@ static int minix_rmdir(struct inode * dir, struct dentry *dentry)
>  }
>  
>  static int minix_rename(struct inode * old_dir, struct dentry *old_dentry,
> -			   struct inode * new_dir, struct dentry *new_dentry)
> +			struct inode * new_dir, struct dentry *new_dentry,
> +			unsigned int flags)
>  {
>  	struct inode * old_inode = d_inode(old_dentry);
>  	struct inode * new_inode = d_inode(new_dentry);
> @@ -195,6 +196,9 @@ static int minix_rename(struct inode * old_dir, struct dentry *old_dentry,
>  	struct minix_dir_entry * old_de;
>  	int err = -ENOENT;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	old_de = minix_find_entry(old_dentry, &old_page);
>  	if (!old_de)
>  		goto out;
> @@ -264,7 +268,7 @@ const struct inode_operations minix_dir_inode_operations = {
>  	.mkdir		= minix_mkdir,
>  	.rmdir		= minix_rmdir,
>  	.mknod		= minix_mknod,
> -	.rename		= minix_rename,
> +	.rename2	= minix_rename,
>  	.getattr	= minix_getattr,
>  	.tmpfile	= minix_tmpfile,
>  };
> diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
> index dbcf1dc93a51..8540c13ef374 100644
> --- a/fs/nilfs2/namei.c
> +++ b/fs/nilfs2/namei.c
> @@ -350,7 +350,8 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry)
>  }
>  
>  static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
> -			struct inode *new_dir,	struct dentry *new_dentry)
> +			struct inode *new_dir,	struct dentry *new_dentry,
> +			unsigned int flags)
>  {
>  	struct inode *old_inode = d_inode(old_dentry);
>  	struct inode *new_inode = d_inode(new_dentry);
> @@ -361,6 +362,9 @@ static int nilfs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	struct nilfs_transaction_info ti;
>  	int err;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	err = nilfs_transaction_begin(old_dir->i_sb, &ti, 1);
>  	if (unlikely(err))
>  		return err;
> @@ -552,7 +556,7 @@ const struct inode_operations nilfs_dir_inode_operations = {
>  	.mkdir		= nilfs_mkdir,
>  	.rmdir		= nilfs_rmdir,
>  	.mknod		= nilfs_mknod,
> -	.rename		= nilfs_rename,
> +	.rename2	= nilfs_rename,
>  	.setattr	= nilfs_setattr,
>  	.permission	= nilfs_permission,
>  	.fiemap		= nilfs_fiemap,
> diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
> index c8cbf3b60645..417511bbe362 100644
> --- a/fs/omfs/dir.c
> +++ b/fs/omfs/dir.c
> @@ -371,12 +371,16 @@ static bool omfs_fill_chain(struct inode *dir, struct dir_context *ctx,
>  }
>  
>  static int omfs_rename(struct inode *old_dir, struct dentry *old_dentry,
> -		struct inode *new_dir, struct dentry *new_dentry)
> +		       struct inode *new_dir, struct dentry *new_dentry,
> +		       unsigned int flags)
>  {
>  	struct inode *new_inode = d_inode(new_dentry);
>  	struct inode *old_inode = d_inode(old_dentry);
>  	int err;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	if (new_inode) {
>  		/* overwriting existing file/dir */
>  		err = omfs_remove(new_dir, new_dentry);
> @@ -444,7 +448,7 @@ static int omfs_readdir(struct file *file, struct dir_context *ctx)
>  const struct inode_operations omfs_dir_inops = {
>  	.lookup = omfs_lookup,
>  	.mkdir = omfs_mkdir,
> -	.rename = omfs_rename,
> +	.rename2 = omfs_rename,
>  	.create = omfs_create,
>  	.unlink = omfs_remove,
>  	.rmdir = omfs_remove,
> diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
> index 8a36696d6df9..21b4b7138985 100644
> --- a/fs/reiserfs/namei.c
> +++ b/fs/reiserfs/namei.c
> @@ -1306,7 +1306,8 @@ static void set_ino_in_dir_entry(struct reiserfs_dir_entry *de,
>   * get_empty_nodes or its clones
>   */
>  static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
> -			   struct inode *new_dir, struct dentry *new_dentry)
> +			   struct inode *new_dir, struct dentry *new_dentry,
> +			   unsigned int flags)
>  {
>  	int retval;
>  	INITIALIZE_PATH(old_entry_path);
> @@ -1321,6 +1322,9 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	unsigned long savelink = 1;
>  	struct timespec ctime;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	/*
>  	 * three balancings: (1) old name removal, (2) new name insertion
>  	 * and (3) maybe "save" link insertion
> @@ -1648,7 +1652,7 @@ const struct inode_operations reiserfs_dir_inode_operations = {
>  	.mkdir = reiserfs_mkdir,
>  	.rmdir = reiserfs_rmdir,
>  	.mknod = reiserfs_mknod,
> -	.rename = reiserfs_rename,
> +	.rename2 = reiserfs_rename,
>  	.setattr = reiserfs_setattr,
>  	.setxattr = generic_setxattr,
>  	.getxattr = generic_getxattr,
> diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c
> index a42de45ce40d..765d79de1217 100644
> --- a/fs/sysv/namei.c
> +++ b/fs/sysv/namei.c
> @@ -206,7 +206,8 @@ static int sysv_rmdir(struct inode * dir, struct dentry * dentry)
>   * higher-level routines.
>   */
>  static int sysv_rename(struct inode * old_dir, struct dentry * old_dentry,
> -		  struct inode * new_dir, struct dentry * new_dentry)
> +		       struct inode * new_dir, struct dentry * new_dentry,
> +		       unsigned int flags)
>  {
>  	struct inode * old_inode = d_inode(old_dentry);
>  	struct inode * new_inode = d_inode(new_dentry);
> @@ -216,6 +217,9 @@ static int sysv_rename(struct inode * old_dir, struct dentry * old_dentry,
>  	struct sysv_dir_entry * old_de;
>  	int err = -ENOENT;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	old_de = sysv_find_entry(old_dentry, &old_page);
>  	if (!old_de)
>  		goto out;
> @@ -285,6 +289,6 @@ const struct inode_operations sysv_dir_inode_operations = {
>  	.mkdir		= sysv_mkdir,
>  	.rmdir		= sysv_rmdir,
>  	.mknod		= sysv_mknod,
> -	.rename		= sysv_rename,
> +	.rename2	= sysv_rename,
>  	.getattr	= sysv_getattr,
>  };
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index 4b86d3a738e1..23d1ebabc688 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -966,7 +966,8 @@ static void unlock_3_inodes(struct inode *inode1, struct inode *inode2,
>  }
>  
>  static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
> -			struct inode *new_dir, struct dentry *new_dentry)
> +			struct inode *new_dir, struct dentry *new_dentry,
> +			unsigned int flags)
>  {
>  	struct ubifs_info *c = old_dir->i_sb->s_fs_info;
>  	struct inode *old_inode = d_inode(old_dentry);
> @@ -984,6 +985,9 @@ static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	struct timespec time;
>  	unsigned int uninitialized_var(saved_nlink);
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	/*
>  	 * Budget request settings: deletion direntry, new direntry, removing
>  	 * the old inode, and changing old and new parent directory inodes.
> @@ -1179,7 +1183,7 @@ const struct inode_operations ubifs_dir_inode_operations = {
>  	.mkdir       = ubifs_mkdir,
>  	.rmdir       = ubifs_rmdir,
>  	.mknod       = ubifs_mknod,
> -	.rename      = ubifs_rename,
> +	.rename2     = ubifs_rename,
>  	.setattr     = ubifs_setattr,
>  	.getattr     = ubifs_getattr,
>  	.setxattr    = generic_setxattr,
> diff --git a/fs/udf/namei.c b/fs/udf/namei.c
> index c3e5c9679371..ca2ec0061802 100644
> --- a/fs/udf/namei.c
> +++ b/fs/udf/namei.c
> @@ -1093,7 +1093,8 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
>   * higher-level routines.
>   */
>  static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
> -		      struct inode *new_dir, struct dentry *new_dentry)
> +		      struct inode *new_dir, struct dentry *new_dentry,
> +		      unsigned int flags)
>  {
>  	struct inode *old_inode = d_inode(old_dentry);
>  	struct inode *new_inode = d_inode(new_dentry);
> @@ -1105,6 +1106,9 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	struct kernel_lb_addr tloc;
>  	struct udf_inode_info *old_iinfo = UDF_I(old_inode);
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	ofi = udf_find_entry(old_dir, &old_dentry->d_name, &ofibh, &ocfi);
>  	if (IS_ERR(ofi)) {
>  		retval = PTR_ERR(ofi);
> @@ -1353,6 +1357,6 @@ const struct inode_operations udf_dir_inode_operations = {
>  	.mkdir				= udf_mkdir,
>  	.rmdir				= udf_rmdir,
>  	.mknod				= udf_mknod,
> -	.rename				= udf_rename,
> +	.rename2			= udf_rename,
>  	.tmpfile			= udf_tmpfile,
>  };
> diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
> index a1559f762805..719c9c9b83d8 100644
> --- a/fs/ufs/namei.c
> +++ b/fs/ufs/namei.c
> @@ -245,7 +245,8 @@ static int ufs_rmdir (struct inode * dir, struct dentry *dentry)
>  }
>  
>  static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry,
> -		      struct inode *new_dir, struct dentry *new_dentry)
> +		      struct inode *new_dir, struct dentry *new_dentry,
> +		      unsigned int flags)
>  {
>  	struct inode *old_inode = d_inode(old_dentry);
>  	struct inode *new_inode = d_inode(new_dentry);
> @@ -255,6 +256,9 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	struct ufs_dir_entry *old_de;
>  	int err = -ENOENT;
>  
> +	if (flags & ~RENAME_NOREPLACE)
> +		return -EINVAL;
> +
>  	old_de = ufs_find_entry(old_dir, &old_dentry->d_name, &old_page);
>  	if (!old_de)
>  		goto out;
> @@ -333,5 +337,5 @@ const struct inode_operations ufs_dir_inode_operations = {
>  	.mkdir		= ufs_mkdir,
>  	.rmdir		= ufs_rmdir,
>  	.mknod		= ufs_mknod,
> -	.rename		= ufs_rename,
> +	.rename2	= ufs_rename,
>  };
> -- 
> 2.5.5
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

end of thread, other threads:[~2016-09-08 13:55 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-23 14:05 [PATCH 0/7] vfs: finish rename -> rename2 conversion Miklos Szeredi
2016-08-23 14:05 ` [PATCH 1/7] ncpfs: fix unused variable warning Miklos Szeredi
2016-08-23 14:05 ` [PATCH 2/7] fs: support RENAME_NOREPLACE for local filesystems Miklos Szeredi
2016-08-23 21:48   ` Richard Weinberger
2016-08-25 12:52   ` Bob Copeland
2016-09-08 13:55   ` Jan Kara
2016-08-23 14:05 ` [PATCH 3/7] libfs: support RENAME_NOREPLACE in simple_rename() Miklos Szeredi
2016-08-23 14:47   ` Greg Kroah-Hartman
2016-08-23 14:05 ` [PATCH 4/7] fs: make remaining filesystems use .rename2 Miklos Szeredi
2016-08-23 14:47   ` Greg Kroah-Hartman
2016-08-23 17:30     ` Mike Marshall
2016-08-23 16:24   ` Boaz Harrosh
2016-08-23 16:29     ` Boaz Harrosh
2016-08-23 14:05 ` [PATCH 5/7] vfs: remove unused i_op->rename Miklos Szeredi
2016-08-23 14:05 ` [PATCH 6/7] fs: rename "rename2" i_op to "rename" Miklos Szeredi
2016-08-23 14:05 ` [PATCH 7/7] vfs: add note about i_op->rename changes to porting Miklos Szeredi
2016-08-23 15:36 ` [PATCH 4/7] fs: make remaining filesystems use .rename2 David Howells

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).