From owner-freebsd-stable Fri May 24 9:19:55 2002 Delivered-To: freebsd-stable@freebsd.org Received: from naxos.pdb.sbs.de (naxos.pdb.sbs.de [192.109.3.5]) by hub.freebsd.org (Postfix) with ESMTP id 76CBE37B400 for ; Fri, 24 May 2002 09:19:46 -0700 (PDT) Received: from trolli.pdb.fsc.net (ThisAddressDoesNotExist [172.25.97.20] (may be forged)) by naxos.pdb.sbs.de (8.11.2/8.11.2) with ESMTP id g4OGJh611432 for ; Fri, 24 May 2002 18:19:43 +0200 Received: from deejai2.mch.fsc.net (deejai2.mch.fsc.net [172.25.124.236]) by trolli.pdb.fsc.net (8.9.3/8.9.3) with ESMTP id SAA03810 for ; Fri, 24 May 2002 18:19:44 +0200 Received: (from root@localhost) by deejai2.mch.fsc.net (8.12.3/8.12.2) id g4OGJij6016323 for freebsd-stable@freebsd.org; Fri, 24 May 2002 18:19:44 +0200 (CEST) (envelope-from martin@deejai2.mch.fsc.net) Received: from deejai2.mch.fsc.net (localhost6 [IPv6:::1]) by deejai2.mch.fsc.net (8.12.3/8.12.3) with ESMTP id g4OGJfR8016312 for ; Fri, 24 May 2002 18:19:41 +0200 (CEST) (envelope-from martin@deejai2.mch.fsc.net) Received: (from martin@localhost) by deejai2.mch.fsc.net (8.12.3/8.12.3/Submit) id g4OGJet1016311 for freebsd-stable@FreeBSD.ORG; Fri, 24 May 2002 18:19:40 +0200 (CEST) Date: Fri, 24 May 2002 18:19:40 +0200 From: Martin Kraemer To: freebsd-stable@freebsd.org Subject: Re: newfs now defaults to fragsize == blksize == 16k?!? Message-ID: <20020524181940.A15918@deejai2.mch.fsc.net> References: <20020524164214.A8063@deejai2.mch.fsc.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020524164214.A8063@deejai2.mch.fsc.net>; from Martin.Kraemer@Fujitsu-Siemens.com on Fri, May 24, 2002 at 04:42:14PM +0200 X-Operating-System: FreeBSD 4.6-PRERELEASE FreeBSD 4.6-PRERELEASE X-Organization: Fujitsu Siemens Computers (Muenchen, Germany) X-Disclaimer: THE COMMENTS CONTAINED IN THIS MESSAGE REFLECT THE VIEWS OF THE WRITER AND ARE NOT NECESSARILY THE VIEWS OF FUJITSU-SIEMENS COMPUTERS X-No-Junk-Mail: I do not want to get *any* junk mail. X-Virus-Scanned: by AMaViS perl-11 Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, May 24, 2002 at 04:42:14PM +0200, Martin Kraemer wrote: > > Closer analysis showed me that the default fragsize in newfs > seems to be 16kB now (identical to blksize). :-(( Even closer inspection shows that this is a bug in disklabel, not in newfs. In disklabel.c, a new disk is initialized thusly: disklabel.c: 83 /* FIX! These are too low, but are traditional */ 84 #define DEFAULT_NEWFS_BLOCK 8192U 85 #define DEFAULT_NEWFS_FRAG 1024U 86 #define DEFAULT_NEWFS_CPG 16U 87 88 #define BIG_NEWFS_BLOCK 16384U 89 #define BIG_NEWFS_FRAG 4096U 90 #define BIG_NEWFS_CPG 64U ... 1281 /* 1282 * FIX! poor attempt at 1283 * adaptive 1284 */ 1285 /* 1 GB */ 1286 if (pp->p_size < 1*1024*1024*1024/lp->d_secsize) { 1287 /* FIX! These are too low, but are traditional */ 1288 pp->p_fsize = DEFAULT_NEWFS_BLOCK; 1289 pp->p_frag = (unsigned char) DEFAULT_NEWFS_FRAG; 1290 pp->p_cpg = DEFAULT_NEWFS_CPG; 1291 } else { 1292 pp->p_fsize = BIG_NEWFS_BLOCK; 1293 pp->p_frag = (unsigned char) BIG_NEWFS_FRAG; 1294 pp->p_cpg = BIG_NEWFS_CPG; 1295 } But p_fsize is the fragment size (here set to 8k/16k depending on the total disk size) by default. IMHO a logic similar to this snippet from disklabel.c: 1265 pp->p_frag = v / pp->p_fsize; must be used instead, like (concept only, not checked): > /* > * FIX! poor attempt at > * adaptive > */ > /* 1 GB */ > if (pp->p_size < 1*1024*1024*1024/lp->d_secsize) { > /* FIX! These are too low, but are traditional */ > pp->p_fsize = DEFAULT_NEWFS_FRAG; /* @@@ was: DEFAULT_NEWFS_BLOCK */ > pp->p_frag = (unsigned char) (DEFAULT_NEWFS_BLOCK / DEFAULT_NEWFS_FRAG); /* was: DEFAULT_NEWFS_FRAG */ > pp->p_cpg = DEFAULT_NEWFS_CPG; > } else { > pp->p_fsize = BIG_NEWFS_FRAG; /* @@@ was: BIG_NEWFS_BLOCK */ > pp->p_frag = (unsigned char) (BIG_NEWFS_BLOCK / BIG_NEWFS_FRAG); /* was: BIG_NEWFS_FRAG */ > pp->p_cpg = BIG_NEWFS_CPG; > } See also the comments in: /usr/include/sys/disklabel.h: u_int32_t p_fsize; /* filesystem basic fragment size */ /usr/include/sys/disklabel.h: u_int8_t p_frag; /* filesystem fragments per block */ /usr/include/disktab.h: short p_fsize; /* frag size in bytes */ And newfs copies (in absense of an explicit switch) these values into the new fs. newfs.c: 528 if (fsize == 0) { 529 fsize = pp->p_fsize; ------------^^^^^^^^^^^^^^^^^^^^ Here. 530 if (fsize <= 0) 531 fsize = MAX(DFL_FRAGSIZE, lp->d_secsize); 532 } BTW: This is how I got the strange values: a) I had used "disklabel -e" and edited the ascii copy # size offset fstype [fsize bsize bps/cpg] a: 2G * 4.2BSD b: 2G * 4.2BSD .... etc. -- but I left the [fsize bsize bps/cpg] empty. b) "disklabel -e" created this output from the empty input: # size offset fstype [fsize bsize bps/cpg] a: 4194304 0 4.2BSD 16384 16384 389 # (Cyl. 0 - 4161*) b: 4194304 4194304 4.2BSD 16384 16384 389 # (Cyl. 4161*- 8322*) .... etc. Soo: it was disklabel that broke the frags. c) newfs used the values that "disklabel" had left :-( Hope this helps, Martin -- | Fujitsu Siemens Fon: +49-89-636-46021, FAX: +49-89-636-47655 | 81730 Munich, Germany To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message