Date: Mon, 04 Dec 2000 21:19:19 +0000 From: Ian Dowse <iedowse@maths.tcd.ie> To: freebsd-fs@freebsd.org Cc: iedowse@maths.tcd.ie, Kirk McKusick <mckusick@mckusick.com> Subject: SIGINFO handler for fsck(8) Message-ID: <200012042119.aa25259@salmon.maths.tcd.ie>
next in thread | raw e-mail | index | archive | help
I've had this patch lying around here for a while - it adds a simple
SIGINFO handler to fsck(8) so you can tell what it's doing by
pressing Ctrl-T. The output will be something like:
^T
load: 0.14 cmd: fsck_ufs 10473 [physstr] 2.12u 0.30s 8% 2016k
/dev/da0s1f: phase 1: cyl group 26 of 60 (43%)
^T
load: 0.12 cmd: fsck_ufs 10473 [physstr] 4.00u 0.49s 11% 2804k
/dev/da0s1f: phase 2: dir 488 of 27965 (1%)
Is this a feature we want in fsck? It doesn't really help except
to give you something to do while waiting for a huge filesystem to
be checked :-) I guess it also allows you to see if fsck is actually
getting anywhere.
Ian
Index: fsck.h
===================================================================
RCS file: /FreeBSD/FreeBSD-CVS/src/sbin/fsck_ffs/fsck.h,v
retrieving revision 1.14
diff -u -r1.14 fsck.h
--- fsck.h 2000/10/09 08:26:28 1.14
+++ fsck.h 2000/12/04 21:06:19
@@ -223,6 +223,8 @@
ufs_daddr_t n_blks; /* number of blocks in use */
ufs_daddr_t n_files; /* number of files in use */
+int got_siginfo; /* received a SIGINFO */
+
#define clearinode(dp) (*(dp) = zino)
struct dinode zino;
@@ -280,6 +282,7 @@
struct dinode *getnextinode __P((ino_t inumber));
void getpathname __P((char *namebuf, ino_t curdir, ino_t ino));
struct dinode *ginode __P((ino_t inumber));
+void infohandler __P((int sig));
void inocleanup __P((void));
void inodirty __P((void));
struct inostat *inoinfo __P((ino_t inum));
Index: main.c
===================================================================
RCS file: /FreeBSD/FreeBSD-CVS/src/sbin/fsck_ffs/main.c,v
retrieving revision 1.22
diff -u -r1.22 main.c
--- main.c 2000/10/09 08:26:28 1.22
+++ main.c 2000/12/04 21:06:19
@@ -140,6 +140,7 @@
(void)signal(SIGINT, catch);
if (preen)
(void)signal(SIGQUIT, catchquit);
+ signal(SIGINFO, infohandler);
/*
* Push up our allowed memory limit so we can cope
* with huge filesystems.
Index: pass1.c
===================================================================
RCS file: /FreeBSD/FreeBSD-CVS/src/sbin/fsck_ffs/pass1.c,v
retrieving revision 1.18
diff -u -r1.18 pass1.c
--- pass1.c 2000/07/12 06:19:22 1.18
+++ pass1.c 2000/12/04 21:06:19
@@ -89,6 +89,13 @@
inumber = c * sblock.fs_ipg;
setinodebuf(inumber);
inosused = sblock.fs_ipg;
+
+ if (got_siginfo) {
+ printf("%s: phase 1: cyl group %d of %d (%d%%)\n",
+ cdevname, c, sblock.fs_ncg,
+ c * 100 / sblock.fs_ncg);
+ got_siginfo = 0;
+ }
/*
* If we are using soft updates, then we can trust the
* cylinder group inode allocation maps to tell us which
Index: pass1b.c
===================================================================
RCS file: /FreeBSD/FreeBSD-CVS/src/sbin/fsck_ffs/pass1b.c,v
retrieving revision 1.7
diff -u -r1.7 pass1b.c
--- pass1b.c 1999/08/28 00:12:46 1.7
+++ pass1b.c 2000/12/04 21:06:19
@@ -65,6 +65,12 @@
duphead = duplist;
inumber = 0;
for (c = 0; c < sblock.fs_ncg; c++) {
+ if (got_siginfo) {
+ printf("%s: phase 1c: cyl group %d of %d (%d%%)\n",
+ cdevname, c, sblock.fs_ncg,
+ c * 100 / sblock.fs_ncg);
+ got_siginfo = 0;
+ }
for (i = 0; i < sblock.fs_ipg; i++, inumber++) {
if (inumber < ROOTINO)
continue;
Index: pass2.c
===================================================================
RCS file: /FreeBSD/FreeBSD-CVS/src/sbin/fsck_ffs/pass2.c,v
retrieving revision 1.10
diff -u -r1.10 pass2.c
--- pass2.c 1999/08/28 00:12:46 1.10
+++ pass2.c 2000/12/04 21:06:19
@@ -134,6 +134,12 @@
dp = &dino;
inpend = &inpsort[inplast];
for (inpp = inpsort; inpp < inpend; inpp++) {
+ if (got_siginfo) {
+ printf("%s: phase 2: dir %d of %d (%d%%)\n", cdevname,
+ inpp - inpsort, inplast, (inpp - inpsort) * 100 /
+ inplast);
+ got_siginfo = 0;
+ }
inp = *inpp;
if (inp->i_isize == 0)
continue;
Index: pass3.c
===================================================================
RCS file: /FreeBSD/FreeBSD-CVS/src/sbin/fsck_ffs/pass3.c,v
retrieving revision 1.7
diff -u -r1.7 pass3.c
--- pass3.c 1999/08/28 00:12:47 1.7
+++ pass3.c 2000/12/04 21:06:20
@@ -59,6 +59,12 @@
char namebuf[MAXNAMLEN+1];
for (inpindex = inplast - 1; inpindex >= 0; inpindex--) {
+ if (got_siginfo) {
+ printf("%s: phase 3: dir %d of %d (%d%%)\n", cdevname,
+ inplast - inpindex, inplast,
+ 100 - inpindex * 100 / inplast);
+ got_siginfo = 0;
+ }
inp = inpsort[inpindex];
state = inoinfo(inp->i_number)->ino_state;
if (inp->i_number == ROOTINO ||
Index: pass4.c
===================================================================
RCS file: /FreeBSD/FreeBSD-CVS/src/sbin/fsck_ffs/pass4.c,v
retrieving revision 1.7
diff -u -r1.7 pass4.c
--- pass4.c 1999/08/28 00:12:47 1.7
+++ pass4.c 2000/12/04 21:06:20
@@ -62,6 +62,12 @@
idesc.id_type = ADDR;
idesc.id_func = pass4check;
for (cg = 0; cg < sblock.fs_ncg; cg++) {
+ if (got_siginfo) {
+ printf("%s: phase 4: cyl group %d of %d (%d%%)\n",
+ cdevname, cg, sblock.fs_ncg,
+ cg * 100 / sblock.fs_ncg);
+ got_siginfo = 0;
+ }
inumber = cg * sblock.fs_ipg;
for (i = 0; i < inostathead[cg].il_numalloced; i++, inumber++) {
if (inumber < ROOTINO)
Index: pass5.c
===================================================================
RCS file: /FreeBSD/FreeBSD-CVS/src/sbin/fsck_ffs/pass5.c,v
retrieving revision 1.18
diff -u -r1.18 pass5.c
--- pass5.c 2000/07/06 02:03:11 1.18
+++ pass5.c 2000/12/04 21:06:20
@@ -169,6 +169,12 @@
for (i = fs->fs_size; i < j; i++)
setbmap(i);
for (c = 0; c < fs->fs_ncg; c++) {
+ if (got_siginfo) {
+ printf("%s: phase 5: cyl group %d of %d (%d%%)\n",
+ cdevname, c, sblock.fs_ncg,
+ c * 100 / sblock.fs_ncg);
+ got_siginfo = 0;
+ }
getblk(&cgblk, cgtod(fs, c), fs->fs_cgsize);
if (!cg_chkmagic(cg))
pfatal("CG %d: BAD MAGIC NUMBER\n", c);
Index: utilities.c
===================================================================
RCS file: /FreeBSD/FreeBSD-CVS/src/sbin/fsck_ffs/utilities.c,v
retrieving revision 1.14
diff -u -r1.14 utilities.c
--- utilities.c 2000/10/09 09:21:04 1.14
+++ utilities.c 2000/12/04 21:07:20
@@ -101,3 +101,10 @@
*/
return (origname);
}
+
+void
+infohandler(sig)
+ int sig;
+{
+ got_siginfo = 1;
+}
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-fs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200012042119.aa25259>
