From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753420AbdIEVUc (ORCPT ); Tue, 5 Sep 2017 17:20:32 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:35159 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753390AbdIEVUX (ORCPT ); Tue, 5 Sep 2017 17:20:23 -0400 X-Google-Smtp-Source: AOwi7QAsqPh6unPsyBNt9cvkgJshPqvql3DvdRczuJnY7w30gi6ikzeOWO6GgitE1XExFjj01UGuTA== From: Andreas Dilger Message-Id: <3A56CCE1-34B3-4EBA-9871-DAF175AB89BD@dilger.ca> Content-Type: multipart/signed; boundary="Apple-Mail=_943614EA-D99A-406F-89BC-034B5085BD5B"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH] f2fs: fix wrong bfree and bavail Date: Tue, 5 Sep 2017 15:20:13 -0600 In-Reply-To: <20170905210653.46186-1-jaegeuk@kernel.org> Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, stable@vger.kernel.org To: Jaegeuk Kim References: <20170905210653.46186-1-jaegeuk@kernel.org> X-Mailer: Apple Mail (2.3273) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Apple-Mail=_943614EA-D99A-406F-89BC-034B5085BD5B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On Sep 5, 2017, at 3:06 PM, Jaegeuk Kim wrote: >=20 > This patch fixes bavail and bfree finally. >=20 > long f_bfree; /* free blocks in fs */ > long f_bavail; /* free blocks avail to non-superuser */ >=20 > So, bfree represents all the reserved blocks, while bavail does the = space only > visible to normal user. >=20 > 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(-) >=20 > 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 =3D sbi->blocksize; >=20 > buf->f_blocks =3D total_count - start_count; > - buf->f_bfree =3D user_block_count - valid_user_blocks(sbi) + = ovp_count; > - buf->f_bavail =3D user_block_count - valid_user_blocks(sbi) - > + buf->f_bfree =3D user_block_count - valid_user_blocks(sbi); > + buf->f_bavail =3D user_block_count - valid_user_blocks(sbi) - = ovp_count - > sbi->reserved_blocks; To keep the statfs data more consistent, you could use: buf->f_bavail =3D buf->f_bfree - ovp_count - = sbi->reserved_blocks; That avoids the extra subtraction, and avoids (minor) issues if these = values change while this syscall is running. Cheers, Andreas --Apple-Mail=_943614EA-D99A-406F-89BC-034B5085BD5B Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iD8DBQFZrxUOpIg59Q01vtYRAvEbAJ9W+UxlkoNz2YMWYfQUMrNYgAEZCwCcDgII 5rwo92MTh1gmvK8YXFQZIDI= =dDnr -----END PGP SIGNATURE----- --Apple-Mail=_943614EA-D99A-406F-89BC-034B5085BD5B--