History

[PATCH] ext3: Fix unmapped buffers in transaction's lists

Fix the problem (BUG 4964) with unmapped buffers in transaction's t_sync_data list. The problem is we need to call filesystem's own invalidatepage() from block_write_full_page(). block_write_full_page() must call filesystem's invalidatepage(). Otherwise following nasty race can happen: proc 1 proc 2 ------ ------ - write some new data to 'offset' => bh gets to the transactions data list - starts truncate => i_size set to new size - mpage_writepages() - ext3_ordered_writepage() to 'offset' - block_write_full_page() - page->index > end_index+1 - block_invalidatepage() - discard_buffer() - clear_buffer_mapped() - commit triggers and finds unmapped buffer - BOOM!

Jan Kara committed 21 years ago

Commit aaa40591 parent e812cb53 files · +12 −11Browse files

Unified · Split

3 files
  1. fs/buffer.c +10 −1
  2. include/linux/buffer_head.h +1 −0
  3. mm/truncate.c +1 −10
fs/buffer.c+10−1
@@ -1637,6 +1637,15 @@ out: · 1636 unmodified lines
16371637 }
16381638 EXPORT_SYMBOL(block_invalidatepage);
16391639
1640+int do_invalidatepage(struct page *page, unsigned long offset)
1641+{
1642+ int (*invalidatepage)(struct page *, unsigned long);
1643+ invalidatepage = page->mapping->a_ops->invalidatepage;
1644+ if (invalidatepage == NULL)
1645+ invalidatepage = block_invalidatepage;
1646+ return (*invalidatepage)(page, offset);
1647+}
1648+
16401649 /*
16411650 * We attach and possibly dirty the buffers atomically wrt
16421651 * __set_page_dirty_buffers() via private_lock. try_to_free_buffers
@@ -2696,7 +2705,7 @@ int block_write_full_page(struct page *page, get_block_t *get_block, · 1053 unmodified lines
26962705 * they may have been added in ext3_writepage(). Make them
26972706 * freeable here, so the page does not leak.
26982707 */
2699− block_invalidatepage(page, 0);
2708+ do_invalidatepage(page, 0);
27002709 unlock_page(page);
27012710 return 0; /* don't care */
27022711 }
include/linux/buffer_head.h+1−0
@@ -190,6 +190,7 @@ extern int buffer_heads_over_limit; · 189 unmodified lines
190190 */
191191 int try_to_release_page(struct page * page, gfp_t gfp_mask);
192192 int block_invalidatepage(struct page *page, unsigned long offset);
193+int do_invalidatepage(struct page *page, unsigned long offset);
193194 int block_write_full_page(struct page *page, get_block_t *get_block,
194195 struct writeback_control *wbc);
195196 int block_read_full_page(struct page*, get_block_t*);
mm/truncate.c+1−10
@@ -13,18 +13,9 @@ · 12 unmodified lines
1313 #include <linux/pagemap.h>
1414 #include <linux/pagevec.h>
1515 #include <linux/buffer_head.h> /* grr. try_to_release_page,
16− block_invalidatepage */
16+ do_invalidatepage */
1717
1818
19−static int do_invalidatepage(struct page *page, unsigned long offset)
20−{
21− int (*invalidatepage)(struct page *, unsigned long);
22− invalidatepage = page->mapping->a_ops->invalidatepage;
23− if (invalidatepage == NULL)
24− invalidatepage = block_invalidatepage;
25− return (*invalidatepage)(page, offset);
26−}
27−
2819 static inline void truncate_partial_page(struct page *page, unsigned partial)
2920 {
3021 memclear_highpage_flush(page, partial, PAGE_CACHE_SIZE-partial);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t