Source-Changes-HG archive

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

[src/trunk]: src/sbin/fsck_ffs Try to cope with cs_ndir being wacky (too larg...



details:   https://anonhg.NetBSD.org/src/rev/6d04468764e9
branches:  trunk
changeset: 501914:6d04468764e9
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Tue Jan 09 05:39:27 2001 +0000

description:
Try to cope with cs_ndir being wacky (too large or, particularly when using -b,
too damn small) by setting a minimum (1024) and maximum (maxino + 1).  This
prevents certain operations getting REALLY slow when -b is used, and also
avoids overallocating memory if the superblock is hosed.

diffstat:

 sbin/fsck_ffs/setup.c |  14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diffs (36 lines):

diff -r f58d3e1bda2a -r 6d04468764e9 sbin/fsck_ffs/setup.c
--- a/sbin/fsck_ffs/setup.c     Tue Jan 09 05:06:14 2001 +0000
+++ b/sbin/fsck_ffs/setup.c     Tue Jan 09 05:39:27 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: setup.c,v 1.38 2001/01/05 02:02:57 lukem Exp $ */
+/*     $NetBSD: setup.c,v 1.39 2001/01/09 05:39:27 mycroft Exp $       */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)setup.c    8.10 (Berkeley) 5/9/95";
 #else
-__RCSID("$NetBSD: setup.c,v 1.38 2001/01/05 02:02:57 lukem Exp $");
+__RCSID("$NetBSD: setup.c,v 1.39 2001/01/09 05:39:27 mycroft Exp $");
 #endif
 #endif /* not lint */
 
@@ -413,7 +413,17 @@
                    (unsigned)((maxino + 1) * sizeof(int16_t)));
                goto badsblabel;
        }
+       /*
+        * cs_ndir may be inaccurate, particularly if we're using the -b
+        * option, so set a minimum to prevent bogus subdirectory reconnects
+        * and really inefficient directory scans.
+        * Also set a maximum in case the value is too large.
+        */
        numdirs = sblock->fs_cstotal.cs_ndir;
+       if (numdirs < 1024)
+               numdirs = 1024;
+       if (numdirs > maxino + 1)
+               numdirs = maxino + 1;
        inplast = 0;
        listmax = numdirs + 10;
        inpsort = (struct inoinfo **)calloc((unsigned)listmax,



Home | Main Index | Thread Index | Old Index