From owner-freebsd-arch Sun Jan 20 10:18:32 2002 Delivered-To: freebsd-arch@freebsd.org Received: from camelot.spsl.nsc.ru (camelot.spsl.nsc.ru [194.226.174.80]) by hub.freebsd.org (Postfix) with ESMTP id 2425D37B405 for ; Sun, 20 Jan 2002 10:18:15 -0800 (PST) Received: (from root@localhost) by camelot.spsl.nsc.ru (8.11.6/8.11.6) id g0KIHvv21444 for arch@freebsd.org.AVP; Mon, 21 Jan 2002 00:17:57 +0600 (NOVT) (envelope-from fjoe@iclub.nsu.ru) Received: from iclub.nsu.ru (root@iclub.nsu.ru [193.124.222.66]) by camelot.spsl.nsc.ru (8.11.6/8.11.6) with ESMTP id g0KIHrX21436; Mon, 21 Jan 2002 00:17:53 +0600 (NOVT) (envelope-from fjoe@iclub.nsu.ru) Received: (from fjoe@localhost) by iclub.nsu.ru (8.11.6/8.11.6) id g0KIHnW80990; Mon, 21 Jan 2002 00:17:49 +0600 (NS) (envelope-from fjoe) Date: Mon, 21 Jan 2002 00:17:49 +0600 From: Max Khon To: Bruce Evans Cc: Cy Schubert - ITSD Open Systems Group , Poul-Henning Kamp , arch@freebsd.org Subject: Re: request for review Message-ID: <20020121001749.A80939@iclub.nsu.ru> References: <20020116000607.B10938@iclub.nsu.ru> <20020116155828.T487-100000@gamplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020116155828.T487-100000@gamplex.bde.org>; from bde@zeta.org.au on Wed, Jan 16, 2002 at 04:18:12PM +1100 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG hi, there! On Wed, Jan 16, 2002 at 04:18:12PM +1100, Bruce Evans wrote: > > > This patch also makes FreeBSD almost compatible with FreeBSD (versions > > > 1, 2, 3) that is. Old versions vn_stat() simply passed back the > > > va_blocksize set by VOP_GETTATTR(). > > > > NetBSD/OpenBSD do exactly the same > > The main point of the differences in FreeBSD is to set st_blksize to > a reasonable value for disks (since individual filesystems didn't do > it). The changes really shouldn't have affected non-disks. > > > > > > I think it is bogus for devices other than disks to flout a > > > > > va_blocksize, but I am on the other hand not sure what the > > > > > relevant (if any) standards say. > > > > > > POSIX says almost the same as the quote from www.opengroup.org in the > > > sources: "A file system-specific [sic] preferred I/O block size for > > > this object". 0 is wrong except possibly for /dev/null since it is > > > a very bad I/O size. > > > > do you think we should remove setting sb->st_blksize to 0 in vn_stat() at all? > > Yes. We should also fix any filesystems that set va_blocksize to 0, or > convert a va_blocksize of 0 to a more sensible st_blksize. I just noticed > the following comment in vn_stat(): > > * Default to zero to catch bogus uses of this field. > > This causes many bogus block sizes in the same way that a fixed default > in the kernel does. An st_blksize of 0 means stdio's BUFSIZ in many > cases, since stdio prefers to use st_blksize but has to invent a block > size if st_blksize is not useful. BUFSIZ is 1024, which is rather > small these days. It's good for slow cdevs but not much else. ok, what do you think about this patch? Index: vfs_vnops.c =================================================================== RCS file: /home/ncvs/src/sys/kern/vfs_vnops.c,v retrieving revision 1.126 diff -u -p -r1.126 vfs_vnops.c --- vfs_vnops.c 13 Jan 2002 11:58:03 -0000 1.126 +++ vfs_vnops.c 20 Jan 2002 17:45:38 -0000 @@ -571,17 +571,17 @@ vn_stat(vp, sb, td) * Default to zero to catch bogus uses of this field. */ - if (vap->va_type == VREG) { - sb->st_blksize = vap->va_blocksize; - } else if (vn_isdisk(vp, NULL)) { + if (vn_isdisk(vp, NULL)) { sb->st_blksize = vp->v_rdev->si_bsize_best; if (sb->st_blksize < vp->v_rdev->si_bsize_phys) sb->st_blksize = vp->v_rdev->si_bsize_phys; if (sb->st_blksize < BLKDEV_IOSIZE) sb->st_blksize = BLKDEV_IOSIZE; - } else { - sb->st_blksize = 0; - } + } else + sb->st_blksize = vap->va_blocksize; + + if (sb->st_blksize == 0) + sb->st_blksize = PAGE_SIZE; sb->st_flags = vap->va_flags; if (suser_xxx(td->td_proc->p_ucred, 0, 0)) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message