From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754743AbdIFDIX (ORCPT ); Tue, 5 Sep 2017 23:08:23 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5976 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752226AbdIFDIU (ORCPT ); Tue, 5 Sep 2017 23:08:20 -0400 Subject: Re: [PATCH] f2fs: fix wrong bfree and bavail To: Jaegeuk Kim , , , CC: References: <20170905210653.46186-1-jaegeuk@kernel.org> From: Chao Yu Message-ID: Date: Wed, 6 Sep 2017 11:07:57 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170905210653.46186-1-jaegeuk@kernel.org> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.59AF66A1.0096,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 7b56f96aebea66afe80207ca00b9eabf Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/9/6 5:06, Jaegeuk Kim wrote: > This patch fixes bavail and bfree finally. > > long f_bfree; /* free blocks in fs */ > long f_bavail; /* free blocks avail to non-superuser */ > > So, bfree represents all the reserved blocks, while bavail does the space only > visible to normal user. > > Fix: 3e6d0b4d9c1c ("f2fs: fix incorrect f_bfree calculation in ->statfs") > Cc: # 4.8+ > Signed-off-by: Jaegeuk Kim > --- > fs/f2fs/super.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > index 7e29db227910..17cca4cb93af 100644 > --- a/fs/f2fs/super.c > +++ b/fs/f2fs/super.c > @@ -955,8 +955,8 @@ static int f2fs_statfs(struct dentry *dentry, struct kstatfs *buf) > buf->f_bsize = sbi->blocksize; > > buf->f_blocks = total_count - start_count; > - buf->f_bfree = user_block_count - valid_user_blocks(sbi) + ovp_count; > - buf->f_bavail = user_block_count - valid_user_blocks(sbi) - > + buf->f_bfree = user_block_count - valid_user_blocks(sbi); > + buf->f_bavail = user_block_count - valid_user_blocks(sbi) - ovp_count - set_cp(user_block_count, ((get_cp(free_segment_count) + 6 - get_cp(overprov_segment_count)) * c.blks_per_seg)); As we calculated in mkfs, we have removed ovp_count in user_block_count, so shouldn't we add ovp_count for f_bfree here? Thanks, > sbi->reserved_blocks; > > avail_node_count = sbi->total_node_count - F2FS_RESERVED_NODE_NUM; >