summaryrefslogtreecommitdiff
path: root/mm/shmem.c
diff options
context:
space:
mode:
authorLorenz Bauer <lmb@cloudflare.com>2021-10-28 10:47:21 +0100
committerDaniel Borkmann <daniel@iogearbox.net>2021-11-03 15:43:00 +0100
commit6429e46304ac7820eebbea2bf5d73b90c18e0e06 (patch)
tree0a3b4bec45a6400ff157f66d5d994397b6c2dcbb /mm/shmem.c
parent92f62485b3715882cd397b0cbd80a96d179b86d6 (diff)
downloadlwn-6429e46304ac7820eebbea2bf5d73b90c18e0e06.tar.gz
lwn-6429e46304ac7820eebbea2bf5d73b90c18e0e06.zip
libfs: Move shmem_exchange to simple_rename_exchange
Move shmem_exchange and make it available to other callers. Suggested-by: Miklos Szeredi <mszeredi@redhat.com> Signed-off-by: Lorenz Bauer <lmb@cloudflare.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Miklos Szeredi <mszeredi@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Christian Brauner <christian.brauner@ubuntu.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/bpf/20211028094724.59043-2-lmb@cloudflare.com
Diffstat (limited to 'mm/shmem.c')
-rw-r--r--mm/shmem.c24
1 files changed, 1 insertions, 23 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index 17e344e26e73..56616aabe0a1 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2947,28 +2947,6 @@ static int shmem_rmdir(struct inode *dir, struct dentry *dentry)
return shmem_unlink(dir, dentry);
}
-static int shmem_exchange(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry)
-{
- bool old_is_dir = d_is_dir(old_dentry);
- bool new_is_dir = d_is_dir(new_dentry);
-
- if (old_dir != new_dir && old_is_dir != new_is_dir) {
- if (old_is_dir) {
- drop_nlink(old_dir);
- inc_nlink(new_dir);
- } else {
- drop_nlink(new_dir);
- inc_nlink(old_dir);
- }
- }
- old_dir->i_ctime = old_dir->i_mtime =
- new_dir->i_ctime = new_dir->i_mtime =
- d_inode(old_dentry)->i_ctime =
- d_inode(new_dentry)->i_ctime = current_time(old_dir);
-
- return 0;
-}
-
static int shmem_whiteout(struct user_namespace *mnt_userns,
struct inode *old_dir, struct dentry *old_dentry)
{
@@ -3014,7 +2992,7 @@ static int shmem_rename2(struct user_namespace *mnt_userns,
return -EINVAL;
if (flags & RENAME_EXCHANGE)
- return shmem_exchange(old_dir, old_dentry, new_dir, new_dentry);
+ return simple_rename_exchange(old_dir, old_dentry, new_dir, new_dentry);
if (!simple_empty(new_dentry))
return -ENOTEMPTY;