Date: Mon, 21 Jan 2002 00:17:49 +0600 From: Max Khon <fjoe@iclub.nsu.ru> To: Bruce Evans <bde@zeta.org.au> Cc: Cy Schubert - ITSD Open Systems Group <Cy.Schubert@uumail.gov.bc.ca>, Poul-Henning Kamp <phk@critter.freebsd.dk>, arch@freebsd.org Subject: Re: request for review Message-ID: <20020121001749.A80939@iclub.nsu.ru> In-Reply-To: <20020116155828.T487-100000@gamplex.bde.org>; from bde@zeta.org.au on Wed, Jan 16, 2002 at 04:18:12PM %2B1100 References: <20020116000607.B10938@iclub.nsu.ru> <20020116155828.T487-100000@gamplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020121001749.A80939>