From: Jan Kara <jack@suse.cz>
To: Zhang Yi <yi.zhang@huaweicloud.com>
Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz,
yi.zhang@huawei.com, chengzhihao1@huawei.com, yukuai3@huawei.com
Subject: Re: [PATCH v2 6/9] ext4: make ext4_da_reserve_space() reserve multi-clusters
Date: Mon, 29 Apr 2024 11:25:36 +0200 [thread overview]
Message-ID: <20240429092536.mtlqw4omhc3mrd5g@quack3> (raw)
In-Reply-To: <20240410034203.2188357-7-yi.zhang@huaweicloud.com>
On Wed 10-04-24 11:42:00, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
>
> Add 'nr_resv' parameter to ext4_da_reserve_space(), which indicates the
> number of clusters wants to reserve, make it reserve multi-clusters once
> a time.
>
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/inode.c | 18 +++++++++---------
> include/trace/events/ext4.h | 10 ++++++----
> 2 files changed, 15 insertions(+), 13 deletions(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index d37233e2ed0b..1180a9eb4362 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -1479,9 +1479,9 @@ static int ext4_journalled_write_end(struct file *file,
> }
>
> /*
> - * Reserve space for a single cluster
> + * Reserve space for 'nr_resv' clusters
> */
> -static int ext4_da_reserve_space(struct inode *inode)
> +static int ext4_da_reserve_space(struct inode *inode, int nr_resv)
> {
> struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
> struct ext4_inode_info *ei = EXT4_I(inode);
> @@ -1492,18 +1492,18 @@ static int ext4_da_reserve_space(struct inode *inode)
> * us from metadata over-estimation, though we may go over by
> * a small amount in the end. Here we just reserve for data.
> */
> - ret = dquot_reserve_block(inode, EXT4_C2B(sbi, 1));
> + ret = dquot_reserve_block(inode, EXT4_C2B(sbi, nr_resv));
> if (ret)
> return ret;
>
> spin_lock(&ei->i_block_reservation_lock);
> - if (ext4_claim_free_clusters(sbi, 1, 0)) {
> + if (ext4_claim_free_clusters(sbi, nr_resv, 0)) {
> spin_unlock(&ei->i_block_reservation_lock);
> - dquot_release_reservation_block(inode, EXT4_C2B(sbi, 1));
> + dquot_release_reservation_block(inode, EXT4_C2B(sbi, nr_resv));
> return -ENOSPC;
> }
> - ei->i_reserved_data_blocks++;
> - trace_ext4_da_reserve_space(inode);
> + ei->i_reserved_data_blocks += nr_resv;
> + trace_ext4_da_reserve_space(inode, nr_resv);
> spin_unlock(&ei->i_block_reservation_lock);
>
> return 0; /* success */
> @@ -1678,7 +1678,7 @@ static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk)
> * extents status tree doesn't get a match.
> */
> if (sbi->s_cluster_ratio == 1) {
> - ret = ext4_da_reserve_space(inode);
> + ret = ext4_da_reserve_space(inode, 1);
> if (ret != 0) /* ENOSPC */
> return ret;
> } else { /* bigalloc */
> @@ -1690,7 +1690,7 @@ static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk)
> if (ret < 0)
> return ret;
> if (ret == 0) {
> - ret = ext4_da_reserve_space(inode);
> + ret = ext4_da_reserve_space(inode, 1);
> if (ret != 0) /* ENOSPC */
> return ret;
> } else {
> diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
> index 6b41ac61310f..cc5e9b7b2b44 100644
> --- a/include/trace/events/ext4.h
> +++ b/include/trace/events/ext4.h
> @@ -1246,14 +1246,15 @@ TRACE_EVENT(ext4_da_update_reserve_space,
> );
>
> TRACE_EVENT(ext4_da_reserve_space,
> - TP_PROTO(struct inode *inode),
> + TP_PROTO(struct inode *inode, int nr_resv),
>
> - TP_ARGS(inode),
> + TP_ARGS(inode, nr_resv),
>
> TP_STRUCT__entry(
> __field( dev_t, dev )
> __field( ino_t, ino )
> __field( __u64, i_blocks )
> + __field( int, reserve_blocks )
> __field( int, reserved_data_blocks )
> __field( __u16, mode )
> ),
> @@ -1262,16 +1263,17 @@ TRACE_EVENT(ext4_da_reserve_space,
> __entry->dev = inode->i_sb->s_dev;
> __entry->ino = inode->i_ino;
> __entry->i_blocks = inode->i_blocks;
> + __entry->reserve_blocks = nr_resv;
> __entry->reserved_data_blocks = EXT4_I(inode)->i_reserved_data_blocks;
> __entry->mode = inode->i_mode;
> ),
>
> - TP_printk("dev %d,%d ino %lu mode 0%o i_blocks %llu "
> + TP_printk("dev %d,%d ino %lu mode 0%o i_blocks %llu reserve_blocks %d"
> "reserved_data_blocks %d",
> MAJOR(__entry->dev), MINOR(__entry->dev),
> (unsigned long) __entry->ino,
> __entry->mode, __entry->i_blocks,
> - __entry->reserved_data_blocks)
> + __entry->reserve_blocks, __entry->reserved_data_blocks)
> );
>
> TRACE_EVENT(ext4_da_release_space,
> --
> 2.39.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2024-04-29 9:25 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-10 3:41 [PATCH v2 0/9] ext4: support adding multi-delalloc blocks Zhang Yi
2024-04-10 3:41 ` [PATCH v2 1/9] ext4: factor out a common helper to query extent map Zhang Yi
2024-04-24 20:05 ` Jan Kara
2024-04-10 3:41 ` [PATCH v2 2/9] ext4: check the extent status again before inserting delalloc block Zhang Yi
2024-04-24 20:05 ` Jan Kara
2024-04-10 3:41 ` [PATCH v2 3/9] ext4: trim delalloc extent Zhang Yi
2024-04-25 15:56 ` Jan Kara
2024-04-26 9:38 ` Zhang Yi
2024-04-29 10:25 ` Jan Kara
2024-04-29 11:28 ` Zhang Yi
2024-04-10 3:41 ` [PATCH v2 4/9] ext4: drop iblock parameter Zhang Yi
2024-04-29 7:34 ` Jan Kara
2024-04-10 3:41 ` [PATCH v2 5/9] ext4: make ext4_es_insert_delayed_block() insert multi-blocks Zhang Yi
2024-04-29 9:16 ` Jan Kara
2024-04-29 12:09 ` Zhang Yi
2024-04-29 16:27 ` Jan Kara
2024-04-29 9:24 ` Jan Kara
2024-04-10 3:42 ` [PATCH v2 6/9] ext4: make ext4_da_reserve_space() reserve multi-clusters Zhang Yi
2024-04-29 9:25 ` Jan Kara [this message]
2024-04-10 3:42 ` [PATCH v2 7/9] ext4: factor out check for whether a cluster is allocated Zhang Yi
2024-04-10 3:42 ` [PATCH v2 8/9] ext4: make ext4_insert_delayed_block() insert multi-blocks Zhang Yi
2024-04-29 10:06 ` Jan Kara
2024-04-29 12:54 ` Zhang Yi
2024-04-10 3:42 ` [PATCH v2 9/9] ext4: make ext4_da_map_blocks() buffer_head unaware Zhang Yi
2024-04-29 10:27 ` Jan Kara
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=20240429092536.mtlqw4omhc3mrd5g@quack3 \
--to=jack@suse.cz \
--cc=adilger.kernel@dilger.ca \
--cc=chengzhihao1@huawei.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=yi.zhang@huawei.com \
--cc=yi.zhang@huaweicloud.com \
--cc=yukuai3@huawei.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