aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fs.h
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2017-01-31 10:34:57 +0200
committerMiklos Szeredi <mszeredi@redhat.com>2017-02-07 15:05:04 +0100
commitbfe219d373cadab761373aeea4c70406bc27ea2c (patch)
tree781b1664565d45394b4272cc783932b857de67cf /include/linux/fs.h
parentvfs: deny copy_file_range() for non regular files (diff)
downloadlinux-dev-bfe219d373cadab761373aeea4c70406bc27ea2c.tar.xz
linux-dev-bfe219d373cadab761373aeea4c70406bc27ea2c.zip
vfs: wrap write f_ops with file_{start,end}_write()
Before calling write f_ops, call file_start_write() instead of sb_start_write(). Replace {sb,file}_start_write() for {copy,clone}_file_range() and for fallocate(). Beyond correct semantics, this avoids freeze protection to sb when operating on special inodes, such as fallocate() on a blockdev. Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Amir Goldstein <amir73il@gmail.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r--include/linux/fs.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4a7f3cc9edab..78c81e6f5d76 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1741,19 +1741,6 @@ extern int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff,
extern int vfs_dedupe_file_range(struct file *file,
struct file_dedupe_range *same);
-static inline int do_clone_file_range(struct file *file_in, loff_t pos_in,
- struct file *file_out, loff_t pos_out,
- u64 len)
-{
- int ret;
-
- sb_start_write(file_inode(file_out)->i_sb);
- ret = vfs_clone_file_range(file_in, pos_in, file_out, pos_out, len);
- sb_end_write(file_inode(file_out)->i_sb);
-
- return ret;
-}
-
struct super_operations {
struct inode *(*alloc_inode)(struct super_block *sb);
void (*destroy_inode)(struct inode *);
@@ -2564,6 +2551,19 @@ static inline void file_end_write(struct file *file)
__sb_end_write(file_inode(file)->i_sb, SB_FREEZE_WRITE);
}
+static inline int do_clone_file_range(struct file *file_in, loff_t pos_in,
+ struct file *file_out, loff_t pos_out,
+ u64 len)
+{
+ int ret;
+
+ file_start_write(file_out);
+ ret = vfs_clone_file_range(file_in, pos_in, file_out, pos_out, len);
+ file_end_write(file_out);
+
+ return ret;
+}
+
/*
* get_write_access() gets write permission for a file.
* put_write_access() releases this write permission.