All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
To: Kemeng Shi <shikemeng@huaweicloud.com>,
	tytso@mit.edu, adilger.kernel@dilger.ca,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 02/11] ext4: call ext4_mb_mark_context in ext4_free_blocks_simple
Date: Thu, 31 Aug 2023 19:55:27 +0530	[thread overview]
Message-ID: <87jztb8f1k.fsf@doe.com> (raw)
In-Reply-To: <20230826155028.4019470-3-shikemeng@huaweicloud.com>

Kemeng Shi <shikemeng@huaweicloud.com> writes:

> call ext4_mb_mark_context in ext4_free_blocks_simple to:
> 1. remove repeat code
> 2. pair update of free_clusters in ext4_mb_new_blocks_simple.
> 3. add missing ext4_lock_group/ext4_unlock_group protection.
>
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> ---
>  fs/ext4/mballoc.c | 35 +++--------------------------------
>  1 file changed, 3 insertions(+), 32 deletions(-)

Looks good to me. Please feel free to add - 

Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>

(One small comment below for previous patch)

>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index e2be572deb75..c803f74aaf63 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -6414,43 +6414,14 @@ ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b,
>  static void ext4_free_blocks_simple(struct inode *inode, ext4_fsblk_t block,
>  					unsigned long count)
>  {
> -	struct buffer_head *bitmap_bh;
> +	struct ext4_mark_context mc;
>  	struct super_block *sb = inode->i_sb;
> -	struct ext4_group_desc *gdp;
> -	struct buffer_head *gdp_bh;
>  	ext4_group_t group;
>  	ext4_grpblk_t blkoff;
> -	int already_freed = 0, err, i;
>  
> +	ext4_mb_prepare_mark_context(&mc, sb, 0);

It looks like we always use 0 or 1 as the state for struct
ext4_mark_context. In that case we can keep state member of this struct
as bool instead of int. 


>  	ext4_get_group_no_and_offset(sb, block, &group, &blkoff);
> -	bitmap_bh = ext4_read_block_bitmap(sb, group);
> -	if (IS_ERR(bitmap_bh)) {
> -		pr_warn("Failed to read block bitmap\n");
> -		return;
> -	}
> -	gdp = ext4_get_group_desc(sb, group, &gdp_bh);
> -	if (!gdp)
> -		goto err_out;
> -
> -	for (i = 0; i < count; i++) {
> -		if (!mb_test_bit(blkoff + i, bitmap_bh->b_data))
> -			already_freed++;
> -	}
> -	mb_clear_bits(bitmap_bh->b_data, blkoff, count);
> -	err = ext4_handle_dirty_metadata(NULL, NULL, bitmap_bh);
> -	if (err)
> -		goto err_out;
> -	ext4_free_group_clusters_set(
> -		sb, gdp, ext4_free_group_clusters(sb, gdp) +
> -		count - already_freed);
> -	ext4_block_bitmap_csum_set(sb, gdp, bitmap_bh);
> -	ext4_group_desc_csum_set(sb, group, gdp);
> -	ext4_handle_dirty_metadata(NULL, NULL, gdp_bh);
> -	sync_dirty_buffer(bitmap_bh);
> -	sync_dirty_buffer(gdp_bh);
> -
> -err_out:
> -	brelse(bitmap_bh);
> +	ext4_mb_mark_context(&mc, group, blkoff, count);
>  }
>  
>  /**
> -- 
> 2.30.0

  reply	other threads:[~2023-08-31 14:25 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-26 15:50 [PATCH v6 00/11] cleanups and unit test for mballoc Kemeng Shi
2023-08-26 15:50 ` [PATCH v6 01/11] ext4: factor out codes to update block bitmap and group descriptor on disk from ext4_mb_mark_bb Kemeng Shi
2023-08-31 12:33   ` Ritesh Harjani
2023-08-31 13:42     ` Kemeng Shi
2023-08-31 14:07       ` Ritesh Harjani
2023-09-04  2:50         ` Kemeng Shi
2023-09-04  8:30           ` Ritesh Harjani
2023-08-26 15:50 ` [PATCH v6 02/11] ext4: call ext4_mb_mark_context in ext4_free_blocks_simple Kemeng Shi
2023-08-31 14:25   ` Ritesh Harjani [this message]
2023-09-04  2:51     ` Kemeng Shi
2023-08-26 15:50 ` [PATCH v6 03/11] ext4: extent ext4_mb_mark_context to support allocation under journal Kemeng Shi
2023-08-31 15:51   ` Ritesh Harjani
2023-08-26 15:50 ` [PATCH v6 04/11] ext4: call ext4_mb_mark_context in ext4_mb_mark_diskspace_used Kemeng Shi
2023-09-01  3:51   ` Ritesh Harjani
2023-09-04  2:54     ` Kemeng Shi
2023-08-26 15:50 ` [PATCH v6 05/11] ext4: Separate block bitmap and buddy bitmap freeing in ext4_mb_clear_bb() Kemeng Shi
2023-09-01  9:34   ` Ritesh Harjani
2023-09-04  3:00     ` Kemeng Shi
2023-09-12  7:02       ` Kemeng Shi
2023-09-12 10:13         ` Ritesh Harjani
2023-09-12 11:32           ` Kemeng Shi
2023-08-26 15:50 ` [PATCH v6 06/11] ext4: call ext4_mb_mark_context in ext4_mb_clear_bb Kemeng Shi
2023-09-01  9:38   ` Ritesh Harjani
2023-08-26 15:50 ` [PATCH v6 07/11] ext4: Separate block bitmap and buddy bitmap freeing in ext4_group_add_blocks() Kemeng Shi
2023-08-26 15:50 ` [PATCH v6 08/11] ext4: call ext4_mb_mark_context " Kemeng Shi
2023-09-01  9:50   ` Ritesh Harjani
2023-08-26 15:50 ` [PATCH v6 09/11] ext4: add some kunit stub for mballoc kunit test Kemeng Shi
2023-09-01 14:18   ` Ritesh Harjani
2023-08-26 15:50 ` [PATCH v6 10/11] ext4: add first unit test for ext4_mb_new_blocks_simple in mballoc Kemeng Shi
2023-09-01 14:29   ` Ritesh Harjani
2023-08-26 15:50 ` [PATCH v6 11/11] ext4: run mballoc test with different layouts setting Kemeng Shi
2023-09-01 14:36   ` Ritesh Harjani
2023-09-04  3:01     ` Kemeng Shi
2023-08-29 19:02 ` [PATCH v6 00/11] cleanups and unit test for mballoc Ritesh Harjani
2023-08-30  7:22   ` Kemeng Shi
2023-08-31 14:35     ` Ritesh Harjani

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=87jztb8f1k.fsf@doe.com \
    --to=ritesh.list@gmail.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shikemeng@huaweicloud.com \
    --cc=tytso@mit.edu \
    /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.