linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] Clean up ext4's block free code paths
@ 2009-11-23  2:18 Theodore Ts'o
  2009-11-23  2:18 ` [PATCH 1/8] ext4: move ext4_forget() to ext4_jbd2.c Theodore Ts'o
                   ` (8 more replies)
  0 siblings, 9 replies; 15+ messages in thread
From: Theodore Ts'o @ 2009-11-23  2:18 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

This patch series cleans up functions involved with freeing blocks.  It
removes functions that are only called by a single caller and folds them
into their caller, and makes the code a little easier to read.  It also
reduces ext4's code foot print slightly (by 136 bytes).  

Finally, it fixes a bug in the extents migration function, which was
missing calls to ext4_forget() when it frees the indirect blocks after
converting an inode to using extents.  This avoids potential file system
corruption after a crash while converting an entire filesystem to use
extents via "chattr -R +e /mntpt".

						- Ted

Theodore Ts'o (8):
  ext4: move ext4_forget() to ext4_jbd2.c
  ext4: fold ext4_journal_revoke() into ext4_forget()
  ext4: fold ext4_journal_forget() into ext4_forget()
  ext4: fold ext4_free_blocks() and ext4_mb_free_blocks()
  ext4: call ext4_forget() from ext4_free_blocks()
  ext4: print i_mode in octal in ext4 tracepoints
  ext4: add check for wraparound in ext4_data_block_valid()
  ext4: use ext4_data_block_valid() in ext4_free_blocks()

 fs/ext4/balloc.c            |   38 --------------
 fs/ext4/block_validity.c    |    1 +
 fs/ext4/ext4.h              |   15 +++--
 fs/ext4/ext4_jbd2.c         |   82 ++++++++++++++++++++++---------
 fs/ext4/ext4_jbd2.h         |   23 +++------
 fs/ext4/extents.c           |   24 +++------
 fs/ext4/inode.c             |  116 +++++++++++--------------------------------
 fs/ext4/mballoc.c           |   61 ++++++++++++++++++-----
 fs/ext4/migrate.c           |   23 ++++++---
 fs/ext4/xattr.c             |    8 ++-
 include/trace/events/ext4.h |   24 +++++----
 11 files changed, 198 insertions(+), 217 deletions(-)


^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: [PATCH 5/8] ext4: call ext4_forget() from ext4_free_blocks()
@ 2010-06-27  2:40 Amir G.
  2010-07-23 13:07 ` Ted Ts'o
  0 siblings, 1 reply; 15+ messages in thread
From: Amir G. @ 2010-06-27  2:40 UTC (permalink / raw)
  To: Theodore Tso; +Cc: Aneesh Kumar K.V, Ext4 Developers List

Hi Ted,

There is a lurking bug that needs to be fixed in ext4_free_branches().
it can cause double freeing of blocks after crash.
please see bug description below.

Amir.

On Wed, Jun 23, 2010 at 10:01 PM, Amir G.
<amir73il@users.sourceforge.net> wrote:
> Hi,
>
> We have experienced bitmap inconsistencies after crash during file
> delete under heavy load.
> The crash is not file system related and I the following patch in
> ext4_free_branches() fixes the recovery problem.
>
> If the transaction is restarted and there is a crash before the new
> transaction is committed,
> then after recovery, the blocks that this indirect block points to
> have been freed, but the indirect block itself
> has not been freed and may still point to some of the free blocks
> (because of the ext4_forget()).
>
> So ext4_forget() should be called inside ext4_free_blocks() to avoid
> this problem.
> Are there any consequences to this patch that I am not aware of?
>
> Amir.
>
> Signed-off-by: Amir Goldstein <amir73il@users.sf.net>
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 42272d6..682e2fa 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4458,6 +4458,7 @@ static void ext4_free_branches(handle_t *handle,
> struct inode *inode,
>  {
>        ext4_fsblk_t nr;
>        __le32 *p;
> +       int     flags;
>
>        if (ext4_handle_is_aborted(handle))
>                return;
> @@ -4520,7 +4521,7 @@ static void ext4_free_branches(handle_t *handle,
> struct inode *inode,
>                         * revoke records must be emitted *before* clearing
>                         * this block's bit in the bitmaps.
>                         */
> -                       ext4_forget(handle, 1, inode, bh, bh->b_blocknr);
> +                       flags =
> EXT4_FREE_BLOCKS_METADATA|EXT4_FREE_BLOCKS_FORGET;
>
>                        /*
>                         * Everything below this this pointer has been
> @@ -4546,8 +4547,7 @@ static void ext4_free_branches(handle_t *handle,
> struct inode *inode,
>                                            blocks_for_truncate(inode));
>                        }
>
> -                       ext4_free_blocks(handle, inode, 0, nr, 1,
> -                                        EXT4_FREE_BLOCKS_METADATA);
> +                       ext4_free_blocks(handle, inode, 0, nr, 1, flags);
>
>                        if (parent_bh) {
>                                /*
>
--
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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2010-07-23 13:07 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-23  2:18 [PATCH 0/8] Clean up ext4's block free code paths Theodore Ts'o
2009-11-23  2:18 ` [PATCH 1/8] ext4: move ext4_forget() to ext4_jbd2.c Theodore Ts'o
2009-11-23  2:18 ` [PATCH 2/8] ext4: fold ext4_journal_revoke() into ext4_forget() Theodore Ts'o
2009-11-23  2:18 ` [PATCH 3/8] ext4: fold ext4_journal_forget() " Theodore Ts'o
2009-11-23  2:18 ` [PATCH 4/8] ext4: fold ext4_free_blocks() and ext4_mb_free_blocks() Theodore Ts'o
2009-11-23  2:18 ` [PATCH 5/8] ext4: call ext4_forget() from ext4_free_blocks() Theodore Ts'o
2009-11-23 19:22   ` Andreas Dilger
2009-11-23 20:28     ` tytso
2009-11-23  2:18 ` [PATCH 6/8] ext4: print i_mode in octal in ext4 tracepoints Theodore Ts'o
2009-11-23  2:18 ` [PATCH 7/8] ext4: add check for wraparound in ext4_data_block_valid() Theodore Ts'o
2009-11-23  2:18 ` [PATCH 8/8] ext4: use ext4_data_block_valid() in ext4_free_blocks() Theodore Ts'o
2009-11-23  3:53 ` [PATCH 0/8] Clean up ext4's block free code paths Eric Sandeen
2009-11-23 14:46   ` tytso
  -- strict thread matches above, loose matches on Subject: below --
2010-06-27  2:40 [PATCH 5/8] ext4: call ext4_forget() from ext4_free_blocks() Amir G.
2010-07-23 13:07 ` Ted Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).