diff options
author | Christian Borntraeger <borntraeger@de.ibm.com> | 2007-11-14 20:00:05 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-14 21:45:42 -0500 |
commit | 5d0360ee96a5ef953dbea45873c2a8c87e77d59b (patch) | |
tree | 61270c84623618638a5abe0957d90ee9545e9c92 /drivers/block/rd.c | |
parent | 822bd5aa2b8e8fa1d328f03bf5b9c75701481bf0 (diff) |
rd: fix data corruption on memory pressure
We have seen ramdisk based install systems, where some pages of mapped
libraries and programs were suddendly zeroed under memory pressure. This
should not happen, as the ramdisk avoids freeing its pages by keeping them
dirty all the time.
It turns out that there is a case, where the VM makes a ramdisk page clean,
without telling the ramdisk driver. On memory pressure shrink_zone runs
and it starts to run shrink_active_list. There is a check for
buffer_heads_over_limit, and if true, pagevec_strip is called.
pagevec_strip calls try_to_release_page. If the mapping has no releasepage
callback, try_to_free_buffers is called. try_to_free_buffers has now a
special logic for some file systems to make a dirty page clean, if all
buffers are clean. Thats what happened in our test case.
The simplest solution is to provide a noop-releasepage callback for the
ramdisk driver. This avoids try_to_free_buffers for ramdisk pages.
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Nick Piggin <npiggin@suse.de>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block/rd.c')
-rw-r--r-- | drivers/block/rd.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/block/rd.c b/drivers/block/rd.c index 47f8ac6cce57..82f4eecc8699 100644 --- a/drivers/block/rd.c +++ b/drivers/block/rd.c | |||
@@ -189,6 +189,18 @@ static int ramdisk_set_page_dirty(struct page *page) | |||
189 | return 0; | 189 | return 0; |
190 | } | 190 | } |
191 | 191 | ||
192 | /* | ||
193 | * releasepage is called by pagevec_strip/try_to_release_page if | ||
194 | * buffers_heads_over_limit is true. Without a releasepage function | ||
195 | * try_to_free_buffers is called instead. That can unset the dirty | ||
196 | * bit of our ram disk pages, which will be eventually freed, even | ||
197 | * if the page is still in use. | ||
198 | */ | ||
199 | static int ramdisk_releasepage(struct page *page, gfp_t dummy) | ||
200 | { | ||
201 | return 0; | ||
202 | } | ||
203 | |||
192 | static const struct address_space_operations ramdisk_aops = { | 204 | static const struct address_space_operations ramdisk_aops = { |
193 | .readpage = ramdisk_readpage, | 205 | .readpage = ramdisk_readpage, |
194 | .prepare_write = ramdisk_prepare_write, | 206 | .prepare_write = ramdisk_prepare_write, |
@@ -196,6 +208,7 @@ static const struct address_space_operations ramdisk_aops = { | |||
196 | .writepage = ramdisk_writepage, | 208 | .writepage = ramdisk_writepage, |
197 | .set_page_dirty = ramdisk_set_page_dirty, | 209 | .set_page_dirty = ramdisk_set_page_dirty, |
198 | .writepages = ramdisk_writepages, | 210 | .writepages = ramdisk_writepages, |
211 | .releasepage = ramdisk_releasepage, | ||
199 | }; | 212 | }; |
200 | 213 | ||
201 | static int rd_blkdev_pagecache_IO(int rw, struct bio_vec *vec, sector_t sector, | 214 | static int rd_blkdev_pagecache_IO(int rw, struct bio_vec *vec, sector_t sector, |