linux/fs/f2fs/node.c

// SPDX-License-Identifier: GPL-2.0
/*
 * fs/f2fs/node.c
 *
 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
 *             http://www.samsung.com/
 */
#include <linux/fs.h>
#include <linux/f2fs_fs.h>
#include <linux/mpage.h>
#include <linux/sched/mm.h>
#include <linux/blkdev.h>
#include <linux/pagevec.h>
#include <linux/swap.h>

#include "f2fs.h"
#include "node.h"
#include "segment.h"
#include "xattr.h"
#include "iostat.h"
#include <trace/events/f2fs.h>

#define on_f2fs_build_free_nids(nmi)

static struct kmem_cache *nat_entry_slab;
static struct kmem_cache *free_nid_slab;
static struct kmem_cache *nat_entry_set_slab;
static struct kmem_cache *fsync_node_entry_slab;

/*
 * Check whether the given nid is within node id range.
 */
int f2fs_check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
{}

bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type)
{}

static void clear_node_page_dirty(struct page *page)
{}

static struct page *get_current_nat_page(struct f2fs_sb_info *sbi, nid_t nid)
{}

static struct page *get_next_nat_page(struct f2fs_sb_info *sbi, nid_t nid)
{}

static struct nat_entry *__alloc_nat_entry(struct f2fs_sb_info *sbi,
						nid_t nid, bool no_fail)
{}

static void __free_nat_entry(struct nat_entry *e)
{}

/* must be locked by nat_tree_lock */
static struct nat_entry *__init_nat_entry(struct f2fs_nm_info *nm_i,
	struct nat_entry *ne, struct f2fs_nat_entry *raw_ne, bool no_fail)
{}

static struct nat_entry *__lookup_nat_cache(struct f2fs_nm_info *nm_i, nid_t n)
{}

static unsigned int __gang_lookup_nat_cache(struct f2fs_nm_info *nm_i,
		nid_t start, unsigned int nr, struct nat_entry **ep)
{}

static void __del_from_nat_cache(struct f2fs_nm_info *nm_i, struct nat_entry *e)
{}

static struct nat_entry_set *__grab_nat_entry_set(struct f2fs_nm_info *nm_i,
							struct nat_entry *ne)
{}

static void __set_nat_cache_dirty(struct f2fs_nm_info *nm_i,
						struct nat_entry *ne)
{}

static void __clear_nat_cache_dirty(struct f2fs_nm_info *nm_i,
		struct nat_entry_set *set, struct nat_entry *ne)
{}

static unsigned int __gang_lookup_nat_set(struct f2fs_nm_info *nm_i,
		nid_t start, unsigned int nr, struct nat_entry_set **ep)
{}

bool f2fs_in_warm_node_list(struct f2fs_sb_info *sbi, struct page *page)
{}

void f2fs_init_fsync_node_info(struct f2fs_sb_info *sbi)
{}

static unsigned int f2fs_add_fsync_node_entry(struct f2fs_sb_info *sbi,
							struct page *page)
{}

void f2fs_del_fsync_node_entry(struct f2fs_sb_info *sbi, struct page *page)
{}

void f2fs_reset_fsync_node_info(struct f2fs_sb_info *sbi)
{}

int f2fs_need_dentry_mark(struct f2fs_sb_info *sbi, nid_t nid)
{}

bool f2fs_is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid)
{}

bool f2fs_need_inode_block_update(struct f2fs_sb_info *sbi, nid_t ino)
{}

/* must be locked by nat_tree_lock */
static void cache_nat_entry(struct f2fs_sb_info *sbi, nid_t nid,
						struct f2fs_nat_entry *ne)
{}

static void set_node_addr(struct f2fs_sb_info *sbi, struct node_info *ni,
			block_t new_blkaddr, bool fsync_done)
{}

int f2fs_try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink)
{}

int f2fs_get_node_info(struct f2fs_sb_info *sbi, nid_t nid,
				struct node_info *ni, bool checkpoint_context)
{}

/*
 * readahead MAX_RA_NODE number of node pages.
 */
static void f2fs_ra_node_pages(struct page *parent, int start, int n)
{}

pgoff_t f2fs_get_next_page_offset(struct dnode_of_data *dn, pgoff_t pgofs)
{}

/*
 * The maximum depth is four.
 * Offset[0] will have raw inode offset.
 */
static int get_node_path(struct inode *inode, long block,
				int offset[4], unsigned int noffset[4])
{}

/*
 * Caller should call f2fs_put_dnode(dn).
 * Also, it should grab and release a rwsem by calling f2fs_lock_op() and
 * f2fs_unlock_op() only if mode is set with ALLOC_NODE.
 */
int f2fs_get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode)
{}

static int truncate_node(struct dnode_of_data *dn)
{}

static int truncate_dnode(struct dnode_of_data *dn)
{}

static int truncate_nodes(struct dnode_of_data *dn, unsigned int nofs,
						int ofs, int depth)
{}

static int truncate_partial_nodes(struct dnode_of_data *dn,
			struct f2fs_inode *ri, int *offset, int depth)
{}

/*
 * All the block addresses of data and nodes should be nullified.
 */
int f2fs_truncate_inode_blocks(struct inode *inode, pgoff_t from)
{}

/* caller must lock inode page */
int f2fs_truncate_xattr_node(struct inode *inode)
{}

/*
 * Caller should grab and release a rwsem by calling f2fs_lock_op() and
 * f2fs_unlock_op().
 */
int f2fs_remove_inode_page(struct inode *inode)
{}

struct page *f2fs_new_inode_page(struct inode *inode)
{}

struct page *f2fs_new_node_page(struct dnode_of_data *dn, unsigned int ofs)
{}

/*
 * Caller should do after getting the following values.
 * 0: f2fs_put_page(page, 0)
 * LOCKED_PAGE or error: f2fs_put_page(page, 1)
 */
static int read_node_page(struct page *page, blk_opf_t op_flags)
{}

/*
 * Readahead a node page
 */
void f2fs_ra_node_page(struct f2fs_sb_info *sbi, nid_t nid)
{}

static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
					struct page *parent, int start)
{}

struct page *f2fs_get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
{}

struct page *f2fs_get_node_page_ra(struct page *parent, int start)
{}

static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino)
{}

static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino)
{}

static int __write_node_page(struct page *page, bool atomic, bool *submitted,
				struct writeback_control *wbc, bool do_balance,
				enum iostat_type io_type, unsigned int *seq_id)
{}

int f2fs_move_node_page(struct page *node_page, int gc_type)
{}

static int f2fs_write_node_page(struct page *page,
				struct writeback_control *wbc)
{}

int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
			struct writeback_control *wbc, bool atomic,
			unsigned int *seq_id)
{}

static int f2fs_match_ino(struct inode *inode, unsigned long ino, void *data)
{}

static bool flush_dirty_inode(struct page *page)
{}

void f2fs_flush_inline_data(struct f2fs_sb_info *sbi)
{}

int f2fs_sync_node_pages(struct f2fs_sb_info *sbi,
				struct writeback_control *wbc,
				bool do_balance, enum iostat_type io_type)
{}

int f2fs_wait_on_node_pages_writeback(struct f2fs_sb_info *sbi,
						unsigned int seq_id)
{}

static int f2fs_write_node_pages(struct address_space *mapping,
			    struct writeback_control *wbc)
{}

static bool f2fs_dirty_node_folio(struct address_space *mapping,
		struct folio *folio)
{}

/*
 * Structure of the f2fs node operations
 */
const struct address_space_operations f2fs_node_aops =;

static struct free_nid *__lookup_free_nid_list(struct f2fs_nm_info *nm_i,
						nid_t n)
{}

static int __insert_free_nid(struct f2fs_sb_info *sbi,
				struct free_nid *i)
{}

static void __remove_free_nid(struct f2fs_sb_info *sbi,
			struct free_nid *i, enum nid_state state)
{}

static void __move_free_nid(struct f2fs_sb_info *sbi, struct free_nid *i,
			enum nid_state org_state, enum nid_state dst_state)
{}

bool f2fs_nat_bitmap_enabled(struct f2fs_sb_info *sbi)
{}

static void update_free_nid_bitmap(struct f2fs_sb_info *sbi, nid_t nid,
							bool set, bool build)
{}

/* return if the nid is recognized as free */
static bool add_free_nid(struct f2fs_sb_info *sbi,
				nid_t nid, bool build, bool update)
{}

static void remove_free_nid(struct f2fs_sb_info *sbi, nid_t nid)
{}

static int scan_nat_page(struct f2fs_sb_info *sbi,
			struct page *nat_page, nid_t start_nid)
{}

static void scan_curseg_cache(struct f2fs_sb_info *sbi)
{}

static void scan_free_nid_bits(struct f2fs_sb_info *sbi)
{}

static int __f2fs_build_free_nids(struct f2fs_sb_info *sbi,
						bool sync, bool mount)
{}

int f2fs_build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
{}

/*
 * If this function returns success, caller can obtain a new nid
 * from second parameter of this function.
 * The returned nid could be used ino as well as nid when inode is created.
 */
bool f2fs_alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)
{}

/*
 * f2fs_alloc_nid() should be called prior to this function.
 */
void f2fs_alloc_nid_done(struct f2fs_sb_info *sbi, nid_t nid)
{}

/*
 * f2fs_alloc_nid() should be called prior to this function.
 */
void f2fs_alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid)
{}

int f2fs_try_to_free_nids(struct f2fs_sb_info *sbi, int nr_shrink)
{}

int f2fs_recover_inline_xattr(struct inode *inode, struct page *page)
{}

int f2fs_recover_xattr_data(struct inode *inode, struct page *page)
{}

int f2fs_recover_inode_page(struct f2fs_sb_info *sbi, struct page *page)
{}

int f2fs_restore_node_summary(struct f2fs_sb_info *sbi,
			unsigned int segno, struct f2fs_summary_block *sum)
{}

static void remove_nats_in_journal(struct f2fs_sb_info *sbi)
{}

static void __adjust_nat_entry_set(struct nat_entry_set *nes,
						struct list_head *head, int max)
{}

static void __update_nat_bits(struct f2fs_nm_info *nm_i, unsigned int nat_ofs,
							unsigned int valid)
{}

static void update_nat_bits(struct f2fs_sb_info *sbi, nid_t start_nid,
						struct page *page)
{}

void f2fs_enable_nat_bits(struct f2fs_sb_info *sbi)
{}

static int __flush_nat_entry_set(struct f2fs_sb_info *sbi,
		struct nat_entry_set *set, struct cp_control *cpc)
{}

/*
 * This function is called during the checkpointing process.
 */
int f2fs_flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
{}

static int __get_nat_bitmaps(struct f2fs_sb_info *sbi)
{}

static inline void load_free_nid_bitmap(struct f2fs_sb_info *sbi)
{}

static int init_node_manager(struct f2fs_sb_info *sbi)
{}

static int init_free_nid_cache(struct f2fs_sb_info *sbi)
{}

int f2fs_build_node_manager(struct f2fs_sb_info *sbi)
{}

void f2fs_destroy_node_manager(struct f2fs_sb_info *sbi)
{}

int __init f2fs_create_node_manager_caches(void)
{}

void f2fs_destroy_node_manager_caches(void)
{}