Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Viro <viro@math.psu.edu>2002-02-08 19:16:52 -0800
committerLinus Torvalds <torvalds@home.transmeta.com>2002-02-08 19:16:52 -0800
commita12ebfc1f227f3ae096ef89af2777bad2d16d117 (patch)
tree90f7cf2c86d9fd73a25b58b6a052d4a9b029bb64
parentd7b654751759e2a2e1d49aebf595c12e55ca7b69 (diff)
[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
-rw-r--r--fs/ext2/balloc.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index 5d3f1486f2a2..b1d94cd8b6fe 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -166,6 +166,18 @@ found:
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 */
void ext2_free_blocks (struct inode * inode, unsigned long block,
unsigned long count)
@@ -179,6 +191,7 @@ void ext2_free_blocks (struct inode * inode, unsigned long block,
struct super_block * sb;
struct ext2_group_desc * gdp;
struct ext2_super_block * es;
+ unsigned freed = 0;
sb = inode->i_sb;
if (!sb) {
@@ -239,14 +252,11 @@ do_more:
DQUOT_FREE_BLOCK(inode, 1);
gdp->bg_free_blocks_count =
cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count)+1);
- es->s_free_blocks_count =
- cpu_to_le32(le32_to_cpu(es->s_free_blocks_count)+1);
+ freed++;
}
}
mark_buffer_dirty(bh2);
- mark_buffer_dirty(sb->u.ext2_sb.s_sbh);
-
mark_buffer_dirty(bh);
if (sb->s_flags & MS_SYNCHRONOUS) {
ll_rw_block (WRITE, 1, &bh);
@@ -257,8 +267,8 @@ do_more:
count = overflow;
goto do_more;
}
- sb->s_dirt = 1;
error_return:
+ release_blocks(sb, freed);
unlock_super (sb);
return;
}