bug in buffer cache

Andries.Brouwer@cwi.nl
Sat, 19 Jul 1997 23:16:41 +0200


This may be well-known, I even seem to recall that I
stumbled over it myself while playing with the loop
device, but anyways..

A disk block has several identities (block 100000
on /dev/hda, block 1000 on /dev/hda3, block 120 on /tmp/x
(which is mounted as a loop device, so block 120 on /dev/loop0,
block 2 on /mnt/a, etc).

This time my complaint is about the fact that the buffer
cache (for concreteness: as found in Linux 2.0.29)
contains both block 100000 on /dev/hda and block 1000
on /dev/hda3 without realizing that this is the same block.

[Last week the discussion was about mounting disks given
a volume label, so I created e2label that writes ext2 volume
labels (see ftp.win.tue.nl:/pub/linux/misc) and upgraded
cfdisk-0.8 to show such labels. The above complaint was
caused by the fact that after changing the label with e2label,
cfdisk still showed the old label. I `fixed' this by making
cfdisk call BLKFLSBUF, but of course it should be fixed in
the kernel. (For cfdisk-0.8k, see ftp.win.tue.nl:/pub/linux/util .)]

Probably the right fix is to never refer to partitions in the
buffer cache. On the other hand, the problem does not have
high priority (usually only programs like fdisk and lilo and dd
refer to entire disks), and 2.1.45 does still not compile completely -
everybody is playing with the new dentries, so I will not try
to come with a fix now. (I have not even checked whether the
problem still exists.)
[However, sooner or later I'll submit a fix - it is an easy
but somewhat global change - so please tell me if the above
reasoning is flawed.]

Andries

[PS If you react, please cc to me (aeb@cwi.nl).
The newsgroup linux.dev.kernel is in reasonable shape these days,
but I still see many reactions to originals that never appeared here.]