Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin disklabel now understands the p_sgs partition field (sh...



details:   https://anonhg.NetBSD.org/src/rev/7a59cc012a03
branches:  trunk
changeset: 480694:7a59cc012a03
user:      perseant <perseant%NetBSD.org@localhost>
date:      Tue Jan 18 00:02:28 2000 +0000

description:
disklabel now understands the p_sgs partition field (shift to compute
segment size from block size).

newfs_lfs now reads the disklabel to find segment, block, and fragment
sizes.  Because reading this info from the wrong fs type could result in
very poor fs layout (e.g. ffs has "16" where the segshift would go,
resulting in 512-*megabyte* segments for 8K blocks), newfs_lfs refuses
to create a filesystem on a partition not labeled "4.4LFS".

Man pages for newfs_lfs updated to reflect this change.

diffstat:

 sbin/disklabel/disklabel.c |  16 ++++++++++++++--
 sbin/newfs_lfs/lfs.c       |  30 +++++++++++++++++++++++-------
 sbin/newfs_lfs/newfs_lfs.8 |  16 ++++++++++++----
 3 files changed, 49 insertions(+), 13 deletions(-)

diffs (141 lines):

diff -r 96a6c989c849 -r 7a59cc012a03 sbin/disklabel/disklabel.c
--- a/sbin/disklabel/disklabel.c        Mon Jan 17 21:59:43 2000 +0000
+++ b/sbin/disklabel/disklabel.c        Tue Jan 18 00:02:28 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disklabel.c,v 1.79 1999/12/20 18:19:18 fair Exp $      */
+/*     $NetBSD: disklabel.c,v 1.80 2000/01/18 00:02:28 perseant Exp $  */
 
 /*
  * Copyright (c) 1987, 1993
@@ -47,7 +47,7 @@
 static char sccsid[] = "@(#)disklabel.c        8.4 (Berkeley) 5/4/95";
 /* from static char sccsid[] = "@(#)disklabel.c        1.2 (Symmetric) 11/28/85"; */
 #else
-__RCSID("$NetBSD: disklabel.c,v 1.79 1999/12/20 18:19:18 fair Exp $");
+__RCSID("$NetBSD: disklabel.c,v 1.80 2000/01/18 00:02:28 perseant Exp $");
 #endif
 #endif /* not lint */
 
@@ -1220,6 +1220,11 @@
                                break;
 
                        case FS_BSDLFS:
+                               (void) fprintf(f, "    %5d %5d %5d ",
+                                   pp->p_fsize, pp->p_fsize * pp->p_frag,
+                                   pp->p_sgs);
+                               break;
+
                        case FS_EX2FS:
                                (void) fprintf(f, "    %5d %5d       ",
                                    pp->p_fsize, pp->p_fsize * pp->p_frag);
@@ -1686,6 +1691,13 @@
                                NXTNUM(pp->p_cpg);
                                break;
                        case FS_BSDLFS:
+                               NXTNUM(pp->p_fsize);
+                               if (pp->p_fsize == 0)
+                                       break;
+                               NXTNUM(v);
+                               pp->p_frag = v / pp->p_fsize;
+                               NXTNUM(pp->p_sgs);
+                               break;
                        case FS_EX2FS:
                                NXTNUM(pp->p_fsize);
                                if (pp->p_fsize == 0)
diff -r 96a6c989c849 -r 7a59cc012a03 sbin/newfs_lfs/lfs.c
--- a/sbin/newfs_lfs/lfs.c      Mon Jan 17 21:59:43 2000 +0000
+++ b/sbin/newfs_lfs/lfs.c      Tue Jan 18 00:02:28 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs.c,v 1.6 1999/11/05 18:59:12 perseant Exp $ */
+/*     $NetBSD: lfs.c,v 1.7 2000/01/18 00:02:29 perseant Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -38,11 +38,12 @@
 #if 0
 static char sccsid[] = "@(#)lfs.c      8.5 (Berkeley) 5/24/95";
 #else
-__RCSID("$NetBSD: lfs.c,v 1.6 1999/11/05 18:59:12 perseant Exp $");
+__RCSID("$NetBSD: lfs.c,v 1.7 2000/01/18 00:02:29 perseant Exp $");
 #endif
 #endif /* not lint */
 
 #include <sys/param.h>
+#define FSTYPENAMES
 #include <sys/disklabel.h>
 #include <sys/time.h>
 #include <sys/mount.h>
@@ -228,12 +229,21 @@
 
        lfsp = &lfs_default;
 
+       /* If partition is not an LFS partition, warn that that is the case */
+       if(partp->p_fstype != FS_BSDLFS) {
+               fatal("partition label indicated fs type \"%s\", expected \"%s\"",
+                     fstypenames[partp->p_fstype], fstypenames[FS_BSDLFS]);
+       }
+
        if (!(bsize = block_size))
-               bsize = DFL_LFSBLOCK;
+               if (!(bsize = partp->p_fsize * partp->p_frag))
+                       bsize = DFL_LFSBLOCK;
        if (!(fsize = frag_size))
-               fsize = DFL_LFSFRAG;
+               if (!(fsize = partp->p_frag))
+                       fsize = DFL_LFSFRAG;
        if (!(ssize = seg_size))
-               ssize = DFL_LFSSEG;
+               if (!(ssize = (partp->p_fsize * partp->p_frag) << partp->p_sgs))
+                       ssize = DFL_LFSSEG;
 
        /* Sanity check: fsize<=bsize<ssize */
        if (fsize > bsize) {
@@ -242,8 +252,14 @@
                        fatal("fragment size must be <= block size %d", bsize);
                fsize = bsize;
        }
-       if (bsize >= ssize)
-               fatal("block size must be < segment size");
+       if (bsize >= ssize) {
+               /* Only fatal if ssize was explicitly set */
+               if(seg_size)
+                       fatal("block size must be < segment size");
+               warnx("%s: disklabel segment size (%d) too small, using default (%d)",
+                     progname, ssize, DFL_LFSSEG);
+               ssize = DFL_LFSSEG;
+       }
 
     tryagain:
        /* Modify parts of superblock overridden by command line arguments */
diff -r 96a6c989c849 -r 7a59cc012a03 sbin/newfs_lfs/newfs_lfs.8
--- a/sbin/newfs_lfs/newfs_lfs.8        Mon Jan 17 21:59:43 2000 +0000
+++ b/sbin/newfs_lfs/newfs_lfs.8        Tue Jan 18 00:02:28 2000 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: newfs_lfs.8,v 1.3 2000/01/16 00:44:59 hubertf Exp $
+.\"    $NetBSD: newfs_lfs.8,v 1.4 2000/01/18 00:02:29 perseant Exp $
 .\"
 .\" Copyright (c) 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -56,11 +56,19 @@
 The following options define the general layout policies.
 .Bl -tag -width Fl
 .It Fl B
-The logical segment size of the file system in bytes.
+The logical segment size of the file system in bytes.  If not specified,
+the segment size is computed by left-shifting the partition label's block
+size by the amount indicated in the partition table's segshift.  (A reasonable
+value for the segshift field in the disklabel is 7, which gives 1M segments
+for 8K blocks.)
 .It Fl b Ar block-size
-The block size of the file system in bytes.
+The block size of the file system in bytes.  If not specified, the block
+size is taken from the partition label, or if the partition label
+indicates 0, a compile-time default of 8K is used.
 .It Fl f Ar fragment-size
-The fragment size of the file system in bytes.
+The fragment size of the file system in bytes.  If not specified,
+the fragment size is taken from the partition label, or if the partition
+label indicates 0, a compile-time default of 1K is used.
 .It Fl L
 Create a log-structured file system (LFS).  This is the default, and this
 option is provided for compatibility only.



Home | Main Index | Thread Index | Old Index