From 28b66787e0a00a2afb945534f4d73b62f7834658 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Wed, 27 Dec 2000 22:28:40 +0000 Subject: [PATCH] When trying to deduce the diskname from the name so we can run parallel fsck's one per drive, use the shortest prefix ending in a digit rather than the longest prefix ending in a digit. This makes "/dev/ad0s1a" and "/dev/ad0s2a" appear to both reside on the disk "/dev/ad0" and consequently they will be fsck'ed sequentially rather than in parallel as now. In general this heuristic is rather soft and errorprone. For instance ccd may often reside on two or more physical disks. A good solution would be to look for passes larger than 1 until no disks are found in a particular pass, that way people could put ccd stripes in pass 3... and have them fsck'ed sequentially. Reviewed by: mjacob --- sbin/fsck/fsck.8 | 4 ++-- sbin/fsck/preen.c | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/sbin/fsck/fsck.8 b/sbin/fsck/fsck.8 index a358007e7e58..edef23e33891 100644 --- a/sbin/fsck/fsck.8 +++ b/sbin/fsck/fsck.8 @@ -65,9 +65,9 @@ Filesystems with pass number 1 (normally just the root filesystem) are checked one at a time. When pass 1 completes, all remaining filesystems are checked, running one process per disk drive. -The disk drive containing each filesystem is inferred from the longest prefix +The disk drive containing each filesystem is inferred from the shortest prefix of the device name that ends in a digit; the remaining characters are assumed -to be the partition designator. +to be the partition and slice designator. .Pp The options are as follows: .Bl -tag -width indent diff --git a/sbin/fsck/preen.c b/sbin/fsck/preen.c index bd72d6bc9b2c..e00e84e3bbc0 100644 --- a/sbin/fsck/preen.c +++ b/sbin/fsck/preen.c @@ -259,12 +259,17 @@ finddisk(name) size_t len = 0; struct diskentry *d; - for (len = strlen(name), p = name + len - 1; p >= name; --p) - if (isdigit(*p)) { - len = p - name + 1; - break; - } - if (p < name) + p = strrchr(name, '/'); + if (p == NULL) + p = name; + else + p++; + for (; *p && !isdigit(*p); p++) + continue; + for (; *p && isdigit(*p); p++) + continue; + len = p - name; + if (len == 0) len = strlen(name); TAILQ_FOREACH(d, &diskh, d_entries)