linux/include/linux/f2fs_fs.h

// SPDX-License-Identifier: GPL-2.0
/**
 * include/linux/f2fs_fs.h
 *
 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
 *             http://www.samsung.com/
 */
#ifndef _LINUX_F2FS_FS_H
#define _LINUX_F2FS_FS_H

#include <linux/pagemap.h>
#include <linux/types.h>

#define F2FS_SUPER_OFFSET
#define F2FS_MIN_LOG_SECTOR_SIZE
#define F2FS_MAX_LOG_SECTOR_SIZE
#define F2FS_LOG_SECTORS_PER_BLOCK
#define F2FS_BLKSIZE
#define F2FS_BLKSIZE_BITS
#define F2FS_MAX_EXTENSION
#define F2FS_EXTENSION_LEN
#define F2FS_BLK_ALIGN(x)

#define NULL_ADDR
#define NEW_ADDR
#define COMPRESS_ADDR

#define F2FS_BYTES_TO_BLK(bytes)
#define F2FS_BLK_TO_BYTES(blk)
#define F2FS_BLK_END_BYTES(blk)

/* 0, 1(node nid), 2(meta nid) are reserved node id */
#define F2FS_RESERVED_NODE_NUM

#define F2FS_ROOT_INO(sbi)
#define F2FS_NODE_INO(sbi)
#define F2FS_META_INO(sbi)
#define F2FS_COMPRESS_INO(sbi)

#define F2FS_MAX_QUOTAS

#define F2FS_ENC_UTF8_12_1

/* This flag is used by node and meta inodes, and by recovery */
#define GFP_F2FS_ZERO

/*
 * For further optimization on multi-head logs, on-disk layout supports maximum
 * 16 logs by default. The number, 16, is expected to cover all the cases
 * enoughly. The implementaion currently uses no more than 6 logs.
 * Half the logs are used for nodes, and the other half are used for data.
 */
#define MAX_ACTIVE_LOGS
#define MAX_ACTIVE_NODE_LOGS
#define MAX_ACTIVE_DATA_LOGS

#define VERSION_LEN
#define MAX_VOLUME_NAME
#define MAX_PATH_LEN
#define MAX_DEVICES

/*
 * For superblock
 */
struct f2fs_device {} __packed;

/* reason of stop_checkpoint */
enum stop_cp_reason {};

#define MAX_STOP_REASON

/* detail reason for EFSCORRUPTED */
enum f2fs_error {};

#define MAX_F2FS_ERRORS

struct f2fs_super_block {} __packed;

/*
 * For checkpoint
 */
#define CP_RESIZEFS_FLAG
#define CP_DISABLED_QUICK_FLAG
#define CP_DISABLED_FLAG
#define CP_QUOTA_NEED_FSCK_FLAG
#define CP_LARGE_NAT_BITMAP_FLAG
#define CP_NOCRC_RECOVERY_FLAG
#define CP_TRIMMED_FLAG
#define CP_NAT_BITS_FLAG
#define CP_CRC_RECOVERY_FLAG
#define CP_FASTBOOT_FLAG
#define CP_FSCK_FLAG
#define CP_ERROR_FLAG
#define CP_COMPACT_SUM_FLAG
#define CP_ORPHAN_PRESENT_FLAG
#define CP_UMOUNT_FLAG

#define F2FS_CP_PACKS

struct f2fs_checkpoint {} __packed;

#define CP_CHKSUM_OFFSET
#define CP_MIN_CHKSUM_OFFSET

/*
 * For orphan inode management
 */
#define F2FS_ORPHANS_PER_BLOCK

#define GET_ORPHAN_BLOCKS(n)

struct f2fs_orphan_block {} __packed;

/*
 * For NODE structure
 */
struct f2fs_extent {} __packed;

#define F2FS_NAME_LEN
/* 200 bytes for inline xattrs by default */
#define DEFAULT_INLINE_XATTR_ADDRS

#define OFFSET_OF_END_OF_I_EXT
#define SIZE_OF_I_NID

struct node_footer {} __packed;

/* Address Pointers in an Inode */
#define DEF_ADDRS_PER_INODE
#define CUR_ADDRS_PER_INODE(inode)
#define DEF_NIDS_PER_INODE
#define ADDRS_PER_INODE(inode)
/* Address Pointers in a Direct Block */
#define DEF_ADDRS_PER_BLOCK
#define ADDRS_PER_BLOCK(inode)
/* Node IDs in an Indirect Block */
#define NIDS_PER_BLOCK

#define ADDRS_PER_PAGE(page, inode)

#define NODE_DIR1_BLOCK
#define NODE_DIR2_BLOCK
#define NODE_IND1_BLOCK
#define NODE_IND2_BLOCK
#define NODE_DIND_BLOCK

#define F2FS_INLINE_XATTR
#define F2FS_INLINE_DATA
#define F2FS_INLINE_DENTRY
#define F2FS_DATA_EXIST
#define F2FS_INLINE_DOTS
#define F2FS_EXTRA_ATTR
#define F2FS_PIN_FILE
#define F2FS_COMPRESS_RELEASED

struct f2fs_inode {} __packed;

struct direct_node {} __packed;

struct indirect_node {} __packed;

enum {};

#define OFFSET_BIT_MASK

struct f2fs_node {} __packed;

/*
 * For NAT entries
 */
#define NAT_ENTRY_PER_BLOCK

struct f2fs_nat_entry {} __packed;

struct f2fs_nat_block {} __packed;

/*
 * For SIT entries
 *
 * A validity bitmap of 64 bytes covers 512 blocks of area. For a 4K page size,
 * this results in a segment size of 2MB. For 16k pages, the default segment size
 * is 8MB.
 * Not allow to change this.
 */
#define SIT_VBLOCK_MAP_SIZE
#define SIT_ENTRY_PER_BLOCK

/*
 * F2FS uses 4 bytes to represent block address. As a result, supported size of
 * disk is 16 TB for a 4K page size and 64 TB for a 16K page size and it equals
 * to 16 * 1024 * 1024 / 2 segments.
 */
#define F2FS_MAX_SEGMENT

/*
 * Note that f2fs_sit_entry->vblocks has the following bit-field information.
 * [15:10] : allocation type such as CURSEG_XXXX_TYPE
 * [9:0] : valid block count
 */
#define SIT_VBLOCKS_SHIFT
#define SIT_VBLOCKS_MASK
#define GET_SIT_VBLOCKS(raw_sit)
#define GET_SIT_TYPE(raw_sit)

struct f2fs_sit_entry {} __packed;

struct f2fs_sit_block {} __packed;

/*
 * For segment summary
 *
 * One summary block with 4KB size contains exactly 512 summary entries, which
 * represents exactly one segment with 2MB size.
 * Similarly, in the case of block with 16KB size, it represents one segment with 8MB size.
 * Not allow to change the basic units.
 *
 * NOTE: For initializing fields, you must use set_summary
 *
 * - If data page, nid represents dnode's nid
 * - If node page, nid represents the node page's nid.
 *
 * The ofs_in_node is used by only data page. It represents offset
 * from node's page's beginning to get a data block address.
 * ex) data_blkaddr = (block_t)(nodepage_start_address + ofs_in_node)
 */
#define ENTRIES_IN_SUM
#define SUMMARY_SIZE
#define SUM_FOOTER_SIZE
#define SUM_ENTRY_SIZE

/* a summary entry for a block in a segment */
struct f2fs_summary {} __packed;

/* summary block type, node or data, is stored to the summary_footer */
#define SUM_TYPE_NODE
#define SUM_TYPE_DATA

struct summary_footer {} __packed;

#define SUM_JOURNAL_SIZE
#define NAT_JOURNAL_ENTRIES
#define NAT_JOURNAL_RESERVED
#define SIT_JOURNAL_ENTRIES
#define SIT_JOURNAL_RESERVED

/* Reserved area should make size of f2fs_extra_info equals to
 * that of nat_journal and sit_journal.
 */
#define EXTRA_INFO_RESERVED

/*
 * frequently updated NAT/SIT entries can be stored in the spare area in
 * summary blocks
 */
enum {};

struct nat_journal_entry {} __packed;

struct nat_journal {} __packed;

struct sit_journal_entry {} __packed;

struct sit_journal {} __packed;

struct f2fs_extra_info {} __packed;

struct f2fs_journal {} __packed;

/* Block-sized summary block structure */
struct f2fs_summary_block {} __packed;

/*
 * For directory operations
 */
#define F2FS_DOT_HASH
#define F2FS_DDOT_HASH
#define F2FS_MAX_HASH
#define F2FS_HASH_COL_BIT

f2fs_hash_t;

/* One directory entry slot covers 8bytes-long file name */
#define F2FS_SLOT_LEN
#define F2FS_SLOT_LEN_BITS

#define GET_DENTRY_SLOTS(x)

/* MAX level for dir lookup */
#define MAX_DIR_HASH_DEPTH

/* MAX buckets in one level of dir */
#define MAX_DIR_BUCKETS

/*
 * space utilization of regular dentry and inline dentry (w/o extra reservation)
 * when block size is 4KB.
 *		regular dentry		inline dentry (def)	inline dentry (min)
 * bitmap	1 * 27 = 27		1 * 23 = 23		1 * 1 = 1
 * reserved	1 * 3 = 3		1 * 7 = 7		1 * 1 = 1
 * dentry	11 * 214 = 2354		11 * 182 = 2002		11 * 2 = 22
 * filename	8 * 214 = 1712		8 * 182 = 1456		8 * 2 = 16
 * total	4096			3488			40
 *
 * Note: there are more reserved space in inline dentry than in regular
 * dentry, when converting inline dentry we should handle this carefully.
 */

/* the number of dentry in a block */
#define NR_DENTRY_IN_BLOCK
#define SIZE_OF_DIR_ENTRY
#define SIZE_OF_DENTRY_BITMAP
#define SIZE_OF_RESERVED
#define MIN_INLINE_DENTRY_SIZE

/* One directory entry slot representing F2FS_SLOT_LEN-sized file name */
struct f2fs_dir_entry {} __packed;

/* Block-sized directory entry block */
struct f2fs_dentry_block {} __packed;

#define F2FS_DEF_PROJID

#endif  /* _LINUX_F2FS_FS_H */