Date: Sun, 13 Feb 2011 21:51:31 +1100 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Konstantin Belousov <kib@FreeBSD.org> Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r218603 - head/sbin/tunefs Message-ID: <20110213213251.B1474@besplex.bde.org> In-Reply-To: <201102121312.p1CDCjhD002584@svn.freebsd.org> References: <201102121312.p1CDCjhD002584@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 12 Feb 2011, Konstantin Belousov wrote:
> Log:
> When creating a directory entry for the journal, always read at least
> the fragment, and write the full block. Reading less might not work
> due to device sector size bigger then size of direntries in the
> last directory fragment.
I think it should always write full fragments too (and the kernel should
always read/write in units of fragments, not sectors of any size).
> Modified: head/sbin/tunefs/tunefs.c
> ==============================================================================
> --- head/sbin/tunefs/tunefs.c Sat Feb 12 12:52:12 2011 (r218602)
> +++ head/sbin/tunefs/tunefs.c Sat Feb 12 13:12:45 2011 (r218603)
> @@ -733,16 +740,19 @@ dir_extend(ufs2_daddr_t blk, ufs2_daddr_
> {
> char block[MAXBSIZE];
>
> - if (bread(&disk, fsbtodb(&sblock, blk), block, size) <= 0) {
> + if (bread(&disk, fsbtodb(&sblock, blk), block,
> + roundup(size, sblock.fs_fsize)) <= 0) {
Rounding up to a fragment boundary is spelled fragroundup(fs, size) in
ffs. This use fs->fs_qfmask and fs->fs_fmask for optimality. It is
unclear if the kernel macros work in userland, but here we already
use fsbtodb() which uses fs->fsbtodb for optimality.
[I've just learned again about fragroundup() after trying to fix rounding
in cluster_read(). See blksize(). Since cluster_read() doesn't know
about the fragment size or the fs dependencies in blksize(), it cannot
read ahead correctly across i/o size boundaries (exactly one of which
occurs near EOF for almost all files with fragments in ffs). This bug is
missing in old breadn() -- it can even handle multiple i/o size boundaries,
since it is passed a separate size for every block.]
Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110213213251.B1474>
