Commit 52ab8b6a authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] ext2/ext3 Orlov directory accounting fix

Patch from Stephen Tweedie

"In looking at the fix for the ext3 Orlov double-accounting bug, I
 noticed a change to the sb->s_dir_count accounting, restoring a
 missing s_dir_count++ when we allocate a new directory.

 However, I can't find anywhere in the code where we decrement this
 again on directory deletion, neither in ext2 nor in ext3, in 2.4 nor
 in 2.5."

Locking is via lock_super().
parent 793b840b
...@@ -134,9 +134,11 @@ void ext2_free_inode (struct inode * inode) ...@@ -134,9 +134,11 @@ void ext2_free_inode (struct inode * inode)
if (desc) { if (desc) {
desc->bg_free_inodes_count = desc->bg_free_inodes_count =
cpu_to_le16(le16_to_cpu(desc->bg_free_inodes_count) + 1); cpu_to_le16(le16_to_cpu(desc->bg_free_inodes_count) + 1);
if (is_directory) if (is_directory) {
desc->bg_used_dirs_count = desc->bg_used_dirs_count =
cpu_to_le16(le16_to_cpu(desc->bg_used_dirs_count) - 1); cpu_to_le16(le16_to_cpu(desc->bg_used_dirs_count) - 1);
EXT2_SB(sb)->s_dir_count--;
}
} }
mark_buffer_dirty(bh2); mark_buffer_dirty(bh2);
es->s_free_inodes_count = es->s_free_inodes_count =
......
...@@ -167,9 +167,11 @@ void ext3_free_inode (handle_t *handle, struct inode * inode) ...@@ -167,9 +167,11 @@ void ext3_free_inode (handle_t *handle, struct inode * inode)
if (gdp) { if (gdp) {
gdp->bg_free_inodes_count = cpu_to_le16( gdp->bg_free_inodes_count = cpu_to_le16(
le16_to_cpu(gdp->bg_free_inodes_count) + 1); le16_to_cpu(gdp->bg_free_inodes_count) + 1);
if (is_directory) if (is_directory) {
gdp->bg_used_dirs_count = cpu_to_le16( gdp->bg_used_dirs_count = cpu_to_le16(
le16_to_cpu(gdp->bg_used_dirs_count) - 1); le16_to_cpu(gdp->bg_used_dirs_count) - 1);
EXT3_SB(sb)->s_dir_count--;
}
} }
BUFFER_TRACE(bh2, "call ext3_journal_dirty_metadata"); BUFFER_TRACE(bh2, "call ext3_journal_dirty_metadata");
err = ext3_journal_dirty_metadata(handle, bh2); err = ext3_journal_dirty_metadata(handle, bh2);
......
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