Blame view
include/linux/f2fs_fs.h
16.7 KB
dd31866b0 f2fs: add on-disk... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
/** * include/linux/f2fs_fs.h * * Copyright (c) 2012 Samsung Electronics Co., Ltd. * http://www.samsung.com/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #ifndef _LINUX_F2FS_FS_H #define _LINUX_F2FS_FS_H #include <linux/pagemap.h> #include <linux/types.h> #define F2FS_SUPER_OFFSET 1024 /* byte-size offset */ |
55cf9cb63 f2fs: support lar... |
18 19 20 |
#define F2FS_MIN_LOG_SECTOR_SIZE 9 /* 9 bits for 512 bytes */ #define F2FS_MAX_LOG_SECTOR_SIZE 12 /* 12 bits for 4096 bytes */ #define F2FS_LOG_SECTORS_PER_BLOCK 3 /* log number for sector/blk */ |
dd31866b0 f2fs: add on-disk... |
21 |
#define F2FS_BLKSIZE 4096 /* support only 4KB block */ |
f7ef9b83b f2fs: introduce m... |
22 |
#define F2FS_BLKSIZE_BITS 12 /* bits for F2FS_BLKSIZE */ |
dd31866b0 f2fs: add on-disk... |
23 |
#define F2FS_MAX_EXTENSION 64 /* # of extension entries */ |
24b849125 f2fs: preallocate... |
24 |
#define F2FS_BLK_ALIGN(x) (((x) + F2FS_BLKSIZE - 1) >> F2FS_BLKSIZE_BITS) |
dd31866b0 f2fs: add on-disk... |
25 |
|
a9841c4db f2fs: align data ... |
26 27 |
#define NULL_ADDR ((block_t)0) /* used as block_t addresses */ #define NEW_ADDR ((block_t)-1) /* used as block_t addresses */ |
dd31866b0 f2fs: add on-disk... |
28 |
|
f7ef9b83b f2fs: introduce m... |
29 30 |
#define F2FS_BYTES_TO_BLK(bytes) ((bytes) >> F2FS_BLKSIZE_BITS) #define F2FS_BLK_TO_BYTES(blk) ((blk) << F2FS_BLKSIZE_BITS) |
c200b1aa6 f2fs: fix incorre... |
31 32 |
/* 0, 1(node nid), 2(meta nid) are reserved node id */ #define F2FS_RESERVED_NODE_NUM 3 |
dd31866b0 f2fs: add on-disk... |
33 34 35 36 37 |
#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) /* This flag is used by node and meta inodes, and by recovery */ |
a78186ebe f2fs: use highmem... |
38 39 |
#define GFP_F2FS_ZERO (GFP_NOFS | __GFP_ZERO) #define GFP_F2FS_HIGH_ZERO (GFP_NOFS | __GFP_ZERO | __GFP_HIGHMEM) |
dd31866b0 f2fs: add on-disk... |
40 41 42 43 44 45 46 47 48 49 |
/* * 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 16 #define MAX_ACTIVE_NODE_LOGS 8 #define MAX_ACTIVE_DATA_LOGS 8 |
0040b9331 f2fs: add missing... |
50 |
#define VERSION_LEN 256 |
a11fac377 f2fs: add symbol ... |
51 |
#define MAX_VOLUME_NAME 512 |
0040b9331 f2fs: add missing... |
52 |
|
dd31866b0 f2fs: add on-disk... |
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
/* * For superblock */ struct f2fs_super_block { __le32 magic; /* Magic Number */ __le16 major_ver; /* Major Version */ __le16 minor_ver; /* Minor Version */ __le32 log_sectorsize; /* log2 sector size in bytes */ __le32 log_sectors_per_block; /* log2 # of sectors per block */ __le32 log_blocksize; /* log2 block size in bytes */ __le32 log_blocks_per_seg; /* log2 # of blocks per segment */ __le32 segs_per_sec; /* # of segments per section */ __le32 secs_per_zone; /* # of sections per zone */ __le32 checksum_offset; /* checksum offset inside super block */ __le64 block_count; /* total # of user blocks */ __le32 section_count; /* total # of sections */ __le32 segment_count; /* total # of segments */ __le32 segment_count_ckpt; /* # of segments for checkpoint */ __le32 segment_count_sit; /* # of segments for SIT */ __le32 segment_count_nat; /* # of segments for NAT */ __le32 segment_count_ssa; /* # of segments for SSA */ __le32 segment_count_main; /* # of segments for main area */ __le32 segment0_blkaddr; /* start block address of segment 0 */ __le32 cp_blkaddr; /* start block address of checkpoint */ __le32 sit_blkaddr; /* start block address of SIT */ __le32 nat_blkaddr; /* start block address of NAT */ __le32 ssa_blkaddr; /* start block address of SSA */ __le32 main_blkaddr; /* start block address of main area */ __le32 root_ino; /* root inode number */ __le32 node_ino; /* node inode number */ __le32 meta_ino; /* meta inode number */ __u8 uuid[16]; /* 128-bit uuid for volume */ |
a11fac377 f2fs: add symbol ... |
85 |
__le16 volume_name[MAX_VOLUME_NAME]; /* volume name */ |
dd31866b0 f2fs: add on-disk... |
86 87 |
__le32 extension_count; /* # of extensions below */ __u8 extension_list[F2FS_MAX_EXTENSION][8]; /* extension array */ |
1dbe41521 f2fs: large volum... |
88 |
__le32 cp_payload; |
0040b9331 f2fs: add missing... |
89 90 |
__u8 version[VERSION_LEN]; /* the kernel version */ __u8 init_version[VERSION_LEN]; /* the initial kernel version */ |
76f105a2d f2fs: add feature... |
91 |
__le32 feature; /* defined features */ |
cde4de120 f2fs crypto: decl... |
92 93 94 |
__u8 encryption_level; /* versioning level for encryption */ __u8 encrypt_pw_salt[16]; /* Salt used for string2key algorithm */ __u8 reserved[871]; /* valid reserved region */ |
dd31866b0 f2fs: add on-disk... |
95 96 97 98 99 |
} __packed; /* * For checkpoint */ |
a468f0ef5 f2fs: use crc and... |
100 |
#define CP_CRC_RECOVERY_FLAG 0x00000040 |
119ee9144 f2fs: split UMOUN... |
101 |
#define CP_FASTBOOT_FLAG 0x00000020 |
2ae4c673e f2fs: retain inco... |
102 |
#define CP_FSCK_FLAG 0x00000010 |
dd31866b0 f2fs: add on-disk... |
103 104 105 106 |
#define CP_ERROR_FLAG 0x00000008 #define CP_COMPACT_SUM_FLAG 0x00000004 #define CP_ORPHAN_PRESENT_FLAG 0x00000002 #define CP_UMOUNT_FLAG 0x00000001 |
b5b822050 f2fs: use macro f... |
107 |
#define F2FS_CP_PACKS 2 /* # of checkpoint packs */ |
dd31866b0 f2fs: add on-disk... |
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
struct f2fs_checkpoint { __le64 checkpoint_ver; /* checkpoint block version number */ __le64 user_block_count; /* # of user blocks */ __le64 valid_block_count; /* # of valid blocks in main area */ __le32 rsvd_segment_count; /* # of reserved segments for gc */ __le32 overprov_segment_count; /* # of overprovision segments */ __le32 free_segment_count; /* # of free segments in main area */ /* information of current node segments */ __le32 cur_node_segno[MAX_ACTIVE_NODE_LOGS]; __le16 cur_node_blkoff[MAX_ACTIVE_NODE_LOGS]; /* information of current data segments */ __le32 cur_data_segno[MAX_ACTIVE_DATA_LOGS]; __le16 cur_data_blkoff[MAX_ACTIVE_DATA_LOGS]; __le32 ckpt_flags; /* Flags : umount and journal_present */ __le32 cp_pack_total_block_count; /* total # of one cp pack */ __le32 cp_pack_start_sum; /* start block number of data summary */ __le32 valid_node_count; /* Total number of valid nodes */ __le32 valid_inode_count; /* Total number of valid inodes */ __le32 next_free_nid; /* Next free node number */ __le32 sit_ver_bitmap_bytesize; /* Default value 64 */ __le32 nat_ver_bitmap_bytesize; /* Default value 256 */ __le32 checksum_offset; /* checksum offset inside cp block */ __le64 elapsed_time; /* mounted time */ /* allocation type of current segment */ unsigned char alloc_type[MAX_ACTIVE_LOGS]; /* SIT and NAT version bitmap */ unsigned char sit_nat_version_bitmap[1]; } __packed; /* * For orphan inode management */ #define F2FS_ORPHANS_PER_BLOCK 1020 |
b5b822050 f2fs: use macro f... |
143 144 |
#define GET_ORPHAN_BLOCKS(n) ((n + F2FS_ORPHANS_PER_BLOCK - 1) / \ F2FS_ORPHANS_PER_BLOCK) |
dd31866b0 f2fs: add on-disk... |
145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
struct f2fs_orphan_block { __le32 ino[F2FS_ORPHANS_PER_BLOCK]; /* inode numbers */ __le32 reserved; /* reserved */ __le16 blk_addr; /* block index in current CP */ __le16 blk_count; /* Number of orphan inode blocks in CP */ __le32 entry_count; /* Total number of orphan nodes in current CP */ __le32 check_sum; /* CRC32 for orphan inode block */ } __packed; /* * For NODE structure */ struct f2fs_extent { __le32 fofs; /* start file offset of the extent */ |
4d0b0bd43 f2fs: simplfy a f... |
159 |
__le32 blk; /* start block address of the extent */ |
dd31866b0 f2fs: add on-disk... |
160 161 |
__le32 len; /* lengh of the extent */ } __packed; |
5a20d339c f2fs: align f2fs ... |
162 |
#define F2FS_NAME_LEN 255 |
65985d935 f2fs: support the... |
163 |
#define F2FS_INLINE_XATTR_ADDRS 50 /* 200 bytes for inline xattrs */ |
de93653fe f2fs: reserve the... |
164 |
#define DEF_ADDRS_PER_INODE 923 /* Address Pointers in an Inode */ |
b5b822050 f2fs: use macro f... |
165 |
#define DEF_NIDS_PER_INODE 5 /* Node IDs in an Inode */ |
81ca7350c f2fs: remove unne... |
166 |
#define ADDRS_PER_INODE(inode) addrs_per_inode(inode) |
de93653fe f2fs: reserve the... |
167 168 |
#define ADDRS_PER_BLOCK 1018 /* Address Pointers in a Direct Block */ #define NIDS_PER_BLOCK 1018 /* Node IDs in an Indirect Block */ |
81ca7350c f2fs: remove unne... |
169 170 |
#define ADDRS_PER_PAGE(page, inode) \ (IS_INODE(page) ? ADDRS_PER_INODE(inode) : ADDRS_PER_BLOCK) |
6403eb1f6 f2fs: introduce h... |
171 |
|
de93653fe f2fs: reserve the... |
172 173 174 175 176 |
#define NODE_DIR1_BLOCK (DEF_ADDRS_PER_INODE + 1) #define NODE_DIR2_BLOCK (DEF_ADDRS_PER_INODE + 2) #define NODE_IND1_BLOCK (DEF_ADDRS_PER_INODE + 3) #define NODE_IND2_BLOCK (DEF_ADDRS_PER_INODE + 4) #define NODE_DIND_BLOCK (DEF_ADDRS_PER_INODE + 5) |
dd31866b0 f2fs: add on-disk... |
177 |
|
444c580f7 f2fs: add flags f... |
178 |
#define F2FS_INLINE_XATTR 0x01 /* file inline xattr flag */ |
1001b3479 f2fs: add flags a... |
179 |
#define F2FS_INLINE_DATA 0x02 /* file inline data flag */ |
34d67debe f2fs: add infra s... |
180 |
#define F2FS_INLINE_DENTRY 0x04 /* file inline dentry flag */ |
b3d208f96 f2fs: revisit inl... |
181 |
#define F2FS_DATA_EXIST 0x08 /* file inline data exist flag */ |
510022a85 f2fs: add F2FS_IN... |
182 |
#define F2FS_INLINE_DOTS 0x10 /* file having implicit dot dentries */ |
1001b3479 f2fs: add flags a... |
183 |
|
1001b3479 f2fs: add flags a... |
184 185 |
#define MAX_INLINE_DATA (sizeof(__le32) * (DEF_ADDRS_PER_INODE - \ F2FS_INLINE_XATTR_ADDRS - 1)) |
dd31866b0 f2fs: add on-disk... |
186 187 188 |
struct f2fs_inode { __le16 i_mode; /* file mode */ __u8 i_advise; /* file hints */ |
444c580f7 f2fs: add flags f... |
189 |
__u8 i_inline; /* file inline flags */ |
dd31866b0 f2fs: add on-disk... |
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
__le32 i_uid; /* user ID */ __le32 i_gid; /* group ID */ __le32 i_links; /* links count */ __le64 i_size; /* file size in bytes */ __le64 i_blocks; /* file size in blocks */ __le64 i_atime; /* access time */ __le64 i_ctime; /* change time */ __le64 i_mtime; /* modification time */ __le32 i_atime_nsec; /* access time in nano scale */ __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 */ __le32 i_xattr_nid; /* nid to save xattr */ __le32 i_flags; /* file attributes */ __le32 i_pino; /* parent inode number */ __le32 i_namelen; /* file name length */ |
5a20d339c f2fs: align f2fs ... |
207 |
__u8 i_name[F2FS_NAME_LEN]; /* file name for SPOR */ |
384315459 f2fs: introduce l... |
208 |
__u8 i_dir_level; /* dentry_level for large dir */ |
dd31866b0 f2fs: add on-disk... |
209 210 |
struct f2fs_extent i_ext; /* caching a largest extent */ |
de93653fe f2fs: reserve the... |
211 |
__le32 i_addr[DEF_ADDRS_PER_INODE]; /* Pointers to data blocks */ |
dd31866b0 f2fs: add on-disk... |
212 |
|
b5b822050 f2fs: use macro f... |
213 |
__le32 i_nid[DEF_NIDS_PER_INODE]; /* direct(2), indirect(2), |
dd31866b0 f2fs: add on-disk... |
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
double_indirect(1) node id */ } __packed; struct direct_node { __le32 addr[ADDRS_PER_BLOCK]; /* array of data block address */ } __packed; struct indirect_node { __le32 nid[NIDS_PER_BLOCK]; /* array of data block address */ } __packed; enum { COLD_BIT_SHIFT = 0, FSYNC_BIT_SHIFT, DENT_BIT_SHIFT, OFFSET_BIT_SHIFT }; |
09eb483e8 f2fs: fix missing... |
231 |
#define OFFSET_BIT_MASK (0x07) /* (0x01 << OFFSET_BIT_SHIFT) - 1 */ |
dd31866b0 f2fs: add on-disk... |
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
struct node_footer { __le32 nid; /* node id */ __le32 ino; /* inode nunmber */ __le32 flag; /* include cold/fsync/dentry marks and offset */ __le64 cp_ver; /* checkpoint version */ __le32 next_blkaddr; /* next node page block address */ } __packed; struct f2fs_node { /* can be one of three types: inode, direct, and indirect types */ union { struct f2fs_inode i; struct direct_node dn; struct indirect_node in; }; struct node_footer footer; } __packed; /* * For NAT entries */ |
09cbfeaf1 mm, fs: get rid o... |
253 |
#define NAT_ENTRY_PER_BLOCK (PAGE_SIZE / sizeof(struct f2fs_nat_entry)) |
dd31866b0 f2fs: add on-disk... |
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
struct f2fs_nat_entry { __u8 version; /* latest version of cached nat entry */ __le32 ino; /* inode number */ __le32 block_addr; /* block address */ } __packed; struct f2fs_nat_block { struct f2fs_nat_entry entries[NAT_ENTRY_PER_BLOCK]; } __packed; /* * For SIT entries * * Each segment is 2MB in size by default so that a bitmap for validity of * there-in blocks should occupy 64 bytes, 512 bits. * Not allow to change this. */ #define SIT_VBLOCK_MAP_SIZE 64 |
09cbfeaf1 mm, fs: get rid o... |
273 |
#define SIT_ENTRY_PER_BLOCK (PAGE_SIZE / sizeof(struct f2fs_sit_entry)) |
dd31866b0 f2fs: add on-disk... |
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
/* * 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 10 #define SIT_VBLOCKS_MASK ((1 << SIT_VBLOCKS_SHIFT) - 1) #define GET_SIT_VBLOCKS(raw_sit) \ (le16_to_cpu((raw_sit)->vblocks) & SIT_VBLOCKS_MASK) #define GET_SIT_TYPE(raw_sit) \ ((le16_to_cpu((raw_sit)->vblocks) & ~SIT_VBLOCKS_MASK) \ >> SIT_VBLOCKS_SHIFT) struct f2fs_sit_entry { __le16 vblocks; /* reference above */ __u8 valid_map[SIT_VBLOCK_MAP_SIZE]; /* bitmap for valid blocks */ __le64 mtime; /* segment age for cleaning */ } __packed; struct f2fs_sit_block { struct f2fs_sit_entry entries[SIT_ENTRY_PER_BLOCK]; } __packed; /* * For segment summary * * One summary block contains exactly 512 summary entries, which represents * exactly 2MB segment by default. 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 512 |
25ca923b2 f2fs: fix endian ... |
314 315 |
#define SUMMARY_SIZE (7) /* sizeof(struct summary) */ #define SUM_FOOTER_SIZE (5) /* sizeof(struct summary_footer) */ |
dd31866b0 f2fs: add on-disk... |
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
#define SUM_ENTRY_SIZE (SUMMARY_SIZE * ENTRIES_IN_SUM) /* a summary entry for a 4KB-sized block in a segment */ struct f2fs_summary { __le32 nid; /* parent node id */ union { __u8 reserved[3]; struct { __u8 version; /* node version number */ __le16 ofs_in_node; /* block index in parent node */ } __packed; }; } __packed; /* summary block type, node or data, is stored to the summary_footer */ #define SUM_TYPE_NODE (1) #define SUM_TYPE_DATA (0) struct summary_footer { unsigned char entry_type; /* SUM_TYPE_XXX */ |
479c8bc40 f2fs: fix endiann... |
336 |
__le32 check_sum; /* summary checksum */ |
dd31866b0 f2fs: add on-disk... |
337 |
} __packed; |
25ca923b2 f2fs: fix endian ... |
338 |
#define SUM_JOURNAL_SIZE (F2FS_BLKSIZE - SUM_FOOTER_SIZE -\ |
dd31866b0 f2fs: add on-disk... |
339 340 341 342 343 344 345 346 347 |
SUM_ENTRY_SIZE) #define NAT_JOURNAL_ENTRIES ((SUM_JOURNAL_SIZE - 2) /\ sizeof(struct nat_journal_entry)) #define NAT_JOURNAL_RESERVED ((SUM_JOURNAL_SIZE - 2) %\ sizeof(struct nat_journal_entry)) #define SIT_JOURNAL_ENTRIES ((SUM_JOURNAL_SIZE - 2) /\ sizeof(struct sit_journal_entry)) #define SIT_JOURNAL_RESERVED ((SUM_JOURNAL_SIZE - 2) %\ sizeof(struct sit_journal_entry)) |
8f1dbbbbd f2fs: introduce l... |
348 349 350 351 352 |
/* Reserved area should make size of f2fs_extra_info equals to * that of nat_journal and sit_journal. */ #define EXTRA_INFO_RESERVED (SUM_JOURNAL_SIZE - 2 - 8) |
dd31866b0 f2fs: add on-disk... |
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
/* * frequently updated NAT/SIT entries can be stored in the spare area in * summary blocks */ enum { NAT_JOURNAL = 0, SIT_JOURNAL }; struct nat_journal_entry { __le32 nid; struct f2fs_nat_entry ne; } __packed; struct nat_journal { struct nat_journal_entry entries[NAT_JOURNAL_ENTRIES]; __u8 reserved[NAT_JOURNAL_RESERVED]; } __packed; struct sit_journal_entry { __le32 segno; struct f2fs_sit_entry se; } __packed; struct sit_journal { struct sit_journal_entry entries[SIT_JOURNAL_ENTRIES]; __u8 reserved[SIT_JOURNAL_RESERVED]; } __packed; |
8f1dbbbbd f2fs: introduce l... |
381 382 383 384 |
struct f2fs_extra_info { __le64 kbytes_written; __u8 reserved[EXTRA_INFO_RESERVED]; } __packed; |
dfc08a12e f2fs: introduce f... |
385 |
struct f2fs_journal { |
dd31866b0 f2fs: add on-disk... |
386 387 388 389 |
union { __le16 n_nats; __le16 n_sits; }; |
8f1dbbbbd f2fs: introduce l... |
390 |
/* spare area is used by NAT or SIT journals or extra info */ |
dd31866b0 f2fs: add on-disk... |
391 392 393 |
union { struct nat_journal nat_j; struct sit_journal sit_j; |
8f1dbbbbd f2fs: introduce l... |
394 |
struct f2fs_extra_info info; |
dd31866b0 f2fs: add on-disk... |
395 |
}; |
dfc08a12e f2fs: introduce f... |
396 397 398 399 400 401 |
} __packed; /* 4KB-sized summary block structure */ struct f2fs_summary_block { struct f2fs_summary entries[ENTRIES_IN_SUM]; struct f2fs_journal journal; |
dd31866b0 f2fs: add on-disk... |
402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
struct summary_footer footer; } __packed; /* * For directory operations */ #define F2FS_DOT_HASH 0 #define F2FS_DDOT_HASH F2FS_DOT_HASH #define F2FS_MAX_HASH (~((0x3ULL) << 62)) #define F2FS_HASH_COL_BIT ((0x1ULL) << 63) typedef __le32 f2fs_hash_t; /* One directory entry slot covers 8bytes-long file name */ |
5a20d339c f2fs: align f2fs ... |
416 417 |
#define F2FS_SLOT_LEN 8 #define F2FS_SLOT_LEN_BITS 3 |
457d08ee4 f2fs: introduce a... |
418 |
|
5a20d339c f2fs: align f2fs ... |
419 |
#define GET_DENTRY_SLOTS(x) ((x + F2FS_SLOT_LEN - 1) >> F2FS_SLOT_LEN_BITS) |
dd31866b0 f2fs: add on-disk... |
420 |
|
dd31866b0 f2fs: add on-disk... |
421 422 |
/* MAX level for dir lookup */ #define MAX_DIR_HASH_DEPTH 63 |
bfec07d0f f2fs: avoid overf... |
423 424 |
/* MAX buckets in one level of dir */ #define MAX_DIR_BUCKETS (1 << ((MAX_DIR_HASH_DEPTH / 2) - 1)) |
c031f6a90 f2fs: add annotat... |
425 426 427 428 429 430 431 432 433 434 435 436 437 |
/* * space utilization of regular dentry and inline dentry * regular dentry inline dentry * bitmap 1 * 27 = 27 1 * 23 = 23 * reserved 1 * 3 = 3 1 * 7 = 7 * dentry 11 * 214 = 2354 11 * 182 = 2002 * filename 8 * 214 = 1712 8 * 182 = 1456 * total 4096 3488 * * Note: there are more reserved space in inline dentry than in regular * dentry, when converting inline dentry we should handle this carefully. */ #define NR_DENTRY_IN_BLOCK 214 /* the number of dentry in a block */ |
dd31866b0 f2fs: add on-disk... |
438 439 440 441 |
#define SIZE_OF_DIR_ENTRY 11 /* by byte */ #define SIZE_OF_DENTRY_BITMAP ((NR_DENTRY_IN_BLOCK + BITS_PER_BYTE - 1) / \ BITS_PER_BYTE) #define SIZE_OF_RESERVED (PAGE_SIZE - ((SIZE_OF_DIR_ENTRY + \ |
5a20d339c f2fs: align f2fs ... |
442 |
F2FS_SLOT_LEN) * \ |
dd31866b0 f2fs: add on-disk... |
443 |
NR_DENTRY_IN_BLOCK + SIZE_OF_DENTRY_BITMAP)) |
5a20d339c f2fs: align f2fs ... |
444 |
/* One directory entry slot representing F2FS_SLOT_LEN-sized file name */ |
dd31866b0 f2fs: add on-disk... |
445 446 447 448 449 450 451 452 453 454 455 456 457 |
struct f2fs_dir_entry { __le32 hash_code; /* hash code of file name */ __le32 ino; /* inode number */ __le16 name_len; /* lengh of file name */ __u8 file_type; /* file type */ } __packed; /* 4KB-sized directory entry block */ struct f2fs_dentry_block { /* validity bitmap for directory entries in each block */ __u8 dentry_bitmap[SIZE_OF_DENTRY_BITMAP]; __u8 reserved[SIZE_OF_RESERVED]; struct f2fs_dir_entry dentry[NR_DENTRY_IN_BLOCK]; |
5a20d339c f2fs: align f2fs ... |
458 |
__u8 filename[NR_DENTRY_IN_BLOCK][F2FS_SLOT_LEN]; |
dd31866b0 f2fs: add on-disk... |
459 |
} __packed; |
34d67debe f2fs: add infra s... |
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 |
/* 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; |
dd31866b0 f2fs: add on-disk... |
477 478 479 480 481 482 483 484 485 486 487 488 |
/* file types used in inode_info->flags */ enum { F2FS_FT_UNKNOWN, F2FS_FT_REG_FILE, F2FS_FT_DIR, F2FS_FT_CHRDEV, F2FS_FT_BLKDEV, F2FS_FT_FIFO, F2FS_FT_SOCK, F2FS_FT_SYMLINK, F2FS_FT_MAX }; |
675f10bde f2fs: fix to conv... |
489 |
#define S_SHIFT 12 |
dd31866b0 f2fs: add on-disk... |
490 |
#endif /* _LINUX_F2FS_FS_H */ |