From owner-svn-src-all@FreeBSD.ORG Sun Feb 13 10:51:35 2011 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D1BCC1065679; Sun, 13 Feb 2011 10:51:35 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail01.syd.optusnet.com.au (mail01.syd.optusnet.com.au [211.29.132.182]) by mx1.freebsd.org (Postfix) with ESMTP id 5688A8FC14; Sun, 13 Feb 2011 10:51:34 +0000 (UTC) Received: from c122-107-114-89.carlnfd1.nsw.optusnet.com.au (c122-107-114-89.carlnfd1.nsw.optusnet.com.au [122.107.114.89]) by mail01.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p1DApVa6002454 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 13 Feb 2011 21:51:32 +1100 Date: Sun, 13 Feb 2011 21:51:31 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov In-Reply-To: <201102121312.p1CDCjhD002584@svn.freebsd.org> Message-ID: <20110213213251.B1474@besplex.bde.org> References: <201102121312.p1CDCjhD002584@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r218603 - head/sbin/tunefs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Feb 2011 10:51:35 -0000 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