Skip to content

Commit

Permalink
f2fs: truncate stale block for inline_data
Browse files Browse the repository at this point in the history
This verifies to truncate any allocated blocks, offset[0], by inline_data.
Not figured out, but for making sure.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
  • Loading branch information
Jaegeuk Kim committed Aug 25, 2014
1 parent b5b8220 commit c2e6958
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions fs/f2fs/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,22 +823,26 @@ int truncate_xattr_node(struct inode *inode, struct page *page)
*/
void remove_inode_page(struct inode *inode)
{
struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
struct page *page;
nid_t ino = inode->i_ino;
struct dnode_of_data dn;

page = get_node_page(sbi, ino);
if (IS_ERR(page))
set_new_dnode(&dn, inode, NULL, NULL, inode->i_ino);
if (get_dnode_of_data(&dn, 0, LOOKUP_NODE))
return;

if (truncate_xattr_node(inode, page)) {
f2fs_put_page(page, 1);
if (truncate_xattr_node(inode, dn.inode_page)) {
f2fs_put_dnode(&dn);
return;
}

/* remove potential inline_data blocks */
if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
S_ISLNK(inode->i_mode))
truncate_data_blocks_range(&dn, 1);

/* 0 is possible, after f2fs_new_inode() has failed */
f2fs_bug_on(inode->i_blocks != 0 && inode->i_blocks != 1);
set_new_dnode(&dn, inode, page, page, ino);

/* will put inode & node pages */
truncate_node(&dn);
}

Expand Down

0 comments on commit c2e6958

Please sign in to comment.