linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@mit.edu>
To: Wang Jianjian <wangjianjian0@foxmail.com>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext4: Free data blocks directly for ordered journal
Date: Thu, 17 Aug 2023 15:54:15 -0400	[thread overview]
Message-ID: <20230817195415.GE2247938@mit.edu> (raw)
In-Reply-To: <tencent_D6CD42314E6CD7A9ABA771CF10C464390005@qq.com>

On Sat, Jun 24, 2023 at 11:52:59PM +0800, Wang Jianjian wrote:
> ---
>  fs/ext4/mballoc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 7b2e36d103cb..41fdc2f8c061 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -6206,7 +6206,7 @@ static void ext4_mb_clear_bb(handle_t *handle, struct inode *inode,
>  	 * consistency guarantees.
>  	 */
>  	if (ext4_handle_valid(handle) &&
> -	    ((flags & EXT4_FREE_BLOCKS_METADATA) ||
> +	    ((ext4_should_order_data(inode) && (flags & EXT4_FREE_BLOCKS_METADATA)) ||
>  	     !ext4_should_writeback_data(inode))) {
>  		struct ext4_free_data *new_entry;
>  		/*

This is not a safe thing to do, so I have to reject this patch.  As
stated in the comment immediately above this code:

	/*
	 * We need to make sure we don't reuse the freed block until after the
	 * transaction is committed. We make an exception if the inode is to be
	 * written in writeback mode since writeback mode has weak data
	 * consistency guarantees.
	 */

In ordered mode, we *do* care that if a file is deleted, and then the
block gets reallocated and used for some new file --- and then we
crash before a transaction commits, then the not-actually-deleted file
would have its data blocks corrupted.

							- Ted

      reply	other threads:[~2023-08-17 19:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-24 15:52 [PATCH] ext4: Free data blocks directly for ordered journal Wang Jianjian
2023-08-17 19:54 ` Theodore Ts'o [this message]

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=20230817195415.GE2247938@mit.edu \
    --to=tytso@mit.edu \
    --cc=linux-ext4@vger.kernel.org \
    --cc=wangjianjian0@foxmail.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 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).