On 2019/5/15 上午1:29, David Sterba wrote:
> On Fri, May 10, 2019 at 12:45:05PM +0800, Qu Wenruo wrote:
>> Commit ddf30cf03fb5 ("btrfs: extent-tree: Use btrfs_ref to refactor
>> add_pinned_bytes()") refactored add_pinned_bytes(), but during that
>> refactor, there are two callers which add the pinned bytes instead
>> of subtracting.
>>
>> That refactor misses those two caller, causing incorrect pinned bytes
>> calculation and resulting unexpected ENOSPC error.
>>
>> Fix it by adding a new parameter @sign to restore the original behavior.
>>
>> Reported-by: kernel test robot <rong.a.c...@intel.com>
>> Fixes: ddf30cf03fb5 ("btrfs: extent-tree: Use btrfs_ref to refactor 
>> add_pinned_bytes()")
>> Signed-off-by: Qu Wenruo <w...@suse.com>
>> ---
>>  fs/btrfs/extent-tree.c | 12 +++++++-----
>>  1 file changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
>> index f79e477a378e..8592d31e321c 100644
>> --- a/fs/btrfs/extent-tree.c
>> +++ b/fs/btrfs/extent-tree.c
>> @@ -757,12 +757,14 @@ static struct btrfs_space_info 
>> *__find_space_info(struct btrfs_fs_info *info,
>>  }
>>  
>>  static void add_pinned_bytes(struct btrfs_fs_info *fs_info,
>> -                         struct btrfs_ref *ref)
>> +                         struct btrfs_ref *ref, int sign)
> 
> This does not look like a good API, can it be done with a separate
> function like sub_pinned_bytes?
> 

No problem, indeed sub_pinned_bytes looks much better.

Thanks,
Qu

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to