mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Mason <mason@suse.com>
To: linux-kernel@vger.kernel.org
Cc: andrea@suse.de, viro@math.psu.edu, torvalds@transmeta.com
Subject: [PATCH] invalidate buffers on blkdev_put
Date: Mon, 24 Sep 2001 23:18:54 -0400	[thread overview]
Message-ID: <251250000.1001387934@tiny> (raw)


Hi guys,

I had sent this to Al, but couldn't tell if he hated it, thought it was
broken, or just didn't think it was required.  So, I opted for wider
testing.  This only affects 2.4.10pre15+, as it was caused by the blkdev
changes there.

Anyway, the bug looks like this:

dd if=ext2-image-1 of=/dev/ram0
mount /dev/ram0 /mnt
umount /mnt

dd if=ext2-image-2 of=/dev/ram0
mount /dev/ram0 /mnt
ls -la /mnt (FS looks corrupted and wrong).

The problem is that on unmount, the ramdisk's buffer cache isn't cleared
because bd_openers is still one.  So, even if a new image is copied in, you
still see the old image's superblock/inodes etc on mount.

In this case, we want to leave the dirty pages in the page cache, but get
rid of the buffer cache copies.

This should not drop any updated data in the ramdisk because
rd_blkdev_pagecache_IO dirties pages as the higher layers send down
modified buffer heads (and other rd.c funcs do the same).  Patch is below.
Linus, please consider (pending lack of nays from Al).

An additional patch is probably to remove the second invalidate_buffers
call, since only the filesystems should have buffer cache entries.  

-chris

--- 3.1/fs/block_dev.c Sun, 23 Sep 2001 20:11:16 -0400 
+++ 3.1(w)/fs/block_dev.c Mon, 24 Sep 2001 15:11:49 -0400 
@@ -802,8 +802,10 @@
 			unlock_super(sb);
 			drop_super(sb);
 		}
-	} else if (kind == BDEV_FS)
+	} else if (kind == BDEV_FS) {
 		fsync_no_super(rdev);
+		invalidate_buffers(rdev);
+	}
 	if (!--bdev->bd_openers) {
 		truncate_inode_pages(bd_inode->i_mapping, 0);
 		invalidate_buffers(rdev);


             reply	other threads:[~2001-09-25  3:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-25  3:18 Chris Mason [this message]
2001-09-25  3:52 ` Alexander Viro
2001-09-25  4:21   ` Linus Torvalds
2001-09-27 14:03     ` Pavel Machek
2001-10-01 20:02       ` Dave Cinege
2001-09-25 22:59   ` Anton Altaparmakov
2001-09-26  3:39     ` Linus Torvalds
2001-09-26 22:42     ` Anton Altaparmakov
2001-09-27  0:03       ` Andreas Dilger

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=251250000.1001387934@tiny \
    --to=mason@suse.com \
    --cc=andrea@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    --cc=viro@math.psu.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

all inboxes | Powered by JetHome®