Skip to content

Commit

Permalink
nilfs2: move out mark_inode_dirty calls from bmap routines
Browse files Browse the repository at this point in the history
Previously, nilfs_bmap_add_blocks() and nilfs_bmap_sub_blocks() called
mark_inode_dirty() after they changed the number of data blocks.

This moves these calls outside bmap outermost functions like
nilfs_bmap_insert() or nilfs_bmap_truncate().

This will mitigate overhead for truncate or delete operation since
they repeatedly remove set of blocks.  Nearly 10 percent improvement
was observed for removal of a large file:

 # dd if=/dev/zero of=/test/aaa bs=1M count=512
 # time rm /test/aaa

  real  2.968s -> 2.705s

Further optimization may be possible by eliminating these
mark_inode_dirty() uses though I avoid mixing separate changes here.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
  • Loading branch information
Ryusuke Konishi committed Nov 20, 2009
1 parent 09bf4aa commit 9cb4e0d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 0 additions & 4 deletions fs/nilfs2/bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,15 +402,11 @@ int nilfs_bmap_test_and_clear_dirty(struct nilfs_bmap *bmap)
void nilfs_bmap_add_blocks(const struct nilfs_bmap *bmap, int n)
{
inode_add_bytes(bmap->b_inode, (1 << bmap->b_inode->i_blkbits) * n);
if (!NILFS_MDT(bmap->b_inode))
mark_inode_dirty(bmap->b_inode);
}

void nilfs_bmap_sub_blocks(const struct nilfs_bmap *bmap, int n)
{
inode_sub_bytes(bmap->b_inode, (1 << bmap->b_inode->i_blkbits) * n);
if (!NILFS_MDT(bmap->b_inode))
mark_inode_dirty(bmap->b_inode);
}

__u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
Expand Down
3 changes: 3 additions & 0 deletions fs/nilfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ int nilfs_get_block(struct inode *inode, sector_t blkoff,
nilfs_transaction_abort(inode->i_sb);
goto out;
}
mark_inode_dirty(inode);
nilfs_transaction_commit(inode->i_sb); /* never fails */
/* Error handling should be detailed */
set_buffer_new(bh_result);
Expand Down Expand Up @@ -598,6 +599,7 @@ void nilfs_truncate(struct inode *inode)
if (IS_SYNC(inode))
nilfs_set_transaction_flag(NILFS_TI_SYNC);

mark_inode_dirty(inode);
nilfs_set_file_dirty(NILFS_SB(sb), inode, 0);
nilfs_transaction_commit(sb);
/* May construct a logical segment and may fail in sync mode.
Expand All @@ -622,6 +624,7 @@ void nilfs_delete_inode(struct inode *inode)
truncate_inode_pages(&inode->i_data, 0);

nilfs_truncate_bmap(ii, 0);
mark_inode_dirty(inode);
nilfs_free_inode(inode);
/* nilfs_free_inode() marks inode buffer dirty */
if (IS_SYNC(inode))
Expand Down

0 comments on commit 9cb4e0d

Please sign in to comment.