Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/viro/vfs

Pull more vfs updates from Al Viro:
 ">rename2() work from Miklos + current_time() from Deepa"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  fs: Replace current_fs_time() with current_time()
  fs: Replace CURRENT_TIME_SEC with current_time() for inode timestamps
  fs: Replace CURRENT_TIME with current_time() for inode timestamps
  fs: proc: Delete inode time initializations in proc_alloc_inode()
  vfs: Add current_time() api
  vfs: add note about i_op->rename changes to porting
  fs: rename "rename2" i_op to "rename"
  vfs: remove unused i_op->rename
  fs: make remaining filesystems use .rename2
  libfs: support RENAME_NOREPLACE in simple_rename()
  fs: support RENAME_NOREPLACE for local filesystems
  ncpfs: fix unused variable warning
  • Loading branch information
torvalds committed Oct 11, 2016
2 parents 35ff96d + 3873691 commit 101105b
Show file tree
Hide file tree
Showing 182 changed files with 587 additions and 449 deletions.
8 changes: 2 additions & 6 deletions Documentation/filesystems/Locking
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ prototypes:
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);
const char *(*get_link) (struct dentry *, struct inode *, void **);
Expand Down Expand Up @@ -80,8 +78,7 @@ symlink: yes
mkdir: yes
unlink: yes (both)
rmdir: yes (both) (see below)
rename: yes (all) (see below)
rename2: yes (all) (see below)
rename: yes (all) (see below)
readlink: no
get_link: no
setattr: yes
Expand All @@ -97,8 +94,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 ->rename() has (per-superblock) ->s_vfs_rename_sem.

See Documentation/filesystems/directory-locking for more detailed discussion
of the locking scheme for directory operations.
Expand Down
2 changes: 1 addition & 1 deletion Documentation/filesystems/directory-locking
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions Documentation/filesystems/porting
Original file line number Diff line number Diff line change
Expand Up @@ -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.
9 changes: 2 additions & 7 deletions Documentation/filesystems/vfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,6 @@ struct inode_operations {
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);
const char *(*get_link) (struct dentry *, struct inode *,
Expand Down Expand Up @@ -442,11 +440,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
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/cell/spufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ spufs_new_inode(struct super_block *sb, umode_t mode)
inode->i_mode = mode;
inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid();
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
out:
return inode;
}
Expand Down
4 changes: 2 additions & 2 deletions arch/s390/hypfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static void hypfs_update_update(struct super_block *sb)
struct inode *inode = d_inode(sb_info->update_file);

sb_info->last_update = get_seconds();
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
}

/* directory tree removal functions */
Expand Down Expand Up @@ -99,7 +99,7 @@ static struct inode *hypfs_make_inode(struct super_block *sb, umode_t mode)
ret->i_mode = mode;
ret->i_uid = hypfs_info->uid;
ret->i_gid = hypfs_info->gid;
ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
ret->i_atime = ret->i_mtime = ret->i_ctime = current_time(ret);
if (S_ISDIR(mode))
set_nlink(ret, 2);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/sonypi.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,

if (ret > 0) {
struct inode *inode = file_inode(file);
inode->i_atime = current_fs_time(inode->i_sb);
inode->i_atime = current_time(inode);
}

return ret;
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/hw/qib/qib_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static int qibfs_mknod(struct inode *dir, struct dentry *dentry,
inode->i_uid = GLOBAL_ROOT_UID;
inode->i_gid = GLOBAL_ROOT_GID;
inode->i_blocks = 0;
inode->i_atime = CURRENT_TIME;
inode->i_atime = current_time(inode);
inode->i_mtime = inode->i_atime;
inode->i_ctime = inode->i_atime;
inode->i_private = data;
Expand Down
2 changes: 1 addition & 1 deletion drivers/misc/ibmasm/ibmasmfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode)
if (ret) {
ret->i_ino = get_next_ino();
ret->i_mode = mode;
ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
ret->i_atime = ret->i_mtime = ret->i_ctime = current_time(ret);
}
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/oprofile/oprofilefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static struct inode *oprofilefs_get_inode(struct super_block *sb, int mode)
if (inode) {
inode->i_ino = get_next_ino();
inode->i_mode = mode;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
}
return inode;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/platform/x86/sony-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -4116,7 +4116,7 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,

if (ret > 0) {
struct inode *inode = file_inode(file);
inode->i_atime = current_fs_time(inode->i_sb);
inode->i_atime = current_time(inode);
}

return ret;
Expand Down
8 changes: 6 additions & 2 deletions drivers/staging/lustre/lustre/llite/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,13 +1097,17 @@ static int ll_link(struct dentry *old_dentry, struct inode *dir,
}

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,
Expand Down Expand Up @@ -1148,7 +1152,7 @@ const struct inode_operations ll_dir_inode_operations = {
.rmdir = ll_rmdir,
.symlink = ll_symlink,
.link = ll_link,
.rename = ll_rename,
.rename = ll_rename,
.setattr = ll_setattr,
.getattr = ll_getattr,
.permission = ll_inode_permission,
Expand Down
18 changes: 9 additions & 9 deletions drivers/usb/core/devio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2409,21 +2409,21 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
snoop(&dev->dev, "%s: CONTROL\n", __func__);
ret = proc_control(ps, p);
if (ret >= 0)
inode->i_mtime = CURRENT_TIME;
inode->i_mtime = current_time(inode);
break;

case USBDEVFS_BULK:
snoop(&dev->dev, "%s: BULK\n", __func__);
ret = proc_bulk(ps, p);
if (ret >= 0)
inode->i_mtime = CURRENT_TIME;
inode->i_mtime = current_time(inode);
break;

case USBDEVFS_RESETEP:
snoop(&dev->dev, "%s: RESETEP\n", __func__);
ret = proc_resetep(ps, p);
if (ret >= 0)
inode->i_mtime = CURRENT_TIME;
inode->i_mtime = current_time(inode);
break;

case USBDEVFS_RESET:
Expand All @@ -2435,7 +2435,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
snoop(&dev->dev, "%s: CLEAR_HALT\n", __func__);
ret = proc_clearhalt(ps, p);
if (ret >= 0)
inode->i_mtime = CURRENT_TIME;
inode->i_mtime = current_time(inode);
break;

case USBDEVFS_GETDRIVER:
Expand All @@ -2462,22 +2462,22 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
snoop(&dev->dev, "%s: SUBMITURB\n", __func__);
ret = proc_submiturb(ps, p);
if (ret >= 0)
inode->i_mtime = CURRENT_TIME;
inode->i_mtime = current_time(inode);
break;

#ifdef CONFIG_COMPAT
case USBDEVFS_CONTROL32:
snoop(&dev->dev, "%s: CONTROL32\n", __func__);
ret = proc_control_compat(ps, p);
if (ret >= 0)
inode->i_mtime = CURRENT_TIME;
inode->i_mtime = current_time(inode);
break;

case USBDEVFS_BULK32:
snoop(&dev->dev, "%s: BULK32\n", __func__);
ret = proc_bulk_compat(ps, p);
if (ret >= 0)
inode->i_mtime = CURRENT_TIME;
inode->i_mtime = current_time(inode);
break;

case USBDEVFS_DISCSIGNAL32:
Expand All @@ -2489,7 +2489,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
snoop(&dev->dev, "%s: SUBMITURB32\n", __func__);
ret = proc_submiturb_compat(ps, p);
if (ret >= 0)
inode->i_mtime = CURRENT_TIME;
inode->i_mtime = current_time(inode);
break;

case USBDEVFS_IOCTL32:
Expand Down Expand Up @@ -2552,7 +2552,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
done:
usb_unlock_device(dev);
if (ret >= 0)
inode->i_atime = CURRENT_TIME;
inode->i_atime = current_time(inode);
return ret;
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/usb/gadget/function/f_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1196,15 +1196,15 @@ ffs_sb_make_inode(struct super_block *sb, void *data,
inode = new_inode(sb);

if (likely(inode)) {
struct timespec current_time = CURRENT_TIME;
struct timespec ts = current_time(inode);

inode->i_ino = get_next_ino();
inode->i_mode = perms->mode;
inode->i_uid = perms->uid;
inode->i_gid = perms->gid;
inode->i_atime = current_time;
inode->i_mtime = current_time;
inode->i_ctime = current_time;
inode->i_atime = ts;
inode->i_mtime = ts;
inode->i_ctime = ts;
inode->i_private = data;
if (fops)
inode->i_fop = fops;
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/legacy/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1913,7 +1913,7 @@ gadgetfs_make_inode (struct super_block *sb,
inode->i_uid = make_kuid(&init_user_ns, default_uid);
inode->i_gid = make_kgid(&init_user_ns, default_gid);
inode->i_atime = inode->i_mtime = inode->i_ctime
= CURRENT_TIME;
= current_time(inode);
inode->i_private = data;
inode->i_fop = fops;
}
Expand Down
3 changes: 2 additions & 1 deletion fs/9p/v9fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses,
inode_init_owner(inode, NULL, mode);
inode->i_blocks = 0;
inode->i_rdev = rdev;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
inode->i_mapping->a_ops = &v9fs_addr_operations;

switch (mode & S_IFMT) {
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion fs/adfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ adfs_adfs2unix_time(struct timespec *tv, struct inode *inode)
return;

cur_time:
*tv = CURRENT_TIME;
*tv = current_time(inode);
return;

too_early:
Expand Down
3 changes: 2 additions & 1 deletion fs/affs/affs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
6 changes: 3 additions & 3 deletions fs/affs/amigaffs.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ affs_insert_hash(struct inode *dir, struct buffer_head *bh)
mark_buffer_dirty_inode(dir_bh, dir);
affs_brelse(dir_bh);

dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
dir->i_mtime = dir->i_ctime = current_time(dir);
dir->i_version++;
mark_inode_dirty(dir);

Expand Down Expand Up @@ -112,7 +112,7 @@ affs_remove_hash(struct inode *dir, struct buffer_head *rem_bh)

affs_brelse(bh);

dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
dir->i_mtime = dir->i_ctime = current_time(dir);
dir->i_version++;
mark_inode_dirty(dir);

Expand Down Expand Up @@ -313,7 +313,7 @@ affs_remove_header(struct dentry *dentry)
else
clear_nlink(inode);
affs_unlock_link(inode);
inode->i_ctime = CURRENT_TIME_SEC;
inode->i_ctime = current_time(inode);
mark_inode_dirty(inode);

done:
Expand Down
2 changes: 1 addition & 1 deletion fs/affs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ affs_new_inode(struct inode *dir)
inode->i_gid = current_fsgid();
inode->i_ino = block;
set_nlink(inode, 1);
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
atomic_set(&AFFS_I(inode)->i_opencnt, 0);
AFFS_I(inode)->i_blkcnt = 0;
AFFS_I(inode)->i_lc = NULL;
Expand Down
6 changes: 5 additions & 1 deletion fs/affs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading

0 comments on commit 101105b

Please sign in to comment.