#include <linux/fs.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/f2fs_fs.h>
#include <linux/kthread.h>
#include <linux/delay.h>
#include <linux/freezer.h>
#include <linux/sched/signal.h>
#include <linux/random.h>
#include <linux/sched/mm.h>
#include "f2fs.h"
#include "node.h"
#include "segment.h"
#include "gc.h"
#include "iostat.h"
#include <trace/events/f2fs.h>
static struct kmem_cache *victim_entry_slab;
static unsigned int count_bits(const unsigned long *addr,
unsigned int offset, unsigned int len);
static int gc_thread_func(void *data)
{ … }
int f2fs_start_gc_thread(struct f2fs_sb_info *sbi)
{ … }
void f2fs_stop_gc_thread(struct f2fs_sb_info *sbi)
{ … }
static int select_gc_type(struct f2fs_sb_info *sbi, int gc_type)
{ … }
static void select_policy(struct f2fs_sb_info *sbi, int gc_type,
int type, struct victim_sel_policy *p)
{ … }
static unsigned int get_max_cost(struct f2fs_sb_info *sbi,
struct victim_sel_policy *p)
{ … }
static unsigned int check_bg_victims(struct f2fs_sb_info *sbi)
{ … }
static unsigned int get_cb_cost(struct f2fs_sb_info *sbi, unsigned int segno)
{ … }
static inline unsigned int get_gc_cost(struct f2fs_sb_info *sbi,
unsigned int segno, struct victim_sel_policy *p)
{ … }
static unsigned int count_bits(const unsigned long *addr,
unsigned int offset, unsigned int len)
{ … }
static bool f2fs_check_victim_tree(struct f2fs_sb_info *sbi,
struct rb_root_cached *root)
{ … }
static struct victim_entry *__lookup_victim_entry(struct f2fs_sb_info *sbi,
unsigned long long mtime)
{ … }
static struct victim_entry *__create_victim_entry(struct f2fs_sb_info *sbi,
unsigned long long mtime, unsigned int segno)
{ … }
static void __insert_victim_entry(struct f2fs_sb_info *sbi,
unsigned long long mtime, unsigned int segno)
{ … }
static void add_victim_entry(struct f2fs_sb_info *sbi,
struct victim_sel_policy *p, unsigned int segno)
{ … }
static void atgc_lookup_victim(struct f2fs_sb_info *sbi,
struct victim_sel_policy *p)
{ … }
static void atssr_lookup_victim(struct f2fs_sb_info *sbi,
struct victim_sel_policy *p)
{ … }
static void lookup_victim_by_age(struct f2fs_sb_info *sbi,
struct victim_sel_policy *p)
{ … }
static void release_victim_entry(struct f2fs_sb_info *sbi)
{ … }
static bool f2fs_pin_section(struct f2fs_sb_info *sbi, unsigned int segno)
{ … }
static bool f2fs_pinned_section_exists(struct dirty_seglist_info *dirty_i)
{ … }
static bool f2fs_section_is_pinned(struct dirty_seglist_info *dirty_i,
unsigned int secno)
{ … }
static void f2fs_unpin_all_sections(struct f2fs_sb_info *sbi, bool enable)
{ … }
static int f2fs_gc_pinned_control(struct inode *inode, int gc_type,
unsigned int segno)
{ … }
int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result,
int gc_type, int type, char alloc_mode,
unsigned long long age)
{ … }
static struct inode *find_gc_inode(struct gc_inode_list *gc_list, nid_t ino)
{ … }
static void add_gc_inode(struct gc_inode_list *gc_list, struct inode *inode)
{ … }
static void put_gc_inode(struct gc_inode_list *gc_list)
{ … }
static int check_valid_map(struct f2fs_sb_info *sbi,
unsigned int segno, int offset)
{ … }
static int gc_node_segment(struct f2fs_sb_info *sbi,
struct f2fs_summary *sum, unsigned int segno, int gc_type)
{ … }
block_t f2fs_start_bidx_of_node(unsigned int node_ofs, struct inode *inode)
{ … }
static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
struct node_info *dni, block_t blkaddr, unsigned int *nofs)
{ … }
static int ra_data_block(struct inode *inode, pgoff_t index)
{ … }
static int move_data_block(struct inode *inode, block_t bidx,
int gc_type, unsigned int segno, int off)
{ … }
static int move_data_page(struct inode *inode, block_t bidx, int gc_type,
unsigned int segno, int off)
{ … }
static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
struct gc_inode_list *gc_list, unsigned int segno, int gc_type,
bool force_migrate)
{ … }
static int __get_victim(struct f2fs_sb_info *sbi, unsigned int *victim,
int gc_type)
{ … }
static int do_garbage_collect(struct f2fs_sb_info *sbi,
unsigned int start_segno,
struct gc_inode_list *gc_list, int gc_type,
bool force_migrate)
{ … }
int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control)
{ … }
int __init f2fs_create_garbage_collection_cache(void)
{ … }
void f2fs_destroy_garbage_collection_cache(void)
{ … }
static void init_atgc_management(struct f2fs_sb_info *sbi)
{ … }
void f2fs_build_gc_manager(struct f2fs_sb_info *sbi)
{ … }
int f2fs_gc_range(struct f2fs_sb_info *sbi,
unsigned int start_seg, unsigned int end_seg,
bool dry_run, unsigned int dry_run_sections)
{ … }
static int free_segment_range(struct f2fs_sb_info *sbi,
unsigned int secs, bool dry_run)
{ … }
static void update_sb_metadata(struct f2fs_sb_info *sbi, int secs)
{ … }
static void update_fs_metadata(struct f2fs_sb_info *sbi, int secs)
{ … }
int f2fs_resize_fs(struct file *filp, __u64 block_count)
{ … }