Re: pre 2.0.5 2.0.6 hang with /dev/fd0

Andries.Brouwer@cwi.nl
Fri, 24 May 1996 22:03:00 +0200


Alex Gitelman:

: pre 2.0.5 and 2.0.6 always hang then I mount /dev/fd0 with minix
: and try to delete some files. File created by touch was deleted but
: files of biger size cause hang. No messages - just total freezing.
: 2.0.4 - OK.

Yes. The problem is a mix-up between signed and unsigned variables.
It was triggered by the change

diff -u --recursive --new-file pre2.0.4/linux/include/linux/fs.h linux/include/\linux/fs.h
--- pre2.0.4/linux/include/linux/fs.h Wed May 15 11:01:15 1996
+++ linux/include/linux/fs.h Fri May 17 15:05:01 1996
@@ -272,7 +272,7 @@
uid_t i_uid;
gid_t i_gid;
kdev_t i_rdev;
- off_t i_size;
+ unsigned long i_size;
time_t i_atime;
time_t i_mtime;
time_t i_ctime;

and what actually goes wrong is the code

repeat:
for (i = INDIRECT_BLOCK(offset) ; i < 512 ; i++) {
if (i < 0)
i = 0;
if (i < INDIRECT_BLOCK(offset))
goto repeat;

in minix/truncate.c. The above patch made INDIRECT_BLOCK(offset)
unsigned, and when it is negative we have a loop.

When I first noticed this loop I fixed minix/truncate.c by adding
a cast:

#define DIRECT_BLOCK (((off_t) inode->i_size + 1023) >> 10)

but maybe it is better to revert the above patch on fs.h.
I don't know why it was made (to allow 2TB files instead of 1TB ones?)
but it is too dangerous to make such changes just before 2.0.

Andries