Commit a12ebfc1 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (1/5) ext2_free_blocks() cleanup

new helper function - release_blocks(sb, n); in ext2_free_blocks() we
count the blocks we'd freed and update the fs-wide count of free blocks
in the end - just before unlocking superblock.  instead of doing that
step at a time.

reviewed by ext2 folks
parent d7b65475
...@@ -166,6 +166,18 @@ static struct buffer_head *load_block_bitmap(struct super_block * sb, ...@@ -166,6 +166,18 @@ static struct buffer_head *load_block_bitmap(struct super_block * sb,
return bh; return bh;
} }
static inline void release_blocks(struct super_block *sb, int count)
{
if (count) {
struct ext2_sb_info * sbi = EXT2_SB(sb);
struct ext2_super_block * es = sbi->s_es;
unsigned free_blocks = le32_to_cpu(es->s_free_blocks_count);
es->s_free_blocks_count = cpu_to_le32(free_blocks + count);
mark_buffer_dirty(sbi->s_sbh);
sb->s_dirt = 1;
}
}
/* Free given blocks, update quota and i_blocks field */ /* Free given blocks, update quota and i_blocks field */
void ext2_free_blocks (struct inode * inode, unsigned long block, void ext2_free_blocks (struct inode * inode, unsigned long block,
unsigned long count) unsigned long count)
...@@ -179,6 +191,7 @@ void ext2_free_blocks (struct inode * inode, unsigned long block, ...@@ -179,6 +191,7 @@ void ext2_free_blocks (struct inode * inode, unsigned long block,
struct super_block * sb; struct super_block * sb;
struct ext2_group_desc * gdp; struct ext2_group_desc * gdp;
struct ext2_super_block * es; struct ext2_super_block * es;
unsigned freed = 0;
sb = inode->i_sb; sb = inode->i_sb;
if (!sb) { if (!sb) {
...@@ -239,14 +252,11 @@ void ext2_free_blocks (struct inode * inode, unsigned long block, ...@@ -239,14 +252,11 @@ void ext2_free_blocks (struct inode * inode, unsigned long block,
DQUOT_FREE_BLOCK(inode, 1); DQUOT_FREE_BLOCK(inode, 1);
gdp->bg_free_blocks_count = gdp->bg_free_blocks_count =
cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count)+1); cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count)+1);
es->s_free_blocks_count = freed++;
cpu_to_le32(le32_to_cpu(es->s_free_blocks_count)+1);
} }
} }
mark_buffer_dirty(bh2); mark_buffer_dirty(bh2);
mark_buffer_dirty(sb->u.ext2_sb.s_sbh);
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
if (sb->s_flags & MS_SYNCHRONOUS) { if (sb->s_flags & MS_SYNCHRONOUS) {
ll_rw_block (WRITE, 1, &bh); ll_rw_block (WRITE, 1, &bh);
...@@ -257,8 +267,8 @@ void ext2_free_blocks (struct inode * inode, unsigned long block, ...@@ -257,8 +267,8 @@ void ext2_free_blocks (struct inode * inode, unsigned long block,
count = overflow; count = overflow;
goto do_more; goto do_more;
} }
sb->s_dirt = 1;
error_return: error_return:
release_blocks(sb, freed);
unlock_super (sb); unlock_super (sb);
return; return;
} }
......
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