From: Christoph Hellwig <hch@lst.de>
To: Jaegeuk Kim <jaegeuk@kernel.org>, Chao Yu <chao@kernel.org>
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [PATCH 3/8] f2fs: add a f2fs_curseg_valid_blocks helper
Date: Thu, 19 Jan 2023 07:36:20 +0100 [thread overview]
Message-ID: <20230119063625.466485-4-hch@lst.de> (raw)
In-Reply-To: <20230119063625.466485-1-hch@lst.de>
Add a helper to return the valid blocks on log and SSR segments, and
replace the last two uses of curseg_blkoff with it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/f2fs/segment.c | 32 +++++++++++++++-----------------
fs/f2fs/segment.h | 6 ------
2 files changed, 15 insertions(+), 23 deletions(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index ec6880213e8fa9..ad323b6e8609cd 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2323,6 +2323,15 @@ bool f2fs_is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr)
return is_cp;
}
+static unsigned short f2fs_curseg_valid_blocks(struct f2fs_sb_info *sbi, int type)
+{
+ struct curseg_info *curseg = CURSEG_I(sbi, type);
+
+ if (sbi->ckpt->alloc_type[type] == SSR)
+ return sbi->blocks_per_seg;
+ return curseg->next_blkoff;
+}
+
/*
* Calculate the number of current summary pages for writing
*/
@@ -2332,15 +2341,11 @@ int f2fs_npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra)
int i, sum_in_page;
for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
- if (sbi->ckpt->alloc_type[i] == SSR)
- valid_sum_count += sbi->blocks_per_seg;
- else {
- if (for_ra)
- valid_sum_count += le16_to_cpu(
- F2FS_CKPT(sbi)->cur_data_blkoff[i]);
- else
- valid_sum_count += curseg_blkoff(sbi, i);
- }
+ if (sbi->ckpt->alloc_type[i] != SSR && for_ra)
+ valid_sum_count +=
+ le16_to_cpu(F2FS_CKPT(sbi)->cur_data_blkoff[i]);
+ else
+ valid_sum_count += f2fs_curseg_valid_blocks(sbi, i);
}
sum_in_page = (PAGE_SIZE - 2 * SUM_JOURNAL_SIZE -
@@ -3861,15 +3866,8 @@ static void write_compacted_summaries(struct f2fs_sb_info *sbi, block_t blkaddr)
/* Step 3: write summary entries */
for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
- unsigned short blkoff;
-
seg_i = CURSEG_I(sbi, i);
- if (sbi->ckpt->alloc_type[i] == SSR)
- blkoff = sbi->blocks_per_seg;
- else
- blkoff = curseg_blkoff(sbi, i);
-
- for (j = 0; j < blkoff; j++) {
+ for (j = 0; j < f2fs_curseg_valid_blocks(sbi, i); j++) {
if (!page) {
page = f2fs_grab_meta_page(sbi, blkaddr++);
kaddr = (unsigned char *)page_address(page);
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index ad6a9c19f46a48..0f3f05cb8c29f5 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -710,12 +710,6 @@ static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi,
return curseg->alloc_type;
}
-static inline unsigned short curseg_blkoff(struct f2fs_sb_info *sbi, int type)
-{
- struct curseg_info *curseg = CURSEG_I(sbi, type);
- return curseg->next_blkoff;
-}
-
static inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno)
{
f2fs_bug_on(sbi, segno > TOTAL_SEGS(sbi) - 1);
--
2.39.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2023-01-19 6:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-19 6:36 [f2fs-dev] misc f2fs cleanups Christoph Hellwig
2023-01-19 6:36 ` [f2fs-dev] [PATCH 1/8] f2fs: remove __add_sum_entry Christoph Hellwig
2023-01-29 10:29 ` Chao Yu
2023-01-31 19:10 ` patchwork-bot+f2fs
2023-01-19 6:36 ` [f2fs-dev] [PATCH 2/8] f2fs: simplify do_checkpoint Christoph Hellwig
2023-01-29 10:30 ` Chao Yu
2023-01-19 6:36 ` Christoph Hellwig [this message]
2023-01-29 10:34 ` [f2fs-dev] [PATCH 3/8] f2fs: add a f2fs_curseg_valid_blocks helper Chao Yu
2023-01-19 6:36 ` [f2fs-dev] [PATCH 4/8] f2fs: factor the read/write tracing logic into a helper Christoph Hellwig
2023-01-29 10:36 ` Chao Yu
2023-01-30 23:00 ` Jaegeuk Kim
2023-01-19 6:36 ` [f2fs-dev] [PATCH 5/8] f2fs: refactor __allocate_new_segment Christoph Hellwig
2023-01-29 10:39 ` Chao Yu
2023-01-19 6:36 ` [f2fs-dev] [PATCH 6/8] f2fs: remove __allocate_new_section Christoph Hellwig
2023-01-29 10:39 ` Chao Yu
2023-01-19 6:36 ` [f2fs-dev] [PATCH 7/8] f2fs: refactor next blk selection Christoph Hellwig
2023-01-29 12:20 ` Chao Yu
2023-01-19 6:36 ` [f2fs-dev] [PATCH 8/8] f2fs: remove __has_curseg_space Christoph Hellwig
2023-01-29 12:24 ` Chao Yu
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=20230119063625.466485-4-hch@lst.de \
--to=hch@lst.de \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/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).