Skip to content

Commit 5bc5aae

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: zone: introduce first_zoned_segno in f2fs_sb_info
first_zoned_segno() returns a fixed value, let's cache it in structure f2fs_sb_info to avoid redundant calculation. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 128d333 commit 5bc5aae

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

fs/f2fs/f2fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,6 +1759,7 @@ struct f2fs_sb_info {
17591759
unsigned int dirty_device; /* for checkpoint data flush */
17601760
spinlock_t dev_lock; /* protect dirty_device */
17611761
bool aligned_blksize; /* all devices has the same logical blksize */
1762+
unsigned int first_zoned_segno; /* first zoned segno */
17621763

17631764
/* For write statistics */
17641765
u64 sectors_written_start;

fs/f2fs/segment.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,7 +2711,7 @@ static int get_new_segment(struct f2fs_sb_info *sbi,
27112711
if (sbi->blkzone_alloc_policy == BLKZONE_ALLOC_PRIOR_CONV || pinning)
27122712
segno = 0;
27132713
else
2714-
segno = max(first_zoned_segno(sbi), *newseg);
2714+
segno = max(sbi->first_zoned_segno, *newseg);
27152715
hint = GET_SEC_FROM_SEG(sbi, segno);
27162716
}
27172717
#endif
@@ -2723,7 +2723,7 @@ static int get_new_segment(struct f2fs_sb_info *sbi,
27232723
if (secno >= MAIN_SECS(sbi) && f2fs_sb_has_blkzoned(sbi)) {
27242724
/* Write only to sequential zones */
27252725
if (sbi->blkzone_alloc_policy == BLKZONE_ALLOC_ONLY_SEQ) {
2726-
hint = GET_SEC_FROM_SEG(sbi, first_zoned_segno(sbi));
2726+
hint = GET_SEC_FROM_SEG(sbi, sbi->first_zoned_segno);
27272727
secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
27282728
} else
27292729
secno = find_first_zero_bit(free_i->free_secmap,

fs/f2fs/segment.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -974,13 +974,3 @@ static inline void wake_up_discard_thread(struct f2fs_sb_info *sbi, bool force)
974974
dcc->discard_wake = true;
975975
wake_up_interruptible_all(&dcc->discard_wait_queue);
976976
}
977-
978-
static inline unsigned int first_zoned_segno(struct f2fs_sb_info *sbi)
979-
{
980-
int devi;
981-
982-
for (devi = 0; devi < sbi->s_ndevs; devi++)
983-
if (bdev_is_zoned(FDEV(devi).bdev))
984-
return GET_SEGNO(sbi, FDEV(devi).start_blk);
985-
return 0;
986-
}

fs/f2fs/super.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4221,6 +4221,16 @@ static void f2fs_record_error_work(struct work_struct *work)
42214221
f2fs_record_stop_reason(sbi);
42224222
}
42234223

4224+
static inline unsigned int get_first_zoned_segno(struct f2fs_sb_info *sbi)
4225+
{
4226+
int devi;
4227+
4228+
for (devi = 0; devi < sbi->s_ndevs; devi++)
4229+
if (bdev_is_zoned(FDEV(devi).bdev))
4230+
return GET_SEGNO(sbi, FDEV(devi).start_blk);
4231+
return 0;
4232+
}
4233+
42244234
static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
42254235
{
42264236
struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
@@ -4621,6 +4631,9 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
46214631
/* For write statistics */
46224632
sbi->sectors_written_start = f2fs_get_sectors_written(sbi);
46234633

4634+
/* get segno of first zoned block device */
4635+
sbi->first_zoned_segno = get_first_zoned_segno(sbi);
4636+
46244637
/* Read accumulated write IO statistics if exists */
46254638
seg_i = CURSEG_I(sbi, CURSEG_HOT_NODE);
46264639
if (__exist_node_summaries(sbi))

0 commit comments

Comments
 (0)