From owner-freebsd-fs@FreeBSD.ORG Mon Feb 5 15:28:49 2007 Return-Path: X-Original-To: freebsd-fs@FreeBSD.ORG Delivered-To: freebsd-fs@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2E5AC16A402 for ; Mon, 5 Feb 2007 15:28:49 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [83.120.8.8]) by mx1.freebsd.org (Postfix) with ESMTP id 8EC4213C467 for ; Mon, 5 Feb 2007 15:28:48 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (dixgpk@localhost [127.0.0.1]) by lurza.secnetix.de (8.13.4/8.13.4) with ESMTP id l15FSf7c085773; Mon, 5 Feb 2007 16:28:47 +0100 (CET) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.13.4/8.13.1/Submit) id l15FSfsj085766; Mon, 5 Feb 2007 16:28:41 +0100 (CET) (envelope-from olli) Date: Mon, 5 Feb 2007 16:28:41 +0100 (CET) Message-Id: <200702051528.l15FSfsj085766@lurza.secnetix.de> From: Oliver Fromme To: freebsd-fs@FreeBSD.ORG, ticso@cicely.de In-Reply-To: <20070203130226.GO70860@cicely12.cicely.de> X-Newsgroups: list.freebsd-fs User-Agent: tin/1.8.2-20060425 ("Shillay") (UNIX) (FreeBSD/4.11-STABLE (i386)) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Mon, 05 Feb 2007 16:28:47 +0100 (CET) Cc: Subject: Re: Mysterious block count (reproducible) 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: Mon, 05 Feb 2007 15:28:49 -0000 Bernd Walter wrote: > Oliver Fromme wrote: > > [...] > > $ BLOCKSIZE=16K ls -s foo > > 15 foo > > # fsdb -r /dev/md0 > > [...] > > fsdb (inum: 5)> blocks > > Blocks for inode 5: > > Direct blocks: > > 2136, 2144, 2152, 2160, 2168, 2176, 2184, 2192, 2248, 2256, 2264, 2272 > > Indirect blocks: > > 2280, 2288, > > fsdb (inum: 5)> > > > > It lists 12 direct blocks and 2 indirect blocks, that's > > still 14 blocks, not 15. > > > > Where did the 15th block go?!? Or is there a bug in > > the calculation of ls -s output? (Meanwhile I found out that ls(1) doesn't really calculate anything; it simply displays the st_blocks value from the stat structure rounded to $BLOCKSIZE, of course.) > Don't forget the block needed for the indirect table. > fsdb only shows data blocks it seems. Oh, OK ... I really assumed that fsdb would display them as soon as they come into play. :-( What I'm trying to do is to write a small script that calculates the allocation vs. virtual size ratio of sparse files. For that purpose I have to find out how many blocks a file would require if it wasn't sparse. Is there are an easy way to get that information? I have currently hardcoded some information in the script, but it's an ugly hack: http://www.secnetix.de/~olli/scripts/sparsecheck Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, USt-Id: DE204219783 Any opinions expressed in this message are personal to the author and may not necessarily reflect the opinions of secnetix GmbH & Co KG in any way. FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd "IRIX is about as stable as a one-legged drunk with hypothermia in a four-hundred mile per hour wind, balancing on a banana peel on a greased cookie sheet -- when someone throws him an elephant with bad breath and a worse temper." -- Ralf Hildebrandt