Re: [PATCH v2 12/12] btrfs: enable nowait async buffered writes

Stefan Roesch
2022-09-08T19:15:10Z

On 9/8/22 3:14 AM, Filipe Manana wrote:
> On Thu, Sep 8, 2022 at 1:29 AM Stefan Roesch <shr@fb.com> wrote:
>>
>> Enable nowait async buffered writes in btrfs_do_write_iter() and
>> btrfs_file_open().
>
> This is too terse, see below.
>
>>
>> Signed-off-by: Stefan Roesch <shr@fb.com>
>> ---
>> fs/btrfs/file.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
>> index fd42ba9de7a7..887497fd524f 100644
>> --- a/fs/btrfs/file.c
>> +++ b/fs/btrfs/file.c
>> @@ -2107,13 +2107,13 @@ ssize_t btrfs_do_write_iter(struct kiocb *iocb, struct iov_iter *from,
>> if (BTRFS_FS_ERROR(inode->root->fs_info))
>> return -EROFS;
>>
>> - if ((iocb->ki_flags & IOCB_NOWAIT) && !(iocb->ki_flags & IOCB_DIRECT))
>> - return -EOPNOTSUPP;
>> -
>> if (sync)
>> atomic_inc(&inode->sync_writers);
>>
>> if (encoded) {
>> + if (iocb->ki_flags & IOCB_NOWAIT)
>> + return -EOPNOTSUPP;
>
> The changelog should provide some rationale about why encoded writes
> are not supported.
>
> Thanks.

I added an explanation why encoded writes are not yet supported.

>
>> +
>> num_written = btrfs_encoded_write(iocb, from, encoded);
>> num_sync = encoded->len;
>> } else if (iocb->ki_flags & IOCB_DIRECT) {
>> @@ -3755,7 +3755,7 @@ static int btrfs_file_open(struct inode *inode, struct file *filp)
>> {
>> int ret;
>>
>> - filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC;
>> + filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC | FMODE_BUF_WASYNC;
>>
>> ret = fsverity_file_open(inode, filp);
>> if (ret)
>> --
>> 2.30.2
>>
>
>