Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751438AbeAEIFc (ORCPT + 1 other); Fri, 5 Jan 2018 03:05:32 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:45322 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751235AbeAEIFb (ORCPT ); Fri, 5 Jan 2018 03:05:31 -0500 Subject: Re: [f2fs-dev] [PATCH 2/2] f2fs: add reserved blocks for root user To: Jaegeuk Kim , , References: <20180103185845.29953-1-jaegeuk@kernel.org> <20180103185845.29953-2-jaegeuk@kernel.org> CC: , "Yuchao (T)" , chao , , , heyunlei From: Yunlong Song Message-ID: <805948ce-6ce7-5fb3-ab8a-38494e6a6fb1@huawei.com> Date: Fri, 5 Jan 2018 16:04:49 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20180103185845.29953-2-jaegeuk@kernel.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.111.220.140] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 2018/1/4 2:58, Jaegeuk Kim wrote: > @@ -1590,11 +1598,17 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi, > sbi->total_valid_block_count += (block_t)(*count); > avail_user_block_count = sbi->user_block_count - > sbi->current_reserved_blocks; > + > + if (!(test_opt(sbi, RESERVE_ROOT) && capable(CAP_SYS_RESOURCE))) > + avail_user_block_count -= sbi->root_reserved_blocks; Should better be: + if (test_opt(sbi, RESERVE_ROOT) && !capable(CAP_SYS_RESOURCE)) + avail_user_block_count -= sbi->root_reserved_blocks; > @@ -1783,9 +1797,13 @@ static inline int inc_valid_node_count(struct f2fs_sb_info *sbi, > > spin_lock(&sbi->stat_lock); > > - valid_block_count = sbi->total_valid_block_count + 1; > - if (unlikely(valid_block_count + sbi->current_reserved_blocks > > - sbi->user_block_count)) { > + valid_block_count = sbi->total_valid_block_count + > + sbi->current_reserved_blocks + 1; > + > + if (!(test_opt(sbi, RESERVE_ROOT) && capable(CAP_SYS_RESOURCE))) > + valid_block_count += sbi->root_reserved_blocks; > + should better be: + if (test_opt(sbi, RESERVE_ROOT) && !capable(CAP_SYS_RESOURCE)) + valid_block_count += sbi->root_reserved_blocks; > + if (unlikely(valid_block_count > sbi->user_block_count)) { > spin_unlock(&sbi->stat_lock); > goto enospc; > } > -- Thanks, Yunlong Song