Re: [f2fs-dev] [PATCH v2] f2fs: fix quota_sync failure due to f2fs_lock_op

From: Chao Yu
Date: Thu Apr 23 2020 - 21:00:49 EST


On 2020/4/24 3:49, Jaegeuk Kim wrote:
> On 04/23, Chao Yu wrote:
>> On 2020/4/17 5:39, Jaegeuk Kim wrote:
>>> f2fs_quota_sync() uses f2fs_lock_op() before flushing dirty pages, but
>>> f2fs_write_data_page() returns EAGAIN.
>>> Likewise dentry blocks, we can just bypass getting the lock, since quota
>>> blocks are also maintained by checkpoint.
>>>
>>> Signed-off-by: Jaegeuk Kim <jaegeuk@xxxxxxxxxx>
>>> ---
>>> v2:
>>> - fix multipage write case
>>>
>>> fs/f2fs/compress.c | 2 +-
>>> fs/f2fs/data.c | 4 ++--
>>> 2 files changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
>>> index df7b2d15eacde..faaa358289010 100644
>>> --- a/fs/f2fs/compress.c
>>> +++ b/fs/f2fs/compress.c
>>> @@ -985,7 +985,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
>>> loff_t psize;
>>> int i, err;
>>>
>>> - if (!f2fs_trylock_op(sbi))
>>> + if (!IS_NOQUOTA(inode) && !f2fs_trylock_op(sbi))
>>> return -EAGAIN;
>>
>> I encounter deadlock..
>>
>> Should call f2fs_unlock_op() for non-quota compressed inode later.
>
> Could you elaborate a bit?

I meant we need to change as below, otherwise, cp_rwsem can be negative
after f2fs_unlock_op if writebacked datas are belong to compressed quota
file.