From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754797AbdIFDTn (ORCPT ); Tue, 5 Sep 2017 23:19:43 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5978 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753113AbdIFDTl (ORCPT ); Tue, 5 Sep 2017 23:19:41 -0400 Subject: Re: [PATCH] f2fs: fix wrong bfree and bavail To: Jaegeuk Kim CC: , , , References: <20170905210653.46186-1-jaegeuk@kernel.org> <20170906031028.GA61332@jaegeuk-macbookpro.roam.corp.google.com> From: Chao Yu Message-ID: <58ffa17c-286a-a7e6-8cf8-7213bfe2acf7@huawei.com> Date: Wed, 6 Sep 2017 11:19:34 +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: <20170906031028.GA61332@jaegeuk-macbookpro.roam.corp.google.com> 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.0A020201.59AF694B.0062,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 11:10, Jaegeuk Kim wrote: > On 09/06, Chao Yu wrote: >> 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? > > Hehe, I already dropped this. :P Alright. :) > It seems like something wrong with df in android. Maybe its version is too old? Thanks, > >> >> Thanks, >> >>> sbi->reserved_blocks; >>> >>> avail_node_count = sbi->total_node_count - F2FS_RESERVED_NODE_NUM; >>> > > . >