From owner-freebsd-fs@FreeBSD.ORG Wed Apr 22 10:22:59 2009 Return-Path: Delivered-To: freebsd-fs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 48C79106566C for ; Wed, 22 Apr 2009 10:22:59 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail06.syd.optusnet.com.au (mail06.syd.optusnet.com.au [211.29.132.187]) by mx1.freebsd.org (Postfix) with ESMTP id DC7C88FC0C for ; Wed, 22 Apr 2009 10:22:58 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c122-107-120-227.carlnfd1.nsw.optusnet.com.au (c122-107-120-227.carlnfd1.nsw.optusnet.com.au [122.107.120.227]) by mail06.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id n3MAMs0w024718 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 22 Apr 2009 20:22:56 +1000 Date: Wed, 22 Apr 2009 20:22:54 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: "litepc.com" In-Reply-To: <49EF5C55.7178.1CEB83C@sb345.litepc.com> Message-ID: <20090422190944.K59813@delplex.bde.org> References: <49EF5C55.7178.1CEB83C@sb345.litepc.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-fs@FreeBSD.org Subject: Re: Clarrification on fs block size X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Apr 2009 10:22:59 -0000 On Wed, 22 Apr 2009, litepc.com wrote: > I'm trying to to track down files that are using bad disk blocks as > reported by SMART drive tests > > I'm struggling indentifying which inodes are using which disk sectors > because the various utilities appear to define "blocks" differently. > > In the context of smartctl, fdisk, and bsdlabel a "disk block" is a > 512 byte sector > > In the context of UFS file system a "file system block" is 16384 > bytes and a "fragment" is 2048 bytes Actually, ffs has 2 types of blocks, "logical blocks" of configurable size (default 16384) and ordinary "blocks" ("fragments") of configurable size (default 2048). Logical blocks are used mainly within files and ordinary blocks are used in most other contexts, in particular for all block numbers in metadata. Block numbers in metadata need to have the smaller units so that they can address fragments. > So to my mind this means there are 32 x 512byte blocks in each 16384 > byte file system block. > > However... > > dumpfs reports "fsbtodb 2" which means a disk block = file system > block * 2^2 so there are 4 disk blocks in each file system block - > this is verified using the fsdb "blocks" command to list block > numbers assigned to an inode...which then must be multiplied by 4 to > use the fsdb "findblk" command to find the correct inode. 4 is the conversion factor for ordinary ffs blocks of size 2048 and virtual disk blocks of size 512 (actual disk blocks may have a different size though 512 is normal (perhaps due to virtualization in the disk itself). > Which seems to indicate that a "file system block" to dumpfs and fsdb > must be equivalent to a 2048 byte "fragment". Is this correct? Yes. > What is confusing is that if dumpfs reports "bsize" as 16384 then the > "b" in "bsize" and "b" in "fsbtodb" appear to be different "block" > definitions. It's confusing in ffs sources too. > I want to be sure that I can take the identified currupt LBA address > in smartctl, then locate the correct file system and adjusted offset > using bsdlabel and then plug this block number straight into fsdb's > "findblk" command to identify which inode owns the corrupted block. > If fsdb's findblk is expecting some other definition of "disk block" > then its not going to locate the correct inode! "findblk" seems to convert from and to virtual disk block units, so you don't need to know anything about either of ffs's. This is a strange interface since its blocks have different units from the ordinary block numbers printed by the "blocks" command. "findblk" seems to be the only command in fsdb that does these conversions. Bruce