Tue Jan 17 16:27:19 2012 UTC ()
Use an even smaller segment size when creating a very small filesystem.
This allows the lfs_renamerace_dirs case of the t_renamerace test to
fail correctly, rather than with a bogus "file system full" error as it
has since rev 1.135 of sys/ufs/lfs/lfs.h.


(perseant)
diff -r1.16 -r1.17 src/sbin/newfs_lfs/make_lfs.c

cvs diff -r1.16 -r1.17 src/sbin/newfs_lfs/make_lfs.c (expand / switch to unified diff)

--- src/sbin/newfs_lfs/make_lfs.c 2010/02/16 23:20:30 1.16
+++ src/sbin/newfs_lfs/make_lfs.c 2012/01/17 16:27:19 1.17
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: make_lfs.c,v 1.16 2010/02/16 23:20:30 mlelstv Exp $ */ 1/* $NetBSD: make_lfs.c,v 1.17 2012/01/17 16:27:19 perseant Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2003 The NetBSD Foundation, Inc. 4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Konrad E. Schroder <perseant@hhhh.org>. 8 * by Konrad E. Schroder <perseant@hhhh.org>.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -52,27 +52,27 @@ @@ -52,27 +52,27 @@
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * SUCH DAMAGE. 57 * SUCH DAMAGE.
58 */ 58 */
59 59
60#include <sys/cdefs.h> 60#include <sys/cdefs.h>
61#ifndef lint 61#ifndef lint
62#if 0 62#if 0
63static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95"; 63static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95";
64#else 64#else
65__RCSID("$NetBSD: make_lfs.c,v 1.16 2010/02/16 23:20:30 mlelstv Exp $"); 65__RCSID("$NetBSD: make_lfs.c,v 1.17 2012/01/17 16:27:19 perseant Exp $");
66#endif 66#endif
67#endif /* not lint */ 67#endif /* not lint */
68 68
69#include <sys/param.h> 69#include <sys/param.h>
70#include <sys/disk.h> 70#include <sys/disk.h>
71#include <sys/time.h> 71#include <sys/time.h>
72#include <sys/mount.h> 72#include <sys/mount.h>
73#include <sys/stat.h> 73#include <sys/stat.h>
74 74
75#include <ufs/ufs/dir.h> 75#include <ufs/ufs/dir.h>
76#include <ufs/ufs/quota.h> 76#include <ufs/ufs/quota.h>
77#include <ufs/ufs/inode.h> 77#include <ufs/ufs/inode.h>
78 78
@@ -478,48 +478,50 @@ make_lfs(int devfd, uint secsize, struct @@ -478,48 +478,50 @@ make_lfs(int devfd, uint secsize, struct
478 fs->lfs_minfreeseg = fs->lfs_nseg / DFL_MIN_FREE_SEGS; 478 fs->lfs_minfreeseg = fs->lfs_nseg / DFL_MIN_FREE_SEGS;
479 else 479 else
480 fs->lfs_minfreeseg = minfreeseg; 480 fs->lfs_minfreeseg = minfreeseg;
481 if (fs->lfs_minfreeseg < MIN_FREE_SEGS) 481 if (fs->lfs_minfreeseg < MIN_FREE_SEGS)
482 fs->lfs_minfreeseg = MIN_FREE_SEGS; 482 fs->lfs_minfreeseg = MIN_FREE_SEGS;
483 483
484 if (resvseg == 0) 484 if (resvseg == 0)
485 fs->lfs_resvseg = fs->lfs_minfreeseg / 2 + 1; 485 fs->lfs_resvseg = fs->lfs_minfreeseg / 2 + 1;
486 else 486 else
487 fs->lfs_resvseg = resvseg; 487 fs->lfs_resvseg = resvseg;
488 if (fs->lfs_resvseg < MIN_RESV_SEGS) 488 if (fs->lfs_resvseg < MIN_RESV_SEGS)
489 fs->lfs_resvseg = MIN_RESV_SEGS; 489 fs->lfs_resvseg = MIN_RESV_SEGS;
490 490
491 if(fs->lfs_nseg < fs->lfs_minfreeseg + 1 491 if(fs->lfs_nseg < (3 * CM_MAG_NUM * fs->lfs_minfreeseg) / CM_MAG_DEN + 1
492 || fs->lfs_nseg < LFS_MIN_SBINTERVAL + 1) 492 || fs->lfs_nseg < LFS_MIN_SBINTERVAL + 1)
493 { 493 {
494 if(seg_size == 0 && ssize > (bsize<<1)) { 494 if(seg_size == 0 && ssize > (bsize<<1)) {
495 if(!warned_segtoobig) { 495 if(!warned_segtoobig) {
496 fprintf(stderr,"Segment size %d is too large; " 496 fprintf(stderr,"Segment size %d is too large; "
497 "trying smaller sizes.\n", ssize); 497 "trying smaller sizes.\n", ssize);
498 if (ssize == (bsize << 16)) { 498 if (ssize == (bsize << 16)) {
499 fprintf(stderr, "(Did you perhaps " 499 fprintf(stderr, "(Did you perhaps "
500 "accidentally leave \"16\" " 500 "accidentally leave \"16\" "
501 "in the disklabel's sgs " 501 "in the disklabel's sgs "
502 "field?)\n"); 502 "field?)\n");
503 } 503 }
504 } 504 }
505 ++warned_segtoobig; 505 ++warned_segtoobig;
506 ssize >>= 1; 506 ssize >>= 1;
507 goto tryagain; 507 goto tryagain;
508 } 508 }
509 fatal("Could not allocate enough segments with segment " 509 fatal("Could not allocate enough segments with segment "
510 "size %d and block size %d;\nplease decrease the " 510 "size %d and block size %d;\nplease decrease the "
511 "segment size.\n", ssize, fs->lfs_bsize); 511 "segment size.\n", ssize, fs->lfs_bsize);
512 } 512 }
 513 if(warned_segtoobig)
 514 fprintf(stderr,"Using segment size %d.\n", ssize);
513 515
514 /* 516 /*
515 * Now that we've determined what we're going to do, announce it 517 * Now that we've determined what we're going to do, announce it
516 * to the user. 518 * to the user.
517 */ 519 */
518 printf("Creating a version %d LFS", fs->lfs_version); 520 printf("Creating a version %d LFS", fs->lfs_version);
519 if (fs->lfs_version > 1) 521 if (fs->lfs_version > 1)
520 printf(" with roll-forward ident 0x%x", fs->lfs_ident); 522 printf(" with roll-forward ident 0x%x", fs->lfs_ident);
521 printf("\n");  523 printf("\n");
522 fssize = (double)fs->lfs_nseg; 524 fssize = (double)fs->lfs_nseg;
523 fssize *= (double)ssize; 525 fssize *= (double)ssize;
524 fssize /= 1048576.0; 526 fssize /= 1048576.0;
525 printf("%.1fMB in %d segments of size %d\n", fssize, 527 printf("%.1fMB in %d segments of size %d\n", fssize,