From f03b8ad8d38634d13e802165cc15917481b47835 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Tue, 27 Sep 2016 11:03:57 +0200 Subject: fs: support RENAME_NOREPLACE for local filesystems 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, exofs, ext2, hfs, hfsplus, jffs2, jfs, logfs, minix, msdos, nilfs2, omfs, reiserfs, sysvfs, ubifs, udf, ufs, vfat. Signed-off-by: Miklos Szeredi Acked-by: Boaz Harrosh Acked-by: Richard Weinberger Acked-by: Bob Copeland Acked-by: Jan Kara Cc: Theodore Ts'o Cc: Jaegeuk Kim Cc: OGAWA Hirofumi Cc: Mikulas Patocka Cc: David Woodhouse Cc: Dave Kleikamp Cc: Ryusuke Konishi Cc: Christoph Hellwig --- fs/exofs/namei.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'fs/exofs') diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c index 622a686bb08b..ddf343259f13 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 & ~RENAME_NOREPLACE) + 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, }; -- 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/exofs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/exofs') diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c index ddf343259f13..53d838200cc9 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, }; -- cgit From 078cd8279e659989b103359bb22373cc79445bde Mon Sep 17 00:00:00 2001 From: Deepa Dinamani Date: Wed, 14 Sep 2016 07:48:04 -0700 Subject: fs: Replace CURRENT_TIME with current_time() for inode timestamps CURRENT_TIME macro is not appropriate for filesystems as it doesn't use the right granularity for filesystem timestamps. Use current_time() instead. CURRENT_TIME is also not y2038 safe. This is also in preparation for the patch that transitions vfs timestamps to use 64 bit time and hence make them y2038 safe. As part of the effort current_time() will be extended to do range checks. Hence, it is necessary for all file system timestamps to use current_time(). Also, current_time() will be transitioned along with vfs to be y2038 safe. Note that whenever a single call to current_time() is used to change timestamps in different inodes, it is because they share the same time granularity. Signed-off-by: Deepa Dinamani Reviewed-by: Arnd Bergmann Acked-by: Felipe Balbi Acked-by: Steven Whitehouse Acked-by: Ryusuke Konishi Acked-by: David Sterba Signed-off-by: Al Viro --- fs/exofs/dir.c | 6 +++--- fs/exofs/inode.c | 4 ++-- fs/exofs/namei.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'fs/exofs') diff --git a/fs/exofs/dir.c b/fs/exofs/dir.c index f69a1b5826a5..79101651fe9e 100644 --- a/fs/exofs/dir.c +++ b/fs/exofs/dir.c @@ -416,7 +416,7 @@ int exofs_set_link(struct inode *dir, struct exofs_dir_entry *de, if (likely(!err)) err = exofs_commit_chunk(page, pos, len); exofs_put_page(page); - dir->i_mtime = dir->i_ctime = CURRENT_TIME; + dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); return err; } @@ -503,7 +503,7 @@ got_it: de->inode_no = cpu_to_le64(inode->i_ino); exofs_set_de_type(de, inode); err = exofs_commit_chunk(page, pos, rec_len); - dir->i_mtime = dir->i_ctime = CURRENT_TIME; + dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); sbi->s_numfiles++; @@ -554,7 +554,7 @@ int exofs_delete_entry(struct exofs_dir_entry *dir, struct page *page) dir->inode_no = 0; if (likely(!err)) err = exofs_commit_chunk(page, pos, to - from); - inode->i_ctime = inode->i_mtime = CURRENT_TIME; + inode->i_ctime = inode->i_mtime = current_time(inode); mark_inode_dirty(inode); sbi->s_numfiles--; out: diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c index 9dc4c6dbf3c9..4327f71d302d 100644 --- a/fs/exofs/inode.c +++ b/fs/exofs/inode.c @@ -1007,7 +1007,7 @@ static int _do_truncate(struct inode *inode, loff_t newsize) struct exofs_sb_info *sbi = inode->i_sb->s_fs_info; int ret; - inode->i_mtime = inode->i_ctime = CURRENT_TIME; + inode->i_mtime = inode->i_ctime = current_time(inode); ret = ore_truncate(&sbi->layout, &oi->oc, (u64)newsize); if (likely(!ret)) @@ -1313,7 +1313,7 @@ struct inode *exofs_new_inode(struct inode *dir, umode_t mode) inode_init_owner(inode, dir, mode); inode->i_ino = sbi->s_nextid++; inode->i_blkbits = EXOFS_BLKSHIFT; - inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; + inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); oi->i_commit_size = inode->i_size = 0; spin_lock(&sbi->s_next_gen_lock); inode->i_generation = sbi->s_next_generation++; diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c index 622a686bb08b..80c8114d76a6 100644 --- a/fs/exofs/namei.c +++ b/fs/exofs/namei.c @@ -142,7 +142,7 @@ static int exofs_link(struct dentry *old_dentry, struct inode *dir, { struct inode *inode = d_inode(old_dentry); - inode->i_ctime = CURRENT_TIME; + inode->i_ctime = current_time(inode); inode_inc_link_count(inode); ihold(inode); @@ -261,7 +261,7 @@ static int exofs_rename(struct inode *old_dir, struct dentry *old_dentry, if (!new_de) goto out_dir; err = exofs_set_link(new_dir, new_de, new_page, old_inode); - new_inode->i_ctime = CURRENT_TIME; + new_inode->i_ctime = current_time(new_inode); if (dir_de) drop_nlink(new_inode); inode_dec_link_count(new_inode); @@ -275,7 +275,7 @@ static int exofs_rename(struct inode *old_dir, struct dentry *old_dentry, inode_inc_link_count(new_dir); } - old_inode->i_ctime = CURRENT_TIME; + old_inode->i_ctime = current_time(old_inode); exofs_delete_entry(old_de, old_page); mark_inode_dirty(old_inode); -- cgit