Skip to content

Commit f50cb7a

Browse files
osandovkdave
authored andcommitted
btrfs: treat RWF_{,D}SYNC writes as sync for CRCs
The VFS indicates a synchronous write to ->write_iter() via iocb->ki_flags. The IOCB_{,D}SYNC flags may be set based on the file (see iocb_flags()) or the RWF_* flags passed to a syscall like pwritev2() (see kiocb_set_rw_flags()). However, in btrfs_file_write_iter(), we're checking if a write is synchronous based only on the file; we use this to decide when to bump the sync_writers counter and thus do CRCs synchronously. Make sure we do this for all synchronous writes as determined by the VFS. Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: Omar Sandoval <[email protected]> Reviewed-by: David Sterba <[email protected]> [ add const ] Signed-off-by: David Sterba <[email protected]>
1 parent c09767a commit f50cb7a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/btrfs/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1882,7 +1882,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
18821882
u64 start_pos;
18831883
u64 end_pos;
18841884
ssize_t num_written = 0;
1885-
bool sync = (file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host);
1885+
const bool sync = iocb->ki_flags & IOCB_DSYNC;
18861886
ssize_t err;
18871887
loff_t pos;
18881888
size_t count;

0 commit comments

Comments
 (0)