From: Chao Yu <chao@kernel.org>
To: "yohan.joung" <yohan.joung@sk.com>,
jaegeuk@kernel.org, daehojeong@google.com
Cc: chao@kernel.org, linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net, pilhyun.kim@sk.com
Subject: Re: [PATCH v2 1/2] f2fs: Add a method for calculating the remaining blocks in the current segment in LFS mode.
Date: Tue, 6 May 2025 17:09:26 +0800 [thread overview]
Message-ID: <1db80259-a29d-439e-aaff-2a7daac9c1e5@kernel.org> (raw)
In-Reply-To: <20250502044146.552-1-yohan.joung@sk.com>
On 2025/5/2 12:41, yohan.joung wrote:
> In LFS mode, the previous segment cannot use invalid blocks,
> so the remaining blocks from the next_blkoff of the current segment
> to the end of the section are calculated.
>
> Signed-off-by: yohan.joung <yohan.joung@sk.com>
> ---
> fs/f2fs/segment.h | 21 +++++++++++++++++----
> 1 file changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
> index 03c0f59be5a8..345da052f0e1 100644
> --- a/fs/f2fs/segment.h
> +++ b/fs/f2fs/segment.h
> @@ -582,8 +582,14 @@ static inline bool has_curseg_enough_space(struct f2fs_sb_info *sbi,
> if (unlikely(segno == NULL_SEGNO))
> return false;
>
> - left_blocks = CAP_BLKS_PER_SEC(sbi) -
> - get_ckpt_valid_blocks(sbi, segno, true);
> + if (f2fs_lfs_mode(sbi)) {
f2fs_lfs_mode() && __is_large_section(sbi)?
> + left_blocks = CAP_BLKS_PER_SEC(sbi) -
> + (segno - rounddown(segno, SEGS_PER_SEC(sbi))) * BLKS_PER_SEG(sbi) -
How about using SEGS_TO_BLKS() which will be more efficient? and what do you
think of introducing a new macro to improve code readability?
#define GET_START_SEG_FROM_SEC(sbi, segno) (rounddown(segno, SEGS_PER_SEC(sbi)))
> + CURSEG_I(sbi, i)->next_blkoff;
> + } else {
> + left_blocks = CAP_BLKS_PER_SEC(sbi) -
> + get_ckpt_valid_blocks(sbi, segno, true);
> + }
>
> blocks = i <= CURSEG_COLD_DATA ? data_blocks : node_blocks;
> if (blocks > left_blocks)
> @@ -596,8 +602,15 @@ static inline bool has_curseg_enough_space(struct f2fs_sb_info *sbi,
> if (unlikely(segno == NULL_SEGNO))
> return false;
>
> - left_blocks = CAP_BLKS_PER_SEC(sbi) -
> - get_ckpt_valid_blocks(sbi, segno, true);
> + if (f2fs_lfs_mode(sbi)) {
Ditto,
> + left_blocks = CAP_BLKS_PER_SEC(sbi) -
> + (segno - rounddown(segno, SEGS_PER_SEC(sbi))) * BLKS_PER_SEG(sbi) -
> + CURSEG_I(sbi, CURSEG_HOT_DATA)->next_blkoff;
Ditto,
Thanks,
> + } else {
> + left_blocks = CAP_BLKS_PER_SEC(sbi) -
> + get_ckpt_valid_blocks(sbi, segno, true);
> + }
> +
> if (dent_blocks > left_blocks)
> return false;
> return true;
prev parent reply other threads:[~2025-05-06 9:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-02 4:41 yohan.joung
2025-05-02 4:41 ` [PATCH v2 2/2] f2fs: add ckpt_valid_blocks to the section entry yohan.joung
2025-05-06 9:09 ` Chao Yu [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=1db80259-a29d-439e-aaff-2a7daac9c1e5@kernel.org \
--to=chao@kernel.org \
--cc=daehojeong@google.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=pilhyun.kim@sk.com \
--cc=yohan.joung@sk.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
all inboxes | Powered by JetHome®