Another loop device bug (2.0)

Bruce Elliott (belliott@accessone.com)
Thu, 20 Jun 1996 22:04:43 PDT


Someone noted in a recent message (which I no longer have) that the loop
device failed when used with a another block device. As others pointed
out, block devices are supported.

Some testing produced rather bad results. Copying an 8.5 MB filesystem
containing about 700 files into a new ext2 partition with cpio failed on
each attempt. Two types of errors occurred - missing names that should
have been in directories, and improperly updated allocation bitmaps.

It appears that directory (or bitmap) blocks were reread from the lower-
level real device _before_ a previously updated block had been written
out. The real problem is that the underlying block was not marked as
"up-to-date", so the loop logic reread it.

The included patch seems to fix this. It has been tested by copying a
filesystem of 370 MB and about 20000 files. The filesystem was then
unmounted, remounted (again through the loop device), and all files
matched with "cmp".

========================================================================
--- linux/drivers/block/loop.c.orig Sun May 5 21:28:51 1996
+++ linux/drivers/block/loop.c Thu Jun 20 00:29:45 1996
@@ -225,8 +225,10 @@
brelse(bh);
goto error_out;
}
- if (CURRENT->cmd == WRITE)
+ if (CURRENT->cmd == WRITE) {
+ mark_buffer_uptodate(bh, 1);
mark_buffer_dirty(bh, 1);
+ }
brelse(bh);
dest_addr += size;
len -= size;
========================================================================

B. D. Elliott bde@accessone.com (Seattle)