Message ID | 4B03A189.6000109@rs.jp.nec.com |
---|---|
State | Accepted, archived |
Headers | show |
On Wed, Nov 18, 2009 at 04:26:01PM +0900, Akira Fujita wrote: > ext4: Fix double-free of blocks with EXT4_IOC_MOVE_EXT > > From: Akira Fujita <a-fujita@rs.jp.nec.com> > > ext4_move_extent() calls ext4_discard_preallocations() to discard inode PAs > of orig and donor inodes in its beginning. > But the following case (1-4 steps) triggers the double-free of blocks, > so move ext4_discard_preallocations() to the end of ext4_move_extents(). Thanks, applied to the ext4 patch queue. - Ted -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c index 5a106e0..3478889 100644 --- a/fs/ext4/move_extent.c +++ b/fs/ext4/move_extent.c @@ -1289,10 +1289,6 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, ext4_ext_get_actual_len(ext_cur), block_end + 1) - max(le32_to_cpu(ext_cur->ee_block), block_start); - /* Discard preallocations of two inodes */ - ext4_discard_preallocations(orig_inode); - ext4_discard_preallocations(donor_inode); - while (!last_extent && le32_to_cpu(ext_cur->ee_block) <= block_end) { seq_blocks += add_blocks; @@ -1410,6 +1406,11 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, } out: + if (*moved_len) { + ext4_discard_preallocations(orig_inode); + ext4_discard_preallocations(donor_inode); + } + if (orig_path) { ext4_ext_drop_refs(orig_path); kfree(orig_path);