Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756895AbeAHLXd (ORCPT + 1 other); Mon, 8 Jan 2018 06:23:33 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:3752 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755930AbeAHLXc (ORCPT ); Mon, 8 Jan 2018 06:23:32 -0500 Subject: Re: [f2fs-dev] [PATCH 1/2] f2fs: show precise # of blocks that user/root can use To: Yunlong Song , Jaegeuk Kim , , CC: , chao , , , "shengyong (A)" References: <20180103185845.29953-1-jaegeuk@kernel.org> <7206fb17-4785-756c-9fef-39565adf8780@huawei.com> From: Chao Yu Message-ID: <8b4d0f60-3c5d-edce-f634-d8e489c79d59@huawei.com> Date: Mon, 8 Jan 2018 19:23:11 +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: <7206fb17-4785-756c-9fef-39565adf8780@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] 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/5 15:05, Yunlong Song wrote: > NACK > > man statfs shows: > > struct statfs { > ... > fsblkcnt_t f_bfree; /* free blocks in fs */ > fsblkcnt_t f_bavail; /* free blocks available to > unprivileged user */ > ... > } > > f_bfree is free blocks in fs, so buf->bfree should be > > buf->f_bfree = user_block_count - valid_user_blocks(sbi) + ovp_count; As I checked, some filesystems reserving over-privision space like btrfs/xfs/ubifs, they will not calculate those space into f_bfree, IMO, we should follow their behavior to keep compatibility for old applications. Thanks, > > On 2018/1/4 2:58, Jaegeuk Kim wrote: >> Let's show precise # of blocks that user/root can use through bavail and bfree >> respectively. >> >> 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 0a820ba55b10..4c1c99cf54ef 100644 >> --- a/fs/f2fs/super.c >> +++ b/fs/f2fs/super.c >> @@ -1005,9 +1005,9 @@ 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) - >> sbi->current_reserved_blocks; >> + buf->f_bavail = buf->f_bfree; >> >> avail_node_count = sbi->total_node_count - sbi->nquota_files - >> F2FS_RESERVED_NODE_NUM; >