From 1cd66c93ba8cdb873258f58ae6a817b28a02bcc3 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Tue, 27 Sep 2016 11:03:58 +0200 Subject: fs: make remaining filesystems use .rename2 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, kernfs, lustre, ncpfs, nfs, ocfs2, orangefs. After this, we can get rid of the duplicate interfaces for rename. Signed-off-by: Miklos Szeredi Acked-by: Greg Kroah-Hartman Acked-by: David Howells [AFS] Acked-by: Mike Marshall Cc: Eric Van Hensbergen Cc: Ilya Dryomov Cc: Jan Harkes Cc: Tyler Hicks Cc: Oleg Drokin Cc: Trond Myklebust Cc: Mark Fasheh --- fs/ceph/dir.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'fs/ceph') diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index df4b3e6fa563..cef8252af38a 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 = { -- cgit From 2773bf00aeb9bf39e022463272a61dd0ec9f55f4 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Tue, 27 Sep 2016 11:03:58 +0200 Subject: fs: rename "rename2" i_op to "rename" 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 --- fs/ceph/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fs/ceph') diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index cef8252af38a..291a4d59c5f7 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 = { -- cgit