The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: jnc@mercury.lcs.mit.edu (Noel Chiappa)
Subject: [TUHS] Bugs in V6 'dcheck'
Date: Sat, 31 May 2014 11:55:27 -0400 (EDT)	[thread overview]
Message-ID: <20140531155527.39A3B18C09C@mercury.lcs.mit.edu> (raw)

    > From: jnc at mercury.lcs.mit.edu (Noel Chiappa)

    > the second (the un-initialized variable) should have happened every
    > time.

OK, so I was wrong! The variable in question was a global static, 'ino' (the
current inode number), so the answer isn't something simple like 'it was an
auto that happened to be cleared for each disk'. But now that I look closely,
I think I see a way it might have worked.


'dcheck' is a two-pass per disk thing: it begins each disk by clearing its
'inode link count' table; then the first pass does a pass over all the inodes,
and for ones that are directories, increments counts for all the entries; the
second pass re-scans all the inodes, and makes sure that the link count in the
inode itself matches the computed count in the table.

'ino' was cleared before the _second_ pass, but not the _first_. So it was
zero for the first pass of the first disk, but non-zero for the first pass on
the second disk.

This looks like the kind of bug that should almost always be fatal, right?
That's what I thought at first... (and I tried the original version on one of
my machines to make sure it did fail). But...


The loop in each pass has two index variables, one of which is 'ino', which it
compares with the maximum inode number for that disk (per the super-block),
and bails if it reaches the max:

	      for(i=0; ino<nfiles; i =+ NIBLK)

If the first disk is _larger_ than the second, the first pass will never
execute at all for the second desk (producing errors).

However, if the _second_ is larger, then the second disk's first pass will in
fact examine the starting (nfilesSUBsecond - nfilesSUBfirst) inodes of the
second disk to see if they are directories (and if so, count their links).

So if the last nfilesSUBfirst inodes of the second disk are empty (which is
often the case with large drives - I had modified 'df' to count the free
inodes as well as disk blocks, and after doing so I noticed that Unix seems to
be quite generous in its default inode allocations), it will in fact work!

The fact that 'ino' is wrong all throughout the first pass of the second disk
(it counts up from nfilesSUBfirst to nfilesSUBsecond) turns out to be
harmless, because the first pass never uses the current inode number, it only
looks at the inode numbers in the directories.


Note that with two disks of _equal size_, it fails. Only if the second is
larger does it work! (And this generalizes out to N disks - as long as each
one is enough larger than the one before!) So for the config they were
running (rk2, dp0) it probably did in fact work!

   Noel



             reply	other threads:[~2014-05-31 15:55 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-31 15:55 Noel Chiappa [this message]
2014-05-31 16:18 ` Ron Natalie
  -- strict thread matches above, loose matches on Subject: below --
2014-06-03 17:33 Nelson H. F. Beebe
2014-06-02  3:34 Noel Chiappa
2014-06-02  4:05 ` Mary Ann Horton
2014-06-02  6:12 ` arnold
2014-06-03 12:11 ` emanuel stiebler
2014-06-02  3:18 Noel Chiappa
2014-06-02  2:14 Michael Spacefalcon
2014-06-02  2:51 ` John Cowan
2014-05-31 23:24 Doug McIlroy
2014-06-01  0:17 ` Kevin Schoedel
2014-06-01 22:54   ` scj
2014-06-01 23:48 ` A. P. Garcia
2014-06-02  1:11   ` Ronald Natalie
2014-06-02  2:10     ` A. P. Garcia
2014-06-03 16:38 ` Nelson H. F. Beebe
2014-05-31 14:19 Noel Chiappa
2014-05-31 13:30 Norman Wilson
2014-05-31 16:03 ` John Cowan
     [not found]   ` <20140531161620.GL28034@mcvoy.com>
2014-05-31 17:16     ` John Cowan
2014-05-31 13:15 Noel Chiappa
2014-05-31 13:23 ` Ronald Natalie
2014-05-31 18:58 ` Tim Newsham
2014-05-31 19:48 ` Clem Cole

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140531155527.39A3B18C09C@mercury.lcs.mit.edu \
    --to=jnc@mercury.lcs.mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).