From mboxrd@z Thu Jan 1 00:00:00 1970 From: Evgeniy Dushistov Subject: Re: [PATCH] update i_blocks on UFS Date: Mon, 14 May 2012 01:59:26 +0400 Message-ID: <20120513215925.GA1998@maclin> References: <4FAFBCAE.1050401@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: Vladimir =?utf-8?Q?'=CF=86-coder=2Fphcoder'?= Serbinenko Return-path: Content-Disposition: inline In-Reply-To: <4FAFBCAE.1050401@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Sun, May 13, 2012 at 03:52:46PM +0200, Vladimir '=CF=86-coder/phcode= r' Serbinenko wrote: > UFS code dosn't update i_blocks which leads to the problems ranging f= rom wrong > stat/du to long symlinks (as opposed to inline ones) being damaged. T= his is > a fix. >=20 Yes, when quota support was removed, code that update statistic about usage of blocks also was removed. But why so big change to fix th= is? I found this problem some time ago and fixed it with code bellow, but may be I missed something? =46rom 3bba2473d2d09c0ebde5e287d694346ba0e4b4c0 Mon Sep 17 00:00:00 200= 1 =46rom: Evgeniy Dushistov Date: Fri, 18 Mar 2011 06:42:57 +0300 Subject: [PATCH] Looks like with quote support code was removed code that update statistic about usage blocks per inode. So fix this. --- fs/ufs/balloc.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index 100d2ee..e7bf2fd 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c @@ -83,7 +83,7 @@ void ufs_free_fragments(struct inode *inode, u64 frag= ment, unsigned count) ufs_error (sb, "ufs_free_fragments", "bit already cleared for fragment %u", i); } -=09 + inode_sub_bytes(inode, count << uspi->s_fshift); fs32_add(sb, &ucg->cg_cs.cs_nffree, count); uspi->cs_total.cs_nffree +=3D count; fs32_add(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, count); @@ -189,6 +189,7 @@ do_more: ubh_setblock(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno); if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) =3D=3D UFS_CG_44BSD) ufs_clusteracct (sb, ucpi, blkno, 1); + inode_sub_bytes(inode, uspi->s_bsize); =20 fs32_add(sb, &ucg->cg_cs.cs_nbfree, 1); uspi->cs_total.cs_nbfree++; @@ -547,7 +548,7 @@ static u64 ufs_add_fragments(struct inode *inode, u= 64 fragment, fs32_add(sb, &ucg->cg_frsum[fragsize - count], 1); for (i =3D oldcount; i < newcount; i++) ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i); - + inode_add_bytes(inode, count << uspi->s_fshift); fs32_sub(sb, &ucg->cg_cs.cs_nffree, count); fs32_sub(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, count); uspi->cs_total.cs_nffree -=3D count; @@ -649,6 +650,7 @@ cg_found: for (i =3D count; i < uspi->s_fpb; i++) ubh_setbit (UCPI_UBH(ucpi), ucpi->c_freeoff, goal + i); i =3D uspi->s_fpb - count; + inode_sub_bytes(inode, i << uspi->s_fshift); =20 fs32_add(sb, &ucg->cg_cs.cs_nffree, i); uspi->cs_total.cs_nffree +=3D i; @@ -660,6 +662,7 @@ cg_found: result =3D ufs_bitmap_search (sb, ucpi, goal, allocsize); if (result =3D=3D INVBLOCK) return 0; + inode_add_bytes(inode, count << uspi->s_fshift); for (i =3D 0; i < count; i++) ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_freeoff, result + i); =09 @@ -725,7 +728,7 @@ gotit: ubh_clrblock (UCPI_UBH(ucpi), ucpi->c_freeoff, blkno); if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) =3D=3D UFS_CG_44BSD) ufs_clusteracct (sb, ucpi, blkno, -1); - + inode_add_bytes(inode, uspi->s_bsize); fs32_sub(sb, &ucg->cg_cs.cs_nbfree, 1); uspi->cs_total.cs_nbfree--; fs32_sub(sb, &UFS_SB(sb)->fs_cs(ucpi->c_cgx).cs_nbfree, 1); --=20 1.7.3.4 --=20 /Evgeniy