Message ID | 1319144939-28801-4-git-send-email-dmonakhov@openvz.org |
---|---|
State | New, archived |
Headers | show |
On Fri, Oct 21, 2011 at 01:08:56AM +0400, Dmitry Monakhov wrote: > ext4_ext_insert_extent() may fail due to number of reasons (ENOSPC) > so let's update eof flag only after extent was successfully inserted. > > Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> The problem with this patch is that if the check_eofblocks_fl() fails, the patch jumps to out: and doesn't undo the block allocation and extent tree manipulation. I suspect a better way of solving this problem is to keep the existing order, but to save the state of eofblocks flag, and if ext4_ext_insert_extent() fails, to restore the state of the eofblocks flag before jumping to the exit routine. - 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
On Tue, 25 Oct 2011 04:18:34 -0400, Ted Ts'o <tytso@mit.edu> wrote: > On Fri, Oct 21, 2011 at 01:08:56AM +0400, Dmitry Monakhov wrote: > > ext4_ext_insert_extent() may fail due to number of reasons (ENOSPC) > > so let's update eof flag only after extent was successfully inserted. > > > > Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> > > The problem with this patch is that if the check_eofblocks_fl() fails, > the patch jumps to out: and doesn't undo the block allocation and > extent tree manipulation. check_eofblocks_fl may fail only due to ext4_journal_get_write_access or ext4_mark_iloc_dirty, this means that something serious happen, so it is very unlikely we can undo block allocation. > > I suspect a better way of solving this problem is to keep the existing > order, but to save the state of eofblocks flag, and if > ext4_ext_insert_extent() fails, to restore the state of the eofblocks > flag before jumping to the exit routine. Yes. This is definitely looks better, will redo. > > - 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 -- 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/extents.c b/fs/ext4/extents.c index 315775e..d81085e 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4115,10 +4115,7 @@ got_allocated_blocks: map->m_flags |= EXT4_MAP_UNINIT; } - err = check_eofblocks_fl(handle, inode, map->m_lblk, path, ar.len); - if (!err) - err = ext4_ext_insert_extent(handle, inode, path, - &newex, flags); + err = ext4_ext_insert_extent(handle, inode, path, &newex, flags); if (err && free_on_err) { int fb_flags = flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE ? EXT4_FREE_BLOCKS_NO_QUOT_UPDATE : 0; @@ -4130,6 +4127,11 @@ got_allocated_blocks: ext4_ext_get_actual_len(&newex), fb_flags); goto out2; } + err = check_eofblocks_fl(handle, inode, map->m_lblk, path, ar.len); + if (err) { + ext4_discard_preallocations(inode); + goto out2; + } /* previous routine could use block we allocated */ newblock = ext4_ext_pblock(&newex);
ext4_ext_insert_extent() may fail due to number of reasons (ENOSPC) so let's update eof flag only after extent was successfully inserted. Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> --- fs/ext4/extents.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)