mirror of https://github.com/OpenIPC/firmware.git
216 lines
8.0 KiB
Diff
216 lines
8.0 KiB
Diff
diff -drupN a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
|
|
--- a/include/linux/f2fs_fs.h 2018-08-06 17:23:04.000000000 +0300
|
|
+++ b/include/linux/f2fs_fs.h 2022-06-12 05:28:14.000000000 +0300
|
|
@@ -21,6 +21,7 @@
|
|
#define F2FS_BLKSIZE 4096 /* support only 4KB block */
|
|
#define F2FS_BLKSIZE_BITS 12 /* bits for F2FS_BLKSIZE */
|
|
#define F2FS_MAX_EXTENSION 64 /* # of extension entries */
|
|
+#define F2FS_EXTENSION_LEN 8 /* max size of extension */
|
|
#define F2FS_BLK_ALIGN(x) (((x) + F2FS_BLKSIZE - 1) >> F2FS_BLKSIZE_BITS)
|
|
|
|
#define NULL_ADDR ((block_t)0) /* used as block_t addresses */
|
|
@@ -32,13 +33,20 @@
|
|
/* 0, 1(node nid), 2(meta nid) are reserved node id */
|
|
#define F2FS_RESERVED_NODE_NUM 3
|
|
|
|
-#define F2FS_ROOT_INO(sbi) (sbi->root_ino_num)
|
|
-#define F2FS_NODE_INO(sbi) (sbi->node_ino_num)
|
|
-#define F2FS_META_INO(sbi) (sbi->meta_ino_num)
|
|
+#define F2FS_ROOT_INO(sbi) ((sbi)->root_ino_num)
|
|
+#define F2FS_NODE_INO(sbi) ((sbi)->node_ino_num)
|
|
+#define F2FS_META_INO(sbi) ((sbi)->meta_ino_num)
|
|
+
|
|
+#define F2FS_MAX_QUOTAS 3
|
|
+
|
|
+#define F2FS_IO_SIZE(sbi) (1 << F2FS_OPTION(sbi).write_io_size_bits) /* Blocks */
|
|
+#define F2FS_IO_SIZE_KB(sbi) (1 << (F2FS_OPTION(sbi).write_io_size_bits + 2)) /* KB */
|
|
+#define F2FS_IO_SIZE_BYTES(sbi) (1 << (F2FS_OPTION(sbi).write_io_size_bits + 12)) /* B */
|
|
+#define F2FS_IO_SIZE_BITS(sbi) (F2FS_OPTION(sbi).write_io_size_bits) /* power of 2 */
|
|
+#define F2FS_IO_SIZE_MASK(sbi) (F2FS_IO_SIZE(sbi) - 1)
|
|
|
|
/* This flag is used by node and meta inodes, and by recovery */
|
|
#define GFP_F2FS_ZERO (GFP_NOFS | __GFP_ZERO)
|
|
-#define GFP_F2FS_HIGH_ZERO (GFP_NOFS | __GFP_ZERO | __GFP_HIGHMEM)
|
|
|
|
/*
|
|
* For further optimization on multi-head logs, on-disk layout supports maximum
|
|
@@ -52,10 +60,17 @@
|
|
|
|
#define VERSION_LEN 256
|
|
#define MAX_VOLUME_NAME 512
|
|
+#define MAX_PATH_LEN 64
|
|
+#define MAX_DEVICES 8
|
|
|
|
/*
|
|
* For superblock
|
|
*/
|
|
+struct f2fs_device {
|
|
+ __u8 path[MAX_PATH_LEN];
|
|
+ __le32 total_segments;
|
|
+} __packed;
|
|
+
|
|
struct f2fs_super_block {
|
|
__le32 magic; /* Magic Number */
|
|
__le16 major_ver; /* Major Version */
|
|
@@ -87,19 +102,26 @@ struct f2fs_super_block {
|
|
__u8 uuid[16]; /* 128-bit uuid for volume */
|
|
__le16 volume_name[MAX_VOLUME_NAME]; /* volume name */
|
|
__le32 extension_count; /* # of extensions below */
|
|
- __u8 extension_list[F2FS_MAX_EXTENSION][8]; /* extension array */
|
|
+ __u8 extension_list[F2FS_MAX_EXTENSION][F2FS_EXTENSION_LEN];/* extension array */
|
|
__le32 cp_payload;
|
|
__u8 version[VERSION_LEN]; /* the kernel version */
|
|
__u8 init_version[VERSION_LEN]; /* the initial kernel version */
|
|
__le32 feature; /* defined features */
|
|
__u8 encryption_level; /* versioning level for encryption */
|
|
__u8 encrypt_pw_salt[16]; /* Salt used for string2key algorithm */
|
|
- __u8 reserved[871]; /* valid reserved region */
|
|
+ struct f2fs_device devs[MAX_DEVICES]; /* device list */
|
|
+ __le32 qf_ino[F2FS_MAX_QUOTAS]; /* quota inode numbers */
|
|
+ __u8 hot_ext_count; /* # of hot file extension */
|
|
+ __u8 reserved[314]; /* valid reserved region */
|
|
} __packed;
|
|
|
|
/*
|
|
* For checkpoint
|
|
*/
|
|
+#define CP_LARGE_NAT_BITMAP_FLAG 0x00000400
|
|
+#define CP_NOCRC_RECOVERY_FLAG 0x00000200
|
|
+#define CP_TRIMMED_FLAG 0x00000100
|
|
+#define CP_NAT_BITS_FLAG 0x00000080
|
|
#define CP_CRC_RECOVERY_FLAG 0x00000040
|
|
#define CP_FASTBOOT_FLAG 0x00000020
|
|
#define CP_FSCK_FLAG 0x00000010
|
|
@@ -146,7 +168,7 @@ struct f2fs_checkpoint {
|
|
*/
|
|
#define F2FS_ORPHANS_PER_BLOCK 1020
|
|
|
|
-#define GET_ORPHAN_BLOCKS(n) ((n + F2FS_ORPHANS_PER_BLOCK - 1) / \
|
|
+#define GET_ORPHAN_BLOCKS(n) (((n) + F2FS_ORPHANS_PER_BLOCK - 1) / \
|
|
F2FS_ORPHANS_PER_BLOCK)
|
|
|
|
struct f2fs_orphan_block {
|
|
@@ -168,8 +190,11 @@ struct f2fs_extent {
|
|
} __packed;
|
|
|
|
#define F2FS_NAME_LEN 255
|
|
-#define F2FS_INLINE_XATTR_ADDRS 50 /* 200 bytes for inline xattrs */
|
|
+/* 200 bytes for inline xattrs by default */
|
|
+#define DEFAULT_INLINE_XATTR_ADDRS 50
|
|
#define DEF_ADDRS_PER_INODE 923 /* Address Pointers in an Inode */
|
|
+#define CUR_ADDRS_PER_INODE(inode) (DEF_ADDRS_PER_INODE - \
|
|
+ get_extra_isize(inode))
|
|
#define DEF_NIDS_PER_INODE 5 /* Node IDs in an Inode */
|
|
#define ADDRS_PER_INODE(inode) addrs_per_inode(inode)
|
|
#define ADDRS_PER_BLOCK 1018 /* Address Pointers in a Direct Block */
|
|
@@ -189,9 +214,8 @@ struct f2fs_extent {
|
|
#define F2FS_INLINE_DENTRY 0x04 /* file inline dentry flag */
|
|
#define F2FS_DATA_EXIST 0x08 /* file inline data exist flag */
|
|
#define F2FS_INLINE_DOTS 0x10 /* file having implicit dot dentries */
|
|
-
|
|
-#define MAX_INLINE_DATA (sizeof(__le32) * (DEF_ADDRS_PER_INODE - \
|
|
- F2FS_INLINE_XATTR_ADDRS - 1))
|
|
+#define F2FS_EXTRA_ATTR 0x20 /* file having extra attribute */
|
|
+#define F2FS_PIN_FILE 0x40 /* file should not be gced */
|
|
|
|
struct f2fs_inode {
|
|
__le16 i_mode; /* file mode */
|
|
@@ -209,7 +233,13 @@ struct f2fs_inode {
|
|
__le32 i_ctime_nsec; /* change time in nano scale */
|
|
__le32 i_mtime_nsec; /* modification time in nano scale */
|
|
__le32 i_generation; /* file version (for NFS) */
|
|
- __le32 i_current_depth; /* only for directory depth */
|
|
+ union {
|
|
+ __le32 i_current_depth; /* only for directory depth */
|
|
+ __le16 i_gc_failures; /*
|
|
+ * # of gc failures on pinned file.
|
|
+ * only for regular files.
|
|
+ */
|
|
+ };
|
|
__le32 i_xattr_nid; /* nid to save xattr */
|
|
__le32 i_flags; /* file attributes */
|
|
__le32 i_pino; /* parent inode number */
|
|
@@ -219,8 +249,18 @@ struct f2fs_inode {
|
|
|
|
struct f2fs_extent i_ext; /* caching a largest extent */
|
|
|
|
- __le32 i_addr[DEF_ADDRS_PER_INODE]; /* Pointers to data blocks */
|
|
-
|
|
+ union {
|
|
+ struct {
|
|
+ __le16 i_extra_isize; /* extra inode attribute size */
|
|
+ __le16 i_inline_xattr_size; /* inline xattr size, unit: 4 bytes */
|
|
+ __le32 i_projid; /* project id */
|
|
+ __le32 i_inode_checksum;/* inode meta checksum */
|
|
+ __le64 i_crtime; /* creation time */
|
|
+ __le32 i_crtime_nsec; /* creation time in nano scale */
|
|
+ __le32 i_extra_end[0]; /* for attribute size calculation */
|
|
+ } __packed;
|
|
+ __le32 i_addr[DEF_ADDRS_PER_INODE]; /* Pointers to data blocks */
|
|
+ };
|
|
__le32 i_nid[DEF_NIDS_PER_INODE]; /* direct(2), indirect(2),
|
|
double_indirect(1) node id */
|
|
} __packed;
|
|
@@ -264,6 +304,11 @@ struct f2fs_node {
|
|
* For NAT entries
|
|
*/
|
|
#define NAT_ENTRY_PER_BLOCK (PAGE_SIZE / sizeof(struct f2fs_nat_entry))
|
|
+#define NAT_ENTRY_BITMAP_SIZE ((NAT_ENTRY_PER_BLOCK + 7) / 8)
|
|
+#define NAT_ENTRY_BITMAP_SIZE_ALIGNED \
|
|
+ ((NAT_ENTRY_BITMAP_SIZE + BITS_PER_LONG - 1) / \
|
|
+ BITS_PER_LONG * BITS_PER_LONG)
|
|
+
|
|
|
|
struct f2fs_nat_entry {
|
|
__u8 version; /* latest version of cached nat entry */
|
|
@@ -439,7 +484,7 @@ typedef __le32 f2fs_hash_t;
|
|
#define F2FS_SLOT_LEN 8
|
|
#define F2FS_SLOT_LEN_BITS 3
|
|
|
|
-#define GET_DENTRY_SLOTS(x) ((x + F2FS_SLOT_LEN - 1) >> F2FS_SLOT_LEN_BITS)
|
|
+#define GET_DENTRY_SLOTS(x) (((x) + F2FS_SLOT_LEN - 1) >> F2FS_SLOT_LEN_BITS)
|
|
|
|
/* MAX level for dir lookup */
|
|
#define MAX_DIR_HASH_DEPTH 63
|
|
@@ -448,7 +493,7 @@ typedef __le32 f2fs_hash_t;
|
|
#define MAX_DIR_BUCKETS (1 << ((MAX_DIR_HASH_DEPTH / 2) - 1))
|
|
|
|
/*
|
|
- * space utilization of regular dentry and inline dentry
|
|
+ * space utilization of regular dentry and inline dentry (w/o extra reservation)
|
|
* regular dentry inline dentry
|
|
* bitmap 1 * 27 = 27 1 * 23 = 23
|
|
* reserved 1 * 3 = 3 1 * 7 = 7
|
|
@@ -484,24 +529,6 @@ struct f2fs_dentry_block {
|
|
__u8 filename[NR_DENTRY_IN_BLOCK][F2FS_SLOT_LEN];
|
|
} __packed;
|
|
|
|
-/* for inline dir */
|
|
-#define NR_INLINE_DENTRY (MAX_INLINE_DATA * BITS_PER_BYTE / \
|
|
- ((SIZE_OF_DIR_ENTRY + F2FS_SLOT_LEN) * \
|
|
- BITS_PER_BYTE + 1))
|
|
-#define INLINE_DENTRY_BITMAP_SIZE ((NR_INLINE_DENTRY + \
|
|
- BITS_PER_BYTE - 1) / BITS_PER_BYTE)
|
|
-#define INLINE_RESERVED_SIZE (MAX_INLINE_DATA - \
|
|
- ((SIZE_OF_DIR_ENTRY + F2FS_SLOT_LEN) * \
|
|
- NR_INLINE_DENTRY + INLINE_DENTRY_BITMAP_SIZE))
|
|
-
|
|
-/* inline directory entry structure */
|
|
-struct f2fs_inline_dentry {
|
|
- __u8 dentry_bitmap[INLINE_DENTRY_BITMAP_SIZE];
|
|
- __u8 reserved[INLINE_RESERVED_SIZE];
|
|
- struct f2fs_dir_entry dentry[NR_INLINE_DENTRY];
|
|
- __u8 filename[NR_INLINE_DENTRY][F2FS_SLOT_LEN];
|
|
-} __packed;
|
|
-
|
|
/* file types used in inode_info->flags */
|
|
enum {
|
|
F2FS_FT_UNKNOWN,
|
|
@@ -517,4 +544,6 @@ enum {
|
|
|
|
#define S_SHIFT 12
|
|
|
|
+#define F2FS_DEF_PROJID 0 /* default project ID */
|
|
+
|
|
#endif /* _LINUX_F2FS_FS_H */
|