Subject: Re: Solution(?) to kern/28804: quotacheck crashes on FFSv2
To: None <tech-kern@netbsd.org>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 02/19/2007 08:46:47
--bg08WKrSYDhXBjb5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Feb 15, 2007 at 08:06:38PM +0100, Edgar Fu? wrote:
> > The issue, though, is that more of our fs expertise hangs=20
> > on tech-kern, so this is a good list to use.
> Good.
> Anyone in a position to comment on the changes made to the FreeBSD versio=
n by McKusick?

Ok, I don't feel I'm an expert, but no one's said anything and I'd rather=
=20
you get some answer. :-)

> Anyone familiar enough with softdeps?

Nope, but I think the idea is that not all inodes are allocated initially.=
=20
You initialize them as you need them. So this code is coping with that=20
fact; only process inodes that exist.

> /*
>  * If we are using soft updates, then we can trust the
>  * cylinder group inode allocation maps to tell us which
>  * inodes are allocated. We will scan the used inode map
>  * to find the inodes that are really in use, and then
>  * read only those inodes in from disk.
>  */
> if (sblock.fs_flags & FS_DOSOFTDEP) {
> 	if (!cg_chkmagic(&cgblk))
> 		errx(1, "CG %d: BAD MAGIC NUMBER\n", cg);
> 	cp =3D &cg_inosused(&cgblk)[(inosused - 1) / CHAR_BIT];
> 	for ( ; inosused > 0; inosused -=3D CHAR_BIT, cp--) {
> 		if (*cp =3D=3D 0)
> 			continue;
> 		for (i =3D 1 << (CHAR_BIT - 1); i > 0; i >>=3D 1) {
> 			if (*cp & i)
> 				break;
> 			inosused--;
> 		}
> 		break;
> 	}
> 	if (inosused <=3D 0)
> 		continue;
> }
>=20
> And with snapshots?

Our snapshopt person should chime in, but I think it's rather clear that=20
snapshots do not count towards quotas. This if we see a snapshot file, we=
=20
skip it.

> /*=20
>  * Do not account for file system snapshot files
>  * or the actual quota data files to be consistent
>  * with how they are handled inside the kernel.
>  */
> #ifdef	SF_SNAPSHOT
> 	if (DIP(dp, di_flags) & SF_SNAPSHOT)
> 		continue;
> #endif
> 	if (ino =3D=3D userino || ino =3D=3D groupino)
> 		continue;
> 	if (qnp->flags & HASGRP) {
> 		fup =3D addid((u_long)DIP(dp, di_gid), GRPQUOTA,
> 		    (char *)0, mntpt);
> 		fup->fu_curinodes++;
> 		if (mode =3D=3D IFREG || mode =3D=3D IFDIR ||
> 		    mode =3D=3D IFLNK)
> 			fup->fu_curblocks +=3D DIP(dp, di_blocks);
> 	}
> 	if (qnp->flags & HASUSR) {
> 		fup =3D addid((u_long)DIP(dp, di_uid), USRQUOTA,
> 		    (char *)0, mntpt);
> 		fup->fu_curinodes++;
> 		if (mode =3D=3D IFREG || mode =3D=3D IFDIR ||
> 		    mode =3D=3D IFLNK)
> 			fup->fu_curblocks +=3D DIP(dp, di_blocks);
> 	}
>=20
>=20
> May it be a better idea to put all this inode enumeration into the kernel?

I don't think so. While the tool has to track the kernel, we only check=20
quotas occasionally. So it's simpler and a smaller footprint to have the=20
checking in userland.

Take care,

Bill

--bg08WKrSYDhXBjb5
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (NetBSD)

iD8DBQFF2dR3Wz+3JHUci9cRAvb6AJ93lDEcdf54mvZLtAqWjyNfUsN30QCggbH+
Hhrzm6RQOiKvp7Q9fcZAOKY=
=poav
-----END PGP SIGNATURE-----

--bg08WKrSYDhXBjb5--