All of lore.kernel.org
 help / color / mirror / Atom feed
From: Toshiyuki Okajima <toshi.okajima@jp.fujitsu.com>
To: Yongqiang Yang <xiaoqiangnk@gmail.com>
Cc: toshi.okajima@jp.fujitsu.com, tytso@mit.edu, linux-ext4@vger.kernel.org
Subject: Re: [PATCH 1/5] ext4: allocate delalloc blocks before changing journal mode
Date: Fri, 09 Dec 2011 12:31:31 +0900	[thread overview]
Message-ID: <4EE18113.9060503@jp.fujitsu.com> (raw)
In-Reply-To: <1321344474-14707-1-git-send-email-xiaoqiangnk@gmail.com>

(2011/11/15 17:07), Yongqiang Yang wrote:
> delalloc blocks should be allocated before changing journal mode,
> otherwise they can not be allocated and even more truncate on
> delalloc blocks could triggre BUG by flushing delalloc buffers.
> 
> Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
> ---
>  fs/ext4/inode.c |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index de05e86..384f8a7 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4676,6 +4676,17 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)
>  		return 0;
>  	if (is_journal_aborted(journal))
>  		return -EROFS;
> +	/* We have to allocate physical blocks for delalloc blocks
> +	 * before flushing journal. otherwise delalloc blocks can not
> +	 * be allocated any more. even more truncate on delalloc blocks
> +	 * could trigger BUG by flushing delalloc blocks in journal.
> +	 * There is no delalloc block in non-journal data mode.
> +	 */
> +	if (val && test_opt(inode->i_sb, DELALLOC)) {
> +		err = ext4_alloc_da_blocks(inode);
> +		if (err < 0)
> +			return err;
> +	}
>  
>  	jbd2_journal_lock_updates(journal);
>  	jbd2_journal_flush(journal);

Though I tested your patch by my reproducer that caused a panic which you 
pointed out, a panic did not happen. 
-------------------------------------------------------------------------------
#!/bin/sh

echo "a" > /tmp/a # file under an ext4 filesystem
chattr +j /tmp/a
echo "a" >> /tmp/a
chattr -j /tmp/a
-------------------------------------------------------------------------------

So, this patch looks good to me.

Tested-by: Toshiyuki Okajima <toshi.okajima@jp.fujitsu.com>


  parent reply	other threads:[~2011-12-09  3:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-15  8:07 [PATCH 1/5] ext4: allocate delalloc blocks before changing journal mode Yongqiang Yang
2011-11-15  8:07 ` [PATCH 2/5] ext4: let ext4 journal deletion of data blocks Yongqiang Yang
2011-12-28 17:23   ` Ted Ts'o
2011-12-30 14:59     ` Yongqiang Yang
2011-12-30 15:05       ` Ted Ts'o
2011-11-15  8:07 ` [PATCH 3/5] ext4: let ext4_free_blocks handle multiblock correctly Yongqiang Yang
2011-12-28 17:23   ` Ted Ts'o
2011-11-15  8:07 ` [PATCH 4/5] ext4: flush journal when switching from journal data mode Yongqiang Yang
2011-12-28 18:56   ` Ted Ts'o
2011-12-29 21:01     ` Darrick J. Wong
2011-12-30 14:43       ` Yongqiang Yang
2011-12-30 14:57       ` Ted Ts'o
2011-11-15  8:07 ` [PATCH 5/5] jbd2: clear revoked flag on buffers before a new transaction started Yongqiang Yang
2011-12-28 23:25   ` Ted Ts'o
2011-12-09  3:31 ` Toshiyuki Okajima [this message]
2011-12-28 17:14 ` [PATCH 1/5] ext4: allocate delalloc blocks before changing journal mode Ted Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EE18113.9060503@jp.fujitsu.com \
    --to=toshi.okajima@jp.fujitsu.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=xiaoqiangnk@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.