[Devel] [PATCH RHEL COMMIT] fs: Introduce vfs_truncate2() with file argument

Konstantin Khorenko khorenko at virtuozzo.com
Mon Sep 20 19:59:22 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit 3528717686bae71294ccb634fb23852f088860ab
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Mon Sep 20 19:59:21 2021 +0300

    fs: Introduce vfs_truncate2() with file argument
    
    Vstorage requires ATTR_FILE argument assigned in do_truncate().
    Introduce a new function, which allows to care about this.
    
    Suggested-by: Alexey Kuznetsov <kuznet at virtuozzo.com>
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 fs/open.c                | 6 +++---
 include/linux/fs.h       | 6 +++++-
 kernel/trace/bpf_trace.c | 2 +-
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/fs/open.c b/fs/open.c
index 94bef26ff1b6..8e8c676005cb 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -66,7 +66,7 @@ int do_truncate(struct user_namespace *mnt_userns, struct dentry *dentry,
 	return ret;
 }
 
-long vfs_truncate(const struct path *path, loff_t length)
+long vfs_truncate2(const struct path *path, loff_t length, struct file *file)
 {
 	struct user_namespace *mnt_userns;
 	struct inode *inode;
@@ -109,7 +109,7 @@ long vfs_truncate(const struct path *path, loff_t length)
 	if (!error)
 		error = security_path_truncate(path);
 	if (!error)
-		error = do_truncate(mnt_userns, path->dentry, length, 0, NULL);
+		error = do_truncate(mnt_userns, path->dentry, length, 0, file);
 
 put_write_and_out:
 	put_write_access(inode);
@@ -118,7 +118,7 @@ long vfs_truncate(const struct path *path, loff_t length)
 out:
 	return error;
 }
-EXPORT_SYMBOL_GPL(vfs_truncate);
+EXPORT_SYMBOL_GPL(vfs_truncate2);
 
 long do_sys_truncate(const char __user *pathname, loff_t length)
 {
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 640574294216..bf45b4aa5989 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2759,7 +2759,11 @@ static inline struct user_namespace *file_mnt_user_ns(struct file *file)
 {
 	return mnt_user_ns(file->f_path.mnt);
 }
-extern long vfs_truncate(const struct path *, loff_t);
+extern long vfs_truncate2(const struct path *, loff_t, struct file *);
+static inline long vfs_truncate(const struct path *path, loff_t off)
+{
+	return vfs_truncate2(path, off, NULL);
+}
 int do_truncate(struct user_namespace *, struct dentry *, loff_t start,
 		unsigned int time_attrs, struct file *filp);
 extern int vfs_fallocate(struct file *file, int mode, loff_t offset,
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index fdd14072fc3b..e89d0b250a34 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -856,7 +856,7 @@ BTF_ID(func, security_file_open)
 #ifdef CONFIG_SECURITY_PATH
 BTF_ID(func, security_path_truncate)
 #endif
-BTF_ID(func, vfs_truncate)
+BTF_ID(func, vfs_truncate2)
 BTF_ID(func, vfs_fallocate)
 BTF_ID(func, dentry_open)
 BTF_ID(func, vfs_getattr)


More information about the Devel mailing list