[Devel] [PATCH RH8 1/2] fs: Introduce vfs_truncate2() with file argument

Kirill Tkhai ktkhai at virtuozzo.com
Wed Jun 23 19:21:53 MSK 2021


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 +++++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/open.c b/fs/open.c
index dc9603f07dbc..b916749f2f90 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -65,7 +65,7 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
 	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 inode *inode;
 	long error;
@@ -106,7 +106,7 @@ long vfs_truncate(const struct path *path, loff_t length)
 	if (!error)
 		error = security_path_truncate(path);
 	if (!error)
-		error = do_truncate(path->dentry, length, 0, NULL);
+		error = do_truncate(path->dentry, length, 0, file);
 
 put_write_and_out:
 	put_write_access(inode);
@@ -115,7 +115,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 0a54b95dc1b4..70891b893d12 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2546,7 +2546,11 @@ struct filename {
 	const char		iname[];
 };
 
-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);
+}
 extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
 		       struct file *filp);
 extern int vfs_fallocate(struct file *file, int mode, loff_t offset,




More information about the Devel mailing list