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

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

116 goto next;
117 }
118
119 if (has_enough_invalid_blocks(sbi))
120 decrease_sleep_time(gc_th, &wait_ms);
121 else
122 increase_sleep_time(gc_th, &wait_ms);
123do_gc:
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * fs/f2fs/gc.c
4 *
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * http://www.samsung.com/
7 */
8#include <linux/fs.h>

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

116 goto next;
117 }
118
119 if (has_enough_invalid_blocks(sbi))
120 decrease_sleep_time(gc_th, &wait_ms);
121 else
122 increase_sleep_time(gc_th, &wait_ms);
123do_gc:
124 if (!foreground)
125 stat_inc_bggc_count(sbi->stat_info);
124 stat_inc_gc_call_count(sbi, foreground ?
125 FOREGROUND : BACKGROUND);
126
127 sync_mode = F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC;
128
129 /* foreground GC was been triggered via f2fs_balance_fs() */
130 if (foreground)
131 sync_mode = false;
132
133 gc_control.init_gc_type = sync_mode ? FG_GC : BG_GC;

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

1680 struct page *sum_page;
1681 struct f2fs_summary_block *sum;
1682 struct blk_plug plug;
1683 unsigned int segno = start_segno;
1684 unsigned int end_segno = start_segno + sbi->segs_per_sec;
1685 int seg_freed = 0, migrated = 0;
1686 unsigned char type = IS_DATASEG(get_seg_entry(sbi, segno)->type) ?
1687 SUM_TYPE_DATA : SUM_TYPE_NODE;
126
127 sync_mode = F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC;
128
129 /* foreground GC was been triggered via f2fs_balance_fs() */
130 if (foreground)
131 sync_mode = false;
132
133 gc_control.init_gc_type = sync_mode ? FG_GC : BG_GC;

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

1680 struct page *sum_page;
1681 struct f2fs_summary_block *sum;
1682 struct blk_plug plug;
1683 unsigned int segno = start_segno;
1684 unsigned int end_segno = start_segno + sbi->segs_per_sec;
1685 int seg_freed = 0, migrated = 0;
1686 unsigned char type = IS_DATASEG(get_seg_entry(sbi, segno)->type) ?
1687 SUM_TYPE_DATA : SUM_TYPE_NODE;
1688 unsigned char data_type = (type == SUM_TYPE_DATA) ? DATA : NODE;
1688 int submitted = 0;
1689
1690 if (__is_large_section(sbi))
1691 end_segno = rounddown(end_segno, sbi->segs_per_sec);
1692
1693 /*
1694 * zone-capacity can be less than zone-size in zoned devices,
1695 * resulting in less than expected usable segments in the zone,

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

1761 if (type == SUM_TYPE_NODE)
1762 submitted += gc_node_segment(sbi, sum->entries, segno,
1763 gc_type);
1764 else
1765 submitted += gc_data_segment(sbi, sum->entries, gc_list,
1766 segno, gc_type,
1767 force_migrate);
1768
1689 int submitted = 0;
1690
1691 if (__is_large_section(sbi))
1692 end_segno = rounddown(end_segno, sbi->segs_per_sec);
1693
1694 /*
1695 * zone-capacity can be less than zone-size in zoned devices,
1696 * resulting in less than expected usable segments in the zone,

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

1762 if (type == SUM_TYPE_NODE)
1763 submitted += gc_node_segment(sbi, sum->entries, segno,
1764 gc_type);
1765 else
1766 submitted += gc_data_segment(sbi, sum->entries, gc_list,
1767 segno, gc_type,
1768 force_migrate);
1769
1769 stat_inc_seg_count(sbi, type, gc_type);
1770 stat_inc_gc_seg_count(sbi, data_type, gc_type);
1770 sbi->gc_reclaimed_segs[sbi->gc_mode]++;
1771 migrated++;
1772
1773freed:
1774 if (gc_type == FG_GC &&
1775 get_valid_blocks(sbi, segno, false) == 0)
1776 seg_freed++;
1777
1778 if (__is_large_section(sbi))
1779 sbi->next_victim_seg[gc_type] =
1780 (segno + 1 < end_segno) ? segno + 1 : NULL_SEGNO;
1781skip:
1782 f2fs_put_page(sum_page, 0);
1783 }
1784
1785 if (submitted)
1771 sbi->gc_reclaimed_segs[sbi->gc_mode]++;
1772 migrated++;
1773
1774freed:
1775 if (gc_type == FG_GC &&
1776 get_valid_blocks(sbi, segno, false) == 0)
1777 seg_freed++;
1778
1779 if (__is_large_section(sbi))
1780 sbi->next_victim_seg[gc_type] =
1781 (segno + 1 < end_segno) ? segno + 1 : NULL_SEGNO;
1782skip:
1783 f2fs_put_page(sum_page, 0);
1784 }
1785
1786 if (submitted)
1786 f2fs_submit_merged_write(sbi,
1787 (type == SUM_TYPE_NODE) ? NODE : DATA);
1787 f2fs_submit_merged_write(sbi, data_type);
1788
1789 blk_finish_plug(&plug);
1790
1788
1789 blk_finish_plug(&plug);
1790
1791 stat_inc_call_count(sbi->stat_info);
1791 if (migrated)
1792 stat_inc_gc_sec_count(sbi, data_type, gc_type);
1792
1793 return seg_freed;
1794}
1795
1796int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control)
1797{
1798 int gc_type = gc_control->init_gc_type;
1799 unsigned int segno = gc_control->victim_segno;

--- 446 unchanged lines hidden ---
1793
1794 return seg_freed;
1795}
1796
1797int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control)
1798{
1799 int gc_type = gc_control->init_gc_type;
1800 unsigned int segno = gc_control->victim_segno;

--- 446 unchanged lines hidden ---