diff options
-rw-r--r-- | fs/nilfs2/btnode.c | 26 | ||||
-rw-r--r-- | fs/nilfs2/btnode.h | 2 |
2 files changed, 28 insertions, 0 deletions
diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c index 84c25382f8e3..fc3e4bdb62ae 100644 --- a/fs/nilfs2/btnode.c +++ b/fs/nilfs2/btnode.c | |||
@@ -68,6 +68,32 @@ void nilfs_btnode_cache_clear(struct address_space *btnc) | |||
68 | truncate_inode_pages(btnc, 0); | 68 | truncate_inode_pages(btnc, 0); |
69 | } | 69 | } |
70 | 70 | ||
71 | struct buffer_head * | ||
72 | nilfs_btnode_create_block(struct address_space *btnc, __u64 blocknr) | ||
73 | { | ||
74 | struct inode *inode = NILFS_BTNC_I(btnc); | ||
75 | struct buffer_head *bh; | ||
76 | |||
77 | bh = nilfs_grab_buffer(inode, btnc, blocknr, 1 << BH_NILFS_Node); | ||
78 | if (unlikely(!bh)) | ||
79 | return NULL; | ||
80 | |||
81 | if (unlikely(buffer_mapped(bh) || buffer_uptodate(bh) || | ||
82 | buffer_dirty(bh))) { | ||
83 | brelse(bh); | ||
84 | BUG(); | ||
85 | } | ||
86 | memset(bh->b_data, 0, 1 << inode->i_blkbits); | ||
87 | bh->b_bdev = NILFS_I_NILFS(inode)->ns_bdev; | ||
88 | bh->b_blocknr = blocknr; | ||
89 | set_buffer_mapped(bh); | ||
90 | set_buffer_uptodate(bh); | ||
91 | |||
92 | unlock_page(bh->b_page); | ||
93 | page_cache_release(bh->b_page); | ||
94 | return bh; | ||
95 | } | ||
96 | |||
71 | int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr, | 97 | int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr, |
72 | sector_t pblocknr, struct buffer_head **pbh, | 98 | sector_t pblocknr, struct buffer_head **pbh, |
73 | int newblk) | 99 | int newblk) |
diff --git a/fs/nilfs2/btnode.h b/fs/nilfs2/btnode.h index 3e2275172ed6..c53644c0cf0f 100644 --- a/fs/nilfs2/btnode.h +++ b/fs/nilfs2/btnode.h | |||
@@ -40,6 +40,8 @@ struct nilfs_btnode_chkey_ctxt { | |||
40 | void nilfs_btnode_cache_init_once(struct address_space *); | 40 | void nilfs_btnode_cache_init_once(struct address_space *); |
41 | void nilfs_btnode_cache_init(struct address_space *, struct backing_dev_info *); | 41 | void nilfs_btnode_cache_init(struct address_space *, struct backing_dev_info *); |
42 | void nilfs_btnode_cache_clear(struct address_space *); | 42 | void nilfs_btnode_cache_clear(struct address_space *); |
43 | struct buffer_head *nilfs_btnode_create_block(struct address_space *btnc, | ||
44 | __u64 blocknr); | ||
43 | int nilfs_btnode_submit_block(struct address_space *, __u64, sector_t, | 45 | int nilfs_btnode_submit_block(struct address_space *, __u64, sector_t, |
44 | struct buffer_head **, int); | 46 | struct buffer_head **, int); |
45 | int nilfs_btnode_get(struct address_space *, __u64, sector_t, | 47 | int nilfs_btnode_get(struct address_space *, __u64, sector_t, |