segment.c (97767500781fae9c53b7d227f99f1dbb0dfe9a4f) segment.c (901d745f8e6a61a835b12314d8b8a41df7012596)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * fs/f2fs/segment.c
4 *
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * http://www.samsung.com/
7 */
8#include <linux/fs.h>

--- 2719 unchanged lines hidden (view full) ---

2728 if (segno != curseg->segno)
2729 f2fs_notice(sbi, "For resize: curseg of type %d: %u ==> %u",
2730 type, segno, curseg->segno);
2731
2732 mutex_unlock(&curseg->curseg_mutex);
2733 up_read(&SM_I(sbi)->curseg_lock);
2734}
2735
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * fs/f2fs/segment.c
4 *
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * http://www.samsung.com/
7 */
8#include <linux/fs.h>

--- 2719 unchanged lines hidden (view full) ---

2728 if (segno != curseg->segno)
2729 f2fs_notice(sbi, "For resize: curseg of type %d: %u ==> %u",
2730 type, segno, curseg->segno);
2731
2732 mutex_unlock(&curseg->curseg_mutex);
2733 up_read(&SM_I(sbi)->curseg_lock);
2734}
2735
2736void f2fs_allocate_new_segments(struct f2fs_sb_info *sbi, int type)
2736static void __allocate_new_segment(struct f2fs_sb_info *sbi, int type)
2737{
2737{
2738 struct curseg_info *curseg;
2738 struct curseg_info *curseg = CURSEG_I(sbi, type);
2739 unsigned int old_segno;
2739 unsigned int old_segno;
2740 int i;
2741
2740
2742 down_write(&SIT_I(sbi)->sentry_lock);
2741 if (!curseg->next_blkoff &&
2742 !get_valid_blocks(sbi, curseg->segno, false) &&
2743 !get_ckpt_valid_blocks(sbi, curseg->segno))
2744 return;
2743
2745
2744 for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
2745 if (type != NO_CHECK_TYPE && i != type)
2746 continue;
2746 old_segno = curseg->segno;
2747 SIT_I(sbi)->s_ops->allocate_segment(sbi, type, true);
2748 locate_dirty_segment(sbi, old_segno);
2749}
2747
2750
2748 curseg = CURSEG_I(sbi, i);
2749 if (type == NO_CHECK_TYPE || curseg->next_blkoff ||
2750 get_valid_blocks(sbi, curseg->segno, false) ||
2751 get_ckpt_valid_blocks(sbi, curseg->segno)) {
2752 old_segno = curseg->segno;
2753 SIT_I(sbi)->s_ops->allocate_segment(sbi, i, true);
2754 locate_dirty_segment(sbi, old_segno);
2755 }
2756 }
2751void f2fs_allocate_new_segment(struct f2fs_sb_info *sbi, int type)
2752{
2753 down_write(&SIT_I(sbi)->sentry_lock);
2754 __allocate_new_segment(sbi, type);
2755 up_write(&SIT_I(sbi)->sentry_lock);
2756}
2757
2757
2758void f2fs_allocate_new_segments(struct f2fs_sb_info *sbi)
2759{
2760 int i;
2761
2762 down_write(&SIT_I(sbi)->sentry_lock);
2763 for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++)
2764 __allocate_new_segment(sbi, i);
2758 up_write(&SIT_I(sbi)->sentry_lock);
2759}
2760
2761static const struct segment_allocation default_salloc_ops = {
2762 .allocate_segment = allocate_segment_by_default,
2763};
2764
2765bool f2fs_exist_trim_candidates(struct f2fs_sb_info *sbi,

--- 2169 unchanged lines hidden ---
2765 up_write(&SIT_I(sbi)->sentry_lock);
2766}
2767
2768static const struct segment_allocation default_salloc_ops = {
2769 .allocate_segment = allocate_segment_by_default,
2770};
2771
2772bool f2fs_exist_trim_candidates(struct f2fs_sb_info *sbi,

--- 2169 unchanged lines hidden ---