Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Feb 2010 15:37:02 +0300
From:      "Alexander Zagrebin" <alexz@visp.ru>
To:        <freebsd-fs@freebsd.org>
Subject:   ZFS: statfs and recordsize problem
Message-ID:  <A0A0822ABAE34E8C8113BD83EFA11B2D@vosz.local>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.

------=_NextPart_000_01A3_01CAB0B0.375217A0
Content-Type: text/plain;
	charset="koi8-r"
Content-Transfer-Encoding: 7bit

I have noticed, that statfs called for ZFS file systems,
returns the value of FS's recordsize property in both f_bsize and
f_iosize.

It's a problem for some software.
For example, squid uses block size of cache's file system to calculate
the space occupied by file.
So by default it considers that any small file uses 128KB of a cache
(when default value of recordsize is used), though really this file
may use 512B only.
This miscalculation leads to unreasonable cleaning of a cache.

IMHO the behavior of statfs have to be changed, as ZFS uses variable
(up to recordsize) block sizes.
It must return 512 as f_bsize and recordsize as f_iosize.
One of possible solutions is the attached patch.
Could somebody look it?

-- 
Alexander Zagrebin

------=_NextPart_000_01A3_01CAB0B0.375217A0
Content-Type: application/octet-stream;
	name="patch-zfs_vfsops.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="patch-zfs_vfsops.c"

--- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c.orig	=
2009-09-29 14:53:06.000000000 +0400=0A=
+++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c		=
2009-10-26 15:47:29.365783209 +0300=0A=
@@ -214,7 +214,7 @@=0A=
 		newval =3D SPA_MAXBLOCKSIZE;=0A=
 =0A=
 	zfsvfs->z_max_blksz =3D newval;=0A=
-	zfsvfs->z_vfs->vfs_bsize =3D newval;=0A=
+	zfsvfs->z_vfs->mnt_stat.f_iosize =3D newval;=0A=
 }=0A=
 =0A=
 static void=0A=
@@ -577,7 +577,8 @@=0A=
 	if (error =3D dsl_prop_get_integer(osname, "recordsize", &recordsize,=0A=
 	    NULL))=0A=
 		goto out;=0A=
-	zfsvfs->z_vfs->vfs_bsize =3D recordsize;=0A=
+	zfsvfs->z_vfs->vfs_bsize =3D SPA_MINBLOCKSIZE;=0A=
+	zfsvfs->z_vfs->mnt_stat.f_iosize =3D recordsize;=0A=
 =0A=
 	vfsp->vfs_data =3D zfsvfs;=0A=
 	vfsp->mnt_flag |=3D MNT_LOCAL;=0A=
@@ -817,8 +818,8 @@=0A=
 	 * We report the fragsize as the smallest block size we support,=0A=
 	 * and we report our blocksize as the filesystem's maximum blocksize.=0A=
 	 */=0A=
-	statp->f_bsize =3D zfsvfs->z_vfs->vfs_bsize;=0A=
-	statp->f_iosize =3D zfsvfs->z_vfs->vfs_bsize;=0A=
+	statp->f_bsize =3D SPA_MINBLOCKSIZE;=0A=
+	statp->f_iosize =3D zfsvfs->z_vfs->mnt_stat.f_iosize;=0A=
 =0A=
 	/*=0A=
 	 * The following report "total" blocks of various kinds in the=0A=

------=_NextPart_000_01A3_01CAB0B0.375217A0--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?A0A0822ABAE34E8C8113BD83EFA11B2D>