Commit f50cb7af authored by Omar Sandoval's avatar Omar Sandoval Committed by David Sterba

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: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
[ add const ]
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent c09767a8
...@@ -1882,7 +1882,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, ...@@ -1882,7 +1882,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
u64 start_pos; u64 start_pos;
u64 end_pos; u64 end_pos;
ssize_t num_written = 0; ssize_t num_written = 0;
bool sync = (file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host); const bool sync = iocb->ki_flags & IOCB_DSYNC;
ssize_t err; ssize_t err;
loff_t pos; loff_t pos;
size_t count; size_t count;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment