Message ID | 5d52220b-177d-72d4-7825-dbe6cbf8722f@inwind.it (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [RFC] btrfs : avoid O_DIRECT when the file is protected by CSUM | expand |
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 0e41459b8de6..af73157e8200 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2018,7 +2018,12 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, if (sync) atomic_inc(&BTRFS_I(inode)->sync_writers); - if (iocb->ki_flags & IOCB_DIRECT) + /* + * O_DIRECT doesn't play well with CSUM, so allow the O_DIRECT + * only if the file is marked BTRFS_INODE_NODATASUM + */ + if (iocb->ki_flags & IOCB_DIRECT && + (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) num_written = btrfs_direct_write(iocb, from); else num_written = btrfs_buffered_write(iocb, from);