Commit 9c02740c authored by Jaegeuk Kim's avatar Jaegeuk Kim

f2fs: check the free space first in new_node_page

Let's check the free space in prior to the main process of allocating a new node
page.
Signed-off-by: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
parent 41dfde13
...@@ -833,29 +833,29 @@ struct page *new_node_page(struct dnode_of_data *dn, ...@@ -833,29 +833,29 @@ struct page *new_node_page(struct dnode_of_data *dn,
if (!page) if (!page)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
get_node_info(sbi, dn->nid, &old_ni); if (!inc_valid_node_count(sbi, dn->inode, 1)) {
err = -ENOSPC;
goto fail;
}
SetPageUptodate(page); get_node_info(sbi, dn->nid, &old_ni);
fill_node_footer(page, dn->nid, dn->inode->i_ino, ofs, true);
/* Reinitialize old_ni with new node page */ /* Reinitialize old_ni with new node page */
BUG_ON(old_ni.blk_addr != NULL_ADDR); BUG_ON(old_ni.blk_addr != NULL_ADDR);
new_ni = old_ni; new_ni = old_ni;
new_ni.ino = dn->inode->i_ino; new_ni.ino = dn->inode->i_ino;
if (!inc_valid_node_count(sbi, dn->inode, 1)) {
err = -ENOSPC;
goto fail;
}
set_node_addr(sbi, &new_ni, NEW_ADDR); set_node_addr(sbi, &new_ni, NEW_ADDR);
fill_node_footer(page, dn->nid, dn->inode->i_ino, ofs, true);
set_cold_node(dn->inode, page); set_cold_node(dn->inode, page);
SetPageUptodate(page);
set_page_dirty(page);
dn->node_page = page; dn->node_page = page;
if (ipage) if (ipage)
update_inode(dn->inode, ipage); update_inode(dn->inode, ipage);
else else
sync_inode_page(dn); sync_inode_page(dn);
set_page_dirty(page);
if (ofs == 0) if (ofs == 0)
inc_valid_inode_count(sbi); inc_valid_inode_count(sbi);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment