diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-07-17 21:42:25 -0400 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-07-22 21:02:15 -0400 |
commit | 4e13e66bee2d792c1aae21797f16c181024834eb (patch) | |
tree | 1fa51dade28bc025d9bda0e09dec1f202281a498 | |
parent | 464ece88630d0fb715ca942eabb1da825046a534 (diff) |
nilfs2: introduce check flag to btree node buffer
nilfs_btree_get_block() now may return untested buffer due to
read-ahead. This adds a new flag for buffer heads so that the btree
code can check whether the buffer is already verified or not.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
-rw-r--r-- | fs/nilfs2/btree.c | 10 | ||||
-rw-r--r-- | fs/nilfs2/page.c | 5 | ||||
-rw-r--r-- | fs/nilfs2/page.h | 2 |
3 files changed, 15 insertions, 2 deletions
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c index 1b5321c0bcac..d3faa0bba171 100644 --- a/fs/nilfs2/btree.c +++ b/fs/nilfs2/btree.c | |||
@@ -370,8 +370,16 @@ static int nilfs_btree_node_broken(const struct nilfs_btree_node *node, | |||
370 | 370 | ||
371 | int nilfs_btree_broken_node_block(struct buffer_head *bh) | 371 | int nilfs_btree_broken_node_block(struct buffer_head *bh) |
372 | { | 372 | { |
373 | return nilfs_btree_node_broken((struct nilfs_btree_node *)bh->b_data, | 373 | int ret; |
374 | |||
375 | if (buffer_nilfs_checked(bh)) | ||
376 | return 0; | ||
377 | |||
378 | ret = nilfs_btree_node_broken((struct nilfs_btree_node *)bh->b_data, | ||
374 | bh->b_size, bh->b_blocknr); | 379 | bh->b_size, bh->b_blocknr); |
380 | if (likely(!ret)) | ||
381 | set_buffer_nilfs_checked(bh); | ||
382 | return ret; | ||
375 | } | 383 | } |
376 | 384 | ||
377 | static struct nilfs_btree_node * | 385 | static struct nilfs_btree_node * |
diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index 8de3e1e48130..aab11db2cb08 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c | |||
@@ -37,7 +37,8 @@ | |||
37 | 37 | ||
38 | #define NILFS_BUFFER_INHERENT_BITS \ | 38 | #define NILFS_BUFFER_INHERENT_BITS \ |
39 | ((1UL << BH_Uptodate) | (1UL << BH_Mapped) | (1UL << BH_NILFS_Node) | \ | 39 | ((1UL << BH_Uptodate) | (1UL << BH_Mapped) | (1UL << BH_NILFS_Node) | \ |
40 | (1UL << BH_NILFS_Volatile) | (1UL << BH_NILFS_Allocated)) | 40 | (1UL << BH_NILFS_Volatile) | (1UL << BH_NILFS_Allocated) | \ |
41 | (1UL << BH_NILFS_Checked)) | ||
41 | 42 | ||
42 | static struct buffer_head * | 43 | static struct buffer_head * |
43 | __nilfs_get_page_block(struct page *page, unsigned long block, pgoff_t index, | 44 | __nilfs_get_page_block(struct page *page, unsigned long block, pgoff_t index, |
@@ -129,6 +130,7 @@ void nilfs_forget_buffer(struct buffer_head *bh) | |||
129 | 130 | ||
130 | lock_buffer(bh); | 131 | lock_buffer(bh); |
131 | clear_buffer_nilfs_volatile(bh); | 132 | clear_buffer_nilfs_volatile(bh); |
133 | clear_buffer_nilfs_checked(bh); | ||
132 | clear_buffer_dirty(bh); | 134 | clear_buffer_dirty(bh); |
133 | if (nilfs_page_buffers_clean(page)) | 135 | if (nilfs_page_buffers_clean(page)) |
134 | __nilfs_clear_page_dirty(page); | 136 | __nilfs_clear_page_dirty(page); |
@@ -480,6 +482,7 @@ void nilfs_clear_dirty_pages(struct address_space *mapping) | |||
480 | lock_buffer(bh); | 482 | lock_buffer(bh); |
481 | clear_buffer_dirty(bh); | 483 | clear_buffer_dirty(bh); |
482 | clear_buffer_nilfs_volatile(bh); | 484 | clear_buffer_nilfs_volatile(bh); |
485 | clear_buffer_nilfs_checked(bh); | ||
483 | clear_buffer_uptodate(bh); | 486 | clear_buffer_uptodate(bh); |
484 | clear_buffer_mapped(bh); | 487 | clear_buffer_mapped(bh); |
485 | unlock_buffer(bh); | 488 | unlock_buffer(bh); |
diff --git a/fs/nilfs2/page.h b/fs/nilfs2/page.h index 8abca4d1c1f8..f53d8da41ed7 100644 --- a/fs/nilfs2/page.h +++ b/fs/nilfs2/page.h | |||
@@ -34,11 +34,13 @@ enum { | |||
34 | BH_NILFS_Allocated = BH_PrivateStart, | 34 | BH_NILFS_Allocated = BH_PrivateStart, |
35 | BH_NILFS_Node, | 35 | BH_NILFS_Node, |
36 | BH_NILFS_Volatile, | 36 | BH_NILFS_Volatile, |
37 | BH_NILFS_Checked, | ||
37 | }; | 38 | }; |
38 | 39 | ||
39 | BUFFER_FNS(NILFS_Allocated, nilfs_allocated) /* nilfs private buffers */ | 40 | BUFFER_FNS(NILFS_Allocated, nilfs_allocated) /* nilfs private buffers */ |
40 | BUFFER_FNS(NILFS_Node, nilfs_node) /* nilfs node buffers */ | 41 | BUFFER_FNS(NILFS_Node, nilfs_node) /* nilfs node buffers */ |
41 | BUFFER_FNS(NILFS_Volatile, nilfs_volatile) | 42 | BUFFER_FNS(NILFS_Volatile, nilfs_volatile) |
43 | BUFFER_FNS(NILFS_Checked, nilfs_checked) /* buffer is verified */ | ||
42 | 44 | ||
43 | 45 | ||
44 | void nilfs_mark_buffer_dirty(struct buffer_head *bh); | 46 | void nilfs_mark_buffer_dirty(struct buffer_head *bh); |