Subject: kern/6246: statfs output incorrect for LFS with fragments
To: None <gnats-bugs@gnats.netbsd.org, perseant@hhhh.org, margo@eecs.harvard.edu>
From: None <perseant@hhhh.org>
List: netbsd-bugs
Date: 10/04/1998 15:36:53
>Number:         6246
>Category:       kern
>Synopsis:       lfs_statfs returns incorrect value for f_bsize
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct  4 15:50:01 1998
>Last-Modified:
>Originator:     Konrad Schroder
>Organization:
-------------------------------------------------------------------------
Konrad Schroder           http://www.hitl.washington.edu/people/perseant/
System Administrator                         perseant@hitl.washington.edu
Human Interface Technology Lab                     Voice: +1.206.616.1478
Box 352142, University of Washington, 98195, USA     FAX: +1.206.543.5380
>Release:        Sep 14 1998
>Environment:
System: NetBSD inle 1.3 NetBSD 1.3 (INLE) #1: Sun Apr 19 15:01:29 PDT 1998 perseant@gro:/usr/src/sys/arch/i386/compile/INLE i386

>Description:
        lfs_statfs returns a block size (f_bsize) of lfs_bsize, and then
        returns total and available block counts (f_blocks, f_free) in
        units of fragment size.  This causes df to give ludicrous reports,
        and the cleaner to behave erratically, on filesystems with fragments.
>How-To-Repeat:
        (/dev/rsd0g is 511680 512-blocks in size)
        inle# /sbin/newlfs -b 8192 -f 1024 /dev/rsd0g
        inle# mount -t lfs -o-n /dev/sd0g /mnt
        inle# df -k /mnt
        Filesystem  1K-blocks     Used    Avail Capacity  Mounted on
        /dev/sd0g     2023424      136    -9496    -1%    /mnt
>Fix:
*** lfs.1.3H/lfs_vfsops.c       Sat Sep 12 04:11:14 1998
--- lfs/lfs_vfsops.c    Wed Sep 30 11:28:40 1998
***************
*** 478,484 ****
        if (fs->lfs_magic != LFS_MAGIC)
                panic("lfs_statfs: magic");
        sbp->f_type = 0;
!       sbp->f_bsize = fs->lfs_bsize;
        sbp->f_iosize = fs->lfs_bsize;
        sbp->f_blocks = dbtofrags(fs, fs->lfs_dsize);
        sbp->f_bfree = dbtofrags(fs, fs->lfs_bfree);
--- 475,481 ----
        if (fs->lfs_magic != LFS_MAGIC)
                panic("lfs_statfs: magic");
        sbp->f_type = 0;
!       sbp->f_bsize = fs->lfs_fsize;
        sbp->f_iosize = fs->lfs_bsize;
        sbp->f_blocks = dbtofrags(fs, fs->lfs_dsize);
        sbp->f_bfree = dbtofrags(fs, fs->lfs_bfree);

>Audit-Trail:
>Unformatted: