NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/50422: df -G prints the wrong value for fragsize (+FIX)



>Number:         50422
>Category:       bin
>Synopsis:       df -G prints the wrong value for fragsize (+FIX)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Nov 12 17:25:00 +0000 2015
>Originator:     Robert Elz
>Release:        NetBSD 7.99.21 (all versions since NetBSD 5)
>Organization:
	Prince of Songkla University
>Environment:
System: NetBSD andromeda.noi.kre.to 7.99.21 NetBSD 7.99.21 (VBOX64-1.1-20150829) #3: Sun Aug 30 07:16:17 ICT 2015 kre%andromeda.noi.kre.to@localhost:/home/kre/src/current-kernel/usr/src/sys/arch/amd64/compile/VBOX64 amd64
Architecture: x86_64
Machine: amd64
>Description:

	df -G prints the file system block size as both the block
	size and the frag size (OK, it gets the value from two different
	fields of the statvfs struct, but they are both set to the same
	value in the kernel for all cases I saw...)

>How-To-Repeat:
	df -G /

	Expect to see something like ...

         / (/dev/wd0a   ):    8192 block size         8192 frag size
    246959 total blocks     132363 free blocks      120016 available
     57021 total files       61822 free files            0 filesys id
       ffs fstype        0x2005000 flag                255 filename length
         0 owner                 0 syncwrites        20712 asyncwrites

	Yet (from dumpfs) ...

file system: /dev/rwd0a
format	FFSv2
endian	little-endian
location 65536	(-b 128)
magic	19540119	time	Fri Nov 13 00:15:31 2015
superblock location	65536	id	[ 5497bb3d 3df723af ]
cylgrp	dynamic	inodes	FFSv2	sblock	FFSv2	fslevel 5
nbfree	16535	ndir	628	nifree	57021	nffree	83
ncg	6	size	262584	blocks	246959
bsize	8192	shift	13	mask	0xffffe000
fsize	1024	shift	10	mask	0xfffffc00
frag	8	shift	3	fsbtodb	1
bpg	5471	fpg	43768	ipg	10304

>Fix:
	Apply the patch included below.  With that, expect to see ...

         / (/dev/wd0a   ):    8192 block size         1024 frag size
    246959 total blocks     132363 free blocks      120016 available
     57021 total files       61822 free files            0 filesys id
       ffs fstype        0x2005000 flag                255 filename length
         0 owner                 0 syncwrites        20789 asyncwrites

	In the patch, the change from f_iosize to f_bsize is almost
	gratuitous, I made it because if the aim is to print the
	file system block size, that's what we should print, rather
	than the optimal I/O size ... if the latter is wanted, which
	might be a good idea, it should be added as a new field.

	The second change is the one that fixes things.

	This fix should be pulled up everywhere (pity we're a couple of
	days too late to correct the netbsd-5 series ... that's the
	first release that had df -G, so the first to contain the bug.)

--- df.c.BUG	2012-01-08 01:45:13.000000000 +0700
+++ df.c	2015-11-13 00:06:20.000000000 +0700
@@ -379,13 +379,13 @@
 		 */
 		(void)printf("%10s (%-12s): %7ld block size %12ld frag size\n",
 		    sfsp->f_mntonname, sfsp->f_mntfromname,
-		    sfsp->f_iosize,	/* On UFS/FFS systems this is
+		    sfsp->f_bsize,	/* On UFS/FFS systems this is
 					 * also called the "optimal
 					 * transfer block size" but it
 					 * is of course the file
 					 * system's block size too.
 					 */
-		    sfsp->f_bsize);	/* not so surprisingly the
+		    sfsp->f_frsize);	/* not so surprisingly the
 					 * "fundamental file system
 					 * block size" is the frag
 					 * size.



Home | Main Index | Thread Index | Old Index