From bf7fa5ebc459c6775048f13657063b38ff210354 Mon Sep 17 00:00:00 2001 From: Ksawlii Date: Tue, 19 Nov 2024 13:45:08 +0100 Subject: [PATCH] Revert "namei: introduce struct renamedata" This reverts commit 01eed6c908d441b45cc57dc06200b99cf63e1640. --- fs/cachefiles/namei.c | 9 ++------- fs/ecryptfs/inode.c | 10 +++------- fs/namei.c | 21 ++++++--------------- fs/nfsd/vfs.c | 1 + fs/overlayfs/overlayfs.h | 9 +-------- include/linux/fs.h | 12 +----------- 6 files changed, 14 insertions(+), 48 deletions(-) diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index 7b987de0b..ecc8ecbbf 100755 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -412,14 +412,9 @@ try_again: if (ret < 0) { cachefiles_io_error(cache, "Rename security error %d", ret); } else { - struct renamedata rd = { - .old_dir = d_inode(dir), - .old_dentry = rep, - .new_dir = d_inode(cache->graveyard), - .new_dentry = grave, - }; trace_cachefiles_rename(object, rep, grave, why); - ret = vfs_rename(&rd); + ret = vfs_rename(d_inode(dir), rep, + d_inode(cache->graveyard), grave, NULL, 0); if (ret != 0 && ret != -ENOMEM) cachefiles_io_error(cache, "Rename failed with error %d", ret); diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index cd1a60a31..7777bb6f6 100755 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -598,7 +598,6 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry, struct dentry *lower_new_dir_dentry; struct dentry *trap; struct inode *target_inode; - struct renamedata rd = {}; if (flags) return -EINVAL; @@ -628,12 +627,9 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry, rc = -ENOTEMPTY; goto out_lock; } - - rd.old_dir = d_inode(lower_old_dir_dentry); - rd.old_dentry = lower_old_dentry; - rd.new_dir = d_inode(lower_new_dir_dentry); - rd.new_dentry = lower_new_dentry; - rc = vfs_rename(&rd); + rc = vfs_rename(d_inode(lower_old_dir_dentry), lower_old_dentry, + d_inode(lower_new_dir_dentry), lower_new_dentry, + NULL, 0); if (rc) goto out_lock; if (target_inode) diff --git a/fs/namei.c b/fs/namei.c index 8d0b16598..9398c90db 100755 --- a/fs/namei.c +++ b/fs/namei.c @@ -4404,14 +4404,11 @@ SYSCALL_DEFINE2(link, const char __user *, oldname, const char __user *, newname * ->i_mutex on parents, which works but leads to some truly excessive * locking]. */ -int vfs_rename(struct renamedata *rd) +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry, + struct inode **delegated_inode, unsigned int flags) { int error; - struct inode *old_dir = rd->old_dir, *new_dir = rd->new_dir; - struct dentry *old_dentry = rd->old_dentry; - struct dentry *new_dentry = rd->new_dentry; - struct inode **delegated_inode = rd->delegated_inode; - unsigned int flags = rd->flags; bool is_dir = d_is_dir(old_dentry); struct inode *source = old_dentry->d_inode; struct inode *target = new_dentry->d_inode; @@ -4568,7 +4565,6 @@ EXPORT_SYMBOL_NS(vfs_rename, ANDROID_GKI_VFS_EXPORT_ONLY); int do_renameat2(int olddfd, struct filename *from, int newdfd, struct filename *to, unsigned int flags) { - struct renamedata rd; struct dentry *old_dentry, *new_dentry; struct dentry *trap; struct path old_path, new_path; @@ -4672,14 +4668,9 @@ retry_deleg: &new_path, new_dentry, flags); if (error) goto exit5; - - rd.old_dir = old_path.dentry->d_inode; - rd.old_dentry = old_dentry; - rd.new_dir = new_path.dentry->d_inode; - rd.new_dentry = new_dentry; - rd.delegated_inode = &delegated_inode; - rd.flags = flags; - error = vfs_rename(&rd); + error = vfs_rename(old_path.dentry->d_inode, old_dentry, + new_path.dentry->d_inode, new_dentry, + &delegated_inode, flags); exit5: dput(new_dentry); exit4: diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index e10c00fe5..737fe0db9 100755 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1809,6 +1809,7 @@ retry: if (!nfsd_wait_for_delegreturn(rqstp, d_inode(odentry))) break; } + host_err = vfs_rename(fdir, odentry, tdir, ndentry, NULL, 0); if (!host_err) { host_err = commit_metadata(tfhp); if (!host_err) diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 520a6bdaf..a9f9923a7 100755 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -214,16 +214,9 @@ static inline int ovl_do_rename(struct inode *olddir, struct dentry *olddentry, unsigned int flags) { int err; - struct renamedata rd = { - .old_dir = olddir, - .old_dentry = olddentry, - .new_dir = newdir, - .new_dentry = newdentry, - .flags = flags, - }; pr_debug("rename(%pd2, %pd2, 0x%x)\n", olddentry, newdentry, flags); - err = vfs_rename(&rd); + err = vfs_rename(olddir, olddentry, newdir, newdentry, NULL, flags); if (err) { pr_debug("...rename(%pd2, %pd2, ...) = %i\n", olddentry, newdentry, err); diff --git a/include/linux/fs.h b/include/linux/fs.h index 58ee5649a..f160b8e94 100755 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1839,17 +1839,7 @@ extern int vfs_symlink(struct inode *, struct dentry *, const char *); extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct inode **); extern int vfs_rmdir(struct inode *, struct dentry *); extern int vfs_unlink(struct inode *, struct dentry *, struct inode **); - -struct renamedata { - struct inode *old_dir; - struct dentry *old_dentry; - struct inode *new_dir; - struct dentry *new_dentry; - struct inode **delegated_inode; - unsigned int flags; -} __randomize_layout; - -int vfs_rename(struct renamedata *); +extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **, unsigned int); static inline int vfs_whiteout(struct inode *dir, struct dentry *dentry) {