aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/xattr.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2009-11-23 07:17:05 -0500
committerTheodore Ts'o <tytso@mit.edu>2009-11-23 07:17:05 -0500
commite6362609b6c71c5b802026be9cf263bbdd67a50e (patch)
treebe908b6b0566f70d31378bf11b548a0d59ae0218 /fs/ext4/xattr.c
parent4433871130f36585fde38e7dd817433296648945 (diff)
ext4: call ext4_forget() from ext4_free_blocks()
Add the facility for ext4_forget() to be called from ext4_free_blocks(). This simplifies the code in a large number of places, and centralizes most of the work of calling ext4_forget() into a single place. Also fix a bug in the extents migration code; it wasn't calling ext4_forget() when releasing the indirect blocks during the conversion. As a result, if the system cashed during or shortly after the extents migration, and the released indirect blocks get reused as data blocks, the journal replay would corrupt the data blocks. With this new patch, fixing this bug was as simple as adding the EXT4_FREE_BLOCKS_FORGET flags to the call to ext4_free_blocks(). Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Diffstat (limited to 'fs/ext4/xattr.c')
-rw-r--r--fs/ext4/xattr.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 025701926f9a..910bf9a59cb3 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -482,9 +482,10 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
482 ea_bdebug(bh, "refcount now=0; freeing"); 482 ea_bdebug(bh, "refcount now=0; freeing");
483 if (ce) 483 if (ce)
484 mb_cache_entry_free(ce); 484 mb_cache_entry_free(ce);
485 ext4_free_blocks(handle, inode, bh->b_blocknr, 1, 1);
486 get_bh(bh); 485 get_bh(bh);
487 ext4_forget(handle, 1, inode, bh, bh->b_blocknr); 486 ext4_free_blocks(handle, inode, bh, 0, 1,
487 EXT4_FREE_BLOCKS_METADATA |
488 EXT4_FREE_BLOCKS_FORGET);
488 } else { 489 } else {
489 le32_add_cpu(&BHDR(bh)->h_refcount, -1); 490 le32_add_cpu(&BHDR(bh)->h_refcount, -1);
490 error = ext4_handle_dirty_metadata(handle, inode, bh); 491 error = ext4_handle_dirty_metadata(handle, inode, bh);
@@ -832,7 +833,8 @@ inserted:
832 new_bh = sb_getblk(sb, block); 833 new_bh = sb_getblk(sb, block);
833 if (!new_bh) { 834 if (!new_bh) {
834getblk_failed: 835getblk_failed:
835 ext4_free_blocks(handle, inode, block, 1, 1); 836 ext4_free_blocks(handle, inode, 0, block, 1,
837 EXT4_FREE_BLOCKS_METADATA);
836 error = -EIO; 838 error = -EIO;
837 goto cleanup; 839 goto cleanup;
838 } 840 }