Re: [PATCH] cramfs corruption after BLKFLSBUF on loop device

Chris Mason
2006-06-01T20:17:09Z

On Thursday 01 June 2006 14:49, Olaf Hering wrote:
> This script will cause cramfs decompression errors, on SMP at least:
>
> #!/bin/bash
> while :;do blockdev --flushbufs /dev/loop0;done </dev/null &>/dev/null&
> while :;do ps faxs </dev/null &>/dev/null&done </dev/null &>/dev/null&
> while :;do dmesg </dev/null &>/dev/null&done </dev/null &>/dev/null&
> while :;do find /mounts/instsys -type f -print0|xargs -0 cat
> &>/dev/null;done

It looks as though:

* cramfs_readpage is synchronous
* cramfs_readpage always returns an up to date page
* cramfs data doesn't change
* read_cache_page as called by cramfs will always return a page that was
up to date at one time, or an error.

I think this will work (but have not tested it). Another option is to create
a read_cache_page that pins the page via a page flag
that invalidate_mapping_pages will honor.

-chris

diff -r a1a07af2d0cd fs/cramfs/inode.c
--- a/fs/cramfs/inode.c Thu Jun 01 10:45:04 2006 -0400
+++ b/fs/cramfs/inode.c Thu Jun 01 15:04:39 2006 -0400
@@ -190,18 +190,6 @@ static void *cramfs_read(struct super_bl
pages[i] = page;
}

- for (i = 0; i < BLKS_PER_BUF; i++) {
- struct page *page = pages[i];
- if (page) {
- wait_on_page_locked(page);
- if (!PageUptodate(page)) {
- /* asynchronous error */
- page_cache_release(page);
- pages[i] = NULL;
- }
- }
- }
-
buffer = next_buffer;
next_buffer = NEXT_BUFFER(buffer);
buffer_blocknr[buffer] = blocknr;