android_kernel_oneplus_msm8998/include/linux/f2fs_fs.h

550 lines
18 KiB
C
Raw Permalink Normal View History

/**
* 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 */
#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 */
#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 */
f2fs/fscrypt: updates to v4.17-rc1 Pull f2fs update from Jaegeuk Kim: "In this round, we've mainly focused on performance tuning and critical bug fixes occurred in low-end devices. Sheng Yong introduced lost_found feature to keep missing files during recovery instead of thrashing them. We're preparing coming fsverity implementation. And, we've got more features to communicate with users for better performance. In low-end devices, some memory-related issues were fixed, and subtle race condtions and corner cases were addressed as well. Enhancements: - large nat bitmaps for more free node ids - add three block allocation policies to pass down write hints given by user - expose extension list to user and introduce hot file extension - tune small devices seamlessly for low-end devices - set readdir_ra by default - give more resources under gc_urgent mode regarding to discard and cleaning - introduce fsync_mode to enforce posix or not - nowait aio support - add lost_found feature to keep dangling inodes - reserve bits for future fsverity feature - add test_dummy_encryption for FBE Bug fixes: - don't use highmem for dentry pages - align memory boundary for bitops - truncate preallocated blocks in write errors - guarantee i_times on fsync call - clear CP_TRIMMED_FLAG correctly - prevent node chain loop during recovery - avoid data race between atomic write and background cleaning - avoid unnecessary selinux violation warnings on resgid option - GFP_NOFS to avoid deadlock in quota and read paths - fix f2fs_skip_inode_update to allow i_size recovery In addition to the above, there are several minor bug fixes and clean-ups" Cherry-pick from origin/upstream-f2fs-stable-linux-4.4.y: 42bf67fc543b f2fs: remain written times to update inode during fsync 6cb5aa02bfbd f2fs: make assignment of t->dentry_bitmap more readable a8d07f1f9c62 f2fs: truncate preallocated blocks in error case 86444d600692 f2fs: fix a wrong condition in f2fs_skip_inode_update db2188a68704 f2fs: reserve bits for fs-verity ee2e74b3f00e f2fs: Add a segment type check in inplace write 0192e0a4502f f2fs: no need to initialize zero value for GFP_F2FS_ZERO 49338842e9b2 f2fs: don't track new nat entry in nat set d6a69d5e6568 f2fs: clean up with F2FS_BLK_ALIGN 2c8834a7a2c9 f2fs: check blkaddr more accuratly before issue a bio 6ab573a9d96f f2fs: Set GF_NOFS in read_cache_page_gfp while doing f2fs_quota_read 7419dcb8be02 f2fs: introduce a new mount option test_dummy_encryption 9321e22c038c f2fs: introduce F2FS_FEATURE_LOST_FOUND feature 8a5719615847 f2fs: release locks before return in f2fs_ioc_gc_range() 739ace131cdf f2fs: align memory boundary for bitops 4c55abe4f8d2 f2fs: remove unneeded set_cold_node() 30654507e0a2 f2fs: add nowait aio support d909e9410634 f2fs: wrap all options with f2fs_sb_info.mount_opt 5738be52b3e8 f2fs: Don't overwrite all types of node to keep node chain 0bdeb167c843 f2fs: introduce mount option for fsync mode 6bc490f0eedc f2fs: fix to restore old mount option in ->remount_fs 0c9c3e034410 f2fs: wrap sb_rdonly with f2fs_readonly 6c6611223a79 f2fs: avoid selinux denial on CAP_SYS_RESOURCE 076a6f32fe5d f2fs: support hot file extension 58edcdbca67a f2fs: fix to avoid race in between atomic write and background GC 1e0aeb0af9ed f2fs: do gc in greedy mode for whole range if gc_urgent mode is set 10b2d001d6ac f2fs: issue discard aggressively in the gc_urgent mode a5052f32b940 f2fs: set readdir_ra by default 1aa536a624cc f2fs: add auto tuning for small devices 0ffdffc8f106 f2fs: add mount option for segment allocation policy b79829891249 f2fs: don't stop GC if GC is contended 766d2321697f f2fs: expose extension_list sysfs entry 98b329de5026 f2fs: fix to set KEEP_SIZE bit in f2fs_zero_range 4d409fa3346b f2fs: introduce sb_lock to make encrypt pwsalt update exclusive 1f6bac14c100 f2fs: remove redundant initialization of pointer 'p' 946aefc7545d f2fs: flush cp pack except cp pack 2 page at first e5081a52ac09 f2fs: clean up f2fs_sb_has_xxx functions a292477154b5 f2fs: remove redundant check of page type when submit bio 190e64a819df f2fs: fix to handle looped node chain during recovery 889d98087652 f2fs: handle quota for orphan inodes 92b12bb1a23e f2fs: support passing down write hints to block layer with F2FS policy 22fa74c2b097 f2fs: support passing down write hints given by users to block layer 180900373ec1 f2fs: fix to clear CP_TRIMMED_FLAG 0671fae134bb f2fs: support large nat bitmap eceb943d5d59 f2fs: fix to check extent cache in f2fs_drop_extent_tree 2e2a339c9853 f2fs: restrict inline_xattr_size configuration 41dda1164137 f2fs: fix heap mode to reset it back 39575737bb62 f2fs: fix potential corruption in area before F2FS_SUPER_OFFSET 7e0e7995ee97 fscrypt: fix build with pre-4.6 gcc versions 31d3279a4fca fscrypt: fix up fscrypt_fname_encrypted_size() for internal use 82bec888567b fscrypt: define fscrypt_fname_alloc_buffer() to be for presented names 168a90782888 fscrypt: calculate NUL-padding length in one place only 042ae9f4cfbf fscrypt: move fscrypt_symlink_data to fscrypt_private.h f9550c24c20e fscrypt: remove fscrypt_fname_usr_to_disk() 7ac4756a2474 f2fs: switch to fscrypt_get_symlink() 6b76f58e24bd f2fs: switch to fscrypt ->symlink() helper functions fd457d2c4e04 fscrypt: new helper function - fscrypt_get_symlink() a1cdacb7ae0d fscrypt: new helper functions for ->symlink() 7f43602f4d10 fscrypt: trim down fscrypt.h includes d9cadc11bdcf fscrypt: move fscrypt_is_dot_dotdot() to fs/crypto/fname.c e6fe930580cb fscrypt: move fscrypt_valid_enc_modes() to fscrypt_private.h efefa434f47e fscrypt: move fscrypt_operations declaration to fscrypt_supp.h 7ed178bc8ae9 fscrypt: split fscrypt_dummy_context_enabled() into supp/notsupp versions 3f16e09dadfb fscrypt: move fscrypt_ctx declaration to fscrypt_supp.h 8216a0b51a3b fscrypt: move fscrypt_info_cachep declaration to fscrypt_private.h dfe0b3b1b67f fscrypt: move fscrypt_control_page() to supp/notsupp headers 3a2c79177822 fscrypt: move fscrypt_has_encryption_key() to supp/notsupp headers Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-01-05 10:44:52 -08:00
#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 */
#define NEW_ADDR ((block_t)-1) /* used as block_t addresses */
#define F2FS_BYTES_TO_BLK(bytes) ((bytes) >> F2FS_BLKSIZE_BITS)
#define F2FS_BLK_TO_BYTES(blk) ((blk) << F2FS_BLKSIZE_BITS)
/* 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)
f2fs: updates on 4.15-rc1 Pull f2fs updates from Jaegeuk Kim: "In this round, we introduce sysfile-based quota support which is required for Android by default. In addition, we allow that users are able to reserve some blocks in runtime to mitigate performance drops in low free space. Enhancements: - assign proper data segments according to write_hints given by user - issue cache_flush on dirty devices only among multiple devices - exploit cp_error flag and add more faults to enhance fault injection test - conduct more readaheads during f2fs_readdir - add a range for discard commands Bug fixes: - fix zero stat->st_blocks when inline_data is set - drop crypto key and free stale memory pointer while evict_inode is failing - fix some corner cases in free space and segment management - fix wrong last_disk_size This series includes lots of clean-ups and code enhancement in terms of xattr operations, discard/flush command control. In addition, it adds versatile debugfs entries to monitor f2fs status" Cherry-picked from origin/upstream-f2fs-stable-linux-4.4.y: 56a07b070510 f2fs: deny accessing encryption policy if encryption is off c394842e26e5 f2fs: inject fault in inc_valid_node_count 926292251022 f2fs: fix to clear FI_NO_PREALLOC e6cfc5de2d05 f2fs: expose quota information in debugfs c4cd2efe835b f2fs: separate nat entry mem alloc from nat_tree_lock 48c72b4c8c50 f2fs: validate before set/clear free nat bitmap baf9275a4bbd f2fs: avoid opened loop codes in __add_ino_entry 47af6c72d944 f2fs: apply write hints to select the type of segments for buffered write ac9819160586 f2fs: introduce scan_curseg_cache for cleanup ca28e9670e80 f2fs: optimize the way of traversing free_nid_bitmap 460688b59e8b f2fs: keep scanning until enough free nids are acquired 0186182c0c4d f2fs: trace checkpoint reason in fsync() 5d4b6efcfd09 f2fs: keep isize once block is reserved cross EOF 3c8f767e1374 f2fs: avoid race in between GC and block exchange 4423778adf0e f2fs: save a multiplication for last_nid calculation 3e3b40557525 f2fs: fix summary info corruption 44889e487981 f2fs: remove dead code in update_meta_page 55c7b9595bb9 f2fs: remove unneeded semicolon 8b92814117d5 f2fs: don't bother with inode->i_version 42c7c71824fc f2fs: check curseg space before foreground GC c5470498e59b f2fs: use rw_semaphore to protect SIT cache 82750d346ab7 f2fs: support quota sys files 26dfec49b25a f2fs: add quota_ino feature infra ddb8e2ae9811 f2fs: optimize __update_nat_bits f46ae958c701 f2fs: modify for accurate fggc node io stat c713fdb5a23c Revert "f2fs: handle dirty segments inside refresh_sit_entry" 873ec505cb07 f2fs: add a function to move nid ae66786296b4 f2fs: export SSR allocation threshold 90c28a18d2a4 f2fs: give correct trimmed blocks in fstrim 5612922fb0ac f2fs: support bio allocation error injection 583b7a274c27 f2fs: support get_page error injection 09a073cc8c56 f2fs: add missing sysfs description e945474a9c1b f2fs: support soft block reservation b7b2e629b6f6 f2fs: handle error case when adding xattr entry 7368e30495c5 f2fs: support flexible inline xattr size ada4061e191b f2fs: show current cp state 5b8ff1301a61 f2fs: add missing quota_initialize 46d4a691f035 f2fs: show # of dirty segments via sysfs fc13f9d7ce1e f2fs: stop all the operations by cp_error flag 91bea0c391b3 f2fs: remove several redundant assignments 807486c79534 f2fs: avoid using timespec 03b1cb0bb4a2 f2fs: fix to correct no_fggc_candidate 5c15033ceaea Revert "f2fs: return wrong error number on f2fs_quota_write" 5f5f59322240 f2fs: remove obsolete pointer for truncate_xattr_node 032a6906825a f2fs: retry ENOMEM for quota_read|write 171b638fc49b f2fs: limit # of inmemory pages 83ed7a615f0a f2fs: update ctx->pos correctly when hitting hole in directory 4d6e68be2534 f2fs: relocate readahead codes in readdir() c8be47b54018 f2fs: allow readdir() to be interrupted 2b903fe94cd0 f2fs: trace f2fs_readdir bb0db666d4bc f2fs: trace f2fs_lookup 40d6250f046a f2fs: skip searching non-exist range in truncate_hole 8e84f379df61 f2fs: expose some sectors to user in inline data or dentry case cb98f70dea02 f2fs: avoid stale fi->gdirty_list pointer 5562a3c53963 f2fs/crypto: drop crypto key at evict_inode only 85853e7e38d7 f2fs: fix to avoid race when accessing last_disk_size 0c47a892d555 f2fs: Fix bool initialization/comparison 68e801abc520 f2fs: give up CP_TRIMMED_FLAG if it drops discards df74eacb2075 f2fs: trace f2fs_remove_discard bd502c6e3e7a f2fs: reduce cmd_lock coverage in __issue_discard_cmd a34ab5ca4f94 f2fs: split discard policy 1e65afd14d32 f2fs: wrap discard policy 684447dad138 f2fs: support issuing/waiting discard in range 27eaad09380f f2fs: fix to flush multiple device in checkpoint 08bb9d68d51b f2fs: enhance multiple device flush 9c2526ac2ecb f2fs: fix to show ino management cache size correctly 814b463d262f f2fs: drop FI_UPDATE_WRITE tag after f2fs_issue_flush f555b0a117d3 f2fs: obsolete ALLOC_NID_LIST list 75d3164ae128 f2fs: convert inline data for direct I/O & FI_NO_PREALLOC 4de0ceb6b7ef f2fs: allow readpages with NULL file pointer 322a45d17212 f2fs: show flush list status in sysfs 6d625a93b4a8 f2fs: introduce read_xattr_block 8ea6e1c327c5 f2fs: introduce read_inline_xattr dbce11e9ee5b Revert "f2fs: reuse nids more aggressively" 131bc9f6b7f9 Revert "f2fs: node segment is prior to data segment selected victim" Change-Id: I93b9cd867b859a667a448b39299ff44a2b841b8c Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-09-23 17:02:18 +08:00
#define F2FS_MAX_QUOTAS 3
f2fs/fscrypt: updates to v4.17-rc1 Pull f2fs update from Jaegeuk Kim: "In this round, we've mainly focused on performance tuning and critical bug fixes occurred in low-end devices. Sheng Yong introduced lost_found feature to keep missing files during recovery instead of thrashing them. We're preparing coming fsverity implementation. And, we've got more features to communicate with users for better performance. In low-end devices, some memory-related issues were fixed, and subtle race condtions and corner cases were addressed as well. Enhancements: - large nat bitmaps for more free node ids - add three block allocation policies to pass down write hints given by user - expose extension list to user and introduce hot file extension - tune small devices seamlessly for low-end devices - set readdir_ra by default - give more resources under gc_urgent mode regarding to discard and cleaning - introduce fsync_mode to enforce posix or not - nowait aio support - add lost_found feature to keep dangling inodes - reserve bits for future fsverity feature - add test_dummy_encryption for FBE Bug fixes: - don't use highmem for dentry pages - align memory boundary for bitops - truncate preallocated blocks in write errors - guarantee i_times on fsync call - clear CP_TRIMMED_FLAG correctly - prevent node chain loop during recovery - avoid data race between atomic write and background cleaning - avoid unnecessary selinux violation warnings on resgid option - GFP_NOFS to avoid deadlock in quota and read paths - fix f2fs_skip_inode_update to allow i_size recovery In addition to the above, there are several minor bug fixes and clean-ups" Cherry-pick from origin/upstream-f2fs-stable-linux-4.4.y: 42bf67fc543b f2fs: remain written times to update inode during fsync 6cb5aa02bfbd f2fs: make assignment of t->dentry_bitmap more readable a8d07f1f9c62 f2fs: truncate preallocated blocks in error case 86444d600692 f2fs: fix a wrong condition in f2fs_skip_inode_update db2188a68704 f2fs: reserve bits for fs-verity ee2e74b3f00e f2fs: Add a segment type check in inplace write 0192e0a4502f f2fs: no need to initialize zero value for GFP_F2FS_ZERO 49338842e9b2 f2fs: don't track new nat entry in nat set d6a69d5e6568 f2fs: clean up with F2FS_BLK_ALIGN 2c8834a7a2c9 f2fs: check blkaddr more accuratly before issue a bio 6ab573a9d96f f2fs: Set GF_NOFS in read_cache_page_gfp while doing f2fs_quota_read 7419dcb8be02 f2fs: introduce a new mount option test_dummy_encryption 9321e22c038c f2fs: introduce F2FS_FEATURE_LOST_FOUND feature 8a5719615847 f2fs: release locks before return in f2fs_ioc_gc_range() 739ace131cdf f2fs: align memory boundary for bitops 4c55abe4f8d2 f2fs: remove unneeded set_cold_node() 30654507e0a2 f2fs: add nowait aio support d909e9410634 f2fs: wrap all options with f2fs_sb_info.mount_opt 5738be52b3e8 f2fs: Don't overwrite all types of node to keep node chain 0bdeb167c843 f2fs: introduce mount option for fsync mode 6bc490f0eedc f2fs: fix to restore old mount option in ->remount_fs 0c9c3e034410 f2fs: wrap sb_rdonly with f2fs_readonly 6c6611223a79 f2fs: avoid selinux denial on CAP_SYS_RESOURCE 076a6f32fe5d f2fs: support hot file extension 58edcdbca67a f2fs: fix to avoid race in between atomic write and background GC 1e0aeb0af9ed f2fs: do gc in greedy mode for whole range if gc_urgent mode is set 10b2d001d6ac f2fs: issue discard aggressively in the gc_urgent mode a5052f32b940 f2fs: set readdir_ra by default 1aa536a624cc f2fs: add auto tuning for small devices 0ffdffc8f106 f2fs: add mount option for segment allocation policy b79829891249 f2fs: don't stop GC if GC is contended 766d2321697f f2fs: expose extension_list sysfs entry 98b329de5026 f2fs: fix to set KEEP_SIZE bit in f2fs_zero_range 4d409fa3346b f2fs: introduce sb_lock to make encrypt pwsalt update exclusive 1f6bac14c100 f2fs: remove redundant initialization of pointer 'p' 946aefc7545d f2fs: flush cp pack except cp pack 2 page at first e5081a52ac09 f2fs: clean up f2fs_sb_has_xxx functions a292477154b5 f2fs: remove redundant check of page type when submit bio 190e64a819df f2fs: fix to handle looped node chain during recovery 889d98087652 f2fs: handle quota for orphan inodes 92b12bb1a23e f2fs: support passing down write hints to block layer with F2FS policy 22fa74c2b097 f2fs: support passing down write hints given by users to block layer 180900373ec1 f2fs: fix to clear CP_TRIMMED_FLAG 0671fae134bb f2fs: support large nat bitmap eceb943d5d59 f2fs: fix to check extent cache in f2fs_drop_extent_tree 2e2a339c9853 f2fs: restrict inline_xattr_size configuration 41dda1164137 f2fs: fix heap mode to reset it back 39575737bb62 f2fs: fix potential corruption in area before F2FS_SUPER_OFFSET 7e0e7995ee97 fscrypt: fix build with pre-4.6 gcc versions 31d3279a4fca fscrypt: fix up fscrypt_fname_encrypted_size() for internal use 82bec888567b fscrypt: define fscrypt_fname_alloc_buffer() to be for presented names 168a90782888 fscrypt: calculate NUL-padding length in one place only 042ae9f4cfbf fscrypt: move fscrypt_symlink_data to fscrypt_private.h f9550c24c20e fscrypt: remove fscrypt_fname_usr_to_disk() 7ac4756a2474 f2fs: switch to fscrypt_get_symlink() 6b76f58e24bd f2fs: switch to fscrypt ->symlink() helper functions fd457d2c4e04 fscrypt: new helper function - fscrypt_get_symlink() a1cdacb7ae0d fscrypt: new helper functions for ->symlink() 7f43602f4d10 fscrypt: trim down fscrypt.h includes d9cadc11bdcf fscrypt: move fscrypt_is_dot_dotdot() to fs/crypto/fname.c e6fe930580cb fscrypt: move fscrypt_valid_enc_modes() to fscrypt_private.h efefa434f47e fscrypt: move fscrypt_operations declaration to fscrypt_supp.h 7ed178bc8ae9 fscrypt: split fscrypt_dummy_context_enabled() into supp/notsupp versions 3f16e09dadfb fscrypt: move fscrypt_ctx declaration to fscrypt_supp.h 8216a0b51a3b fscrypt: move fscrypt_info_cachep declaration to fscrypt_private.h dfe0b3b1b67f fscrypt: move fscrypt_control_page() to supp/notsupp headers 3a2c79177822 fscrypt: move fscrypt_has_encryption_key() to supp/notsupp headers Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-01-05 10:44:52 -08:00
#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)
/*
* 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
#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 */
__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 */
__le16 volume_name[MAX_VOLUME_NAME]; /* volume name */
__le32 extension_count; /* # of extensions below */
f2fs/fscrypt: updates to v4.17-rc1 Pull f2fs update from Jaegeuk Kim: "In this round, we've mainly focused on performance tuning and critical bug fixes occurred in low-end devices. Sheng Yong introduced lost_found feature to keep missing files during recovery instead of thrashing them. We're preparing coming fsverity implementation. And, we've got more features to communicate with users for better performance. In low-end devices, some memory-related issues were fixed, and subtle race condtions and corner cases were addressed as well. Enhancements: - large nat bitmaps for more free node ids - add three block allocation policies to pass down write hints given by user - expose extension list to user and introduce hot file extension - tune small devices seamlessly for low-end devices - set readdir_ra by default - give more resources under gc_urgent mode regarding to discard and cleaning - introduce fsync_mode to enforce posix or not - nowait aio support - add lost_found feature to keep dangling inodes - reserve bits for future fsverity feature - add test_dummy_encryption for FBE Bug fixes: - don't use highmem for dentry pages - align memory boundary for bitops - truncate preallocated blocks in write errors - guarantee i_times on fsync call - clear CP_TRIMMED_FLAG correctly - prevent node chain loop during recovery - avoid data race between atomic write and background cleaning - avoid unnecessary selinux violation warnings on resgid option - GFP_NOFS to avoid deadlock in quota and read paths - fix f2fs_skip_inode_update to allow i_size recovery In addition to the above, there are several minor bug fixes and clean-ups" Cherry-pick from origin/upstream-f2fs-stable-linux-4.4.y: 42bf67fc543b f2fs: remain written times to update inode during fsync 6cb5aa02bfbd f2fs: make assignment of t->dentry_bitmap more readable a8d07f1f9c62 f2fs: truncate preallocated blocks in error case 86444d600692 f2fs: fix a wrong condition in f2fs_skip_inode_update db2188a68704 f2fs: reserve bits for fs-verity ee2e74b3f00e f2fs: Add a segment type check in inplace write 0192e0a4502f f2fs: no need to initialize zero value for GFP_F2FS_ZERO 49338842e9b2 f2fs: don't track new nat entry in nat set d6a69d5e6568 f2fs: clean up with F2FS_BLK_ALIGN 2c8834a7a2c9 f2fs: check blkaddr more accuratly before issue a bio 6ab573a9d96f f2fs: Set GF_NOFS in read_cache_page_gfp while doing f2fs_quota_read 7419dcb8be02 f2fs: introduce a new mount option test_dummy_encryption 9321e22c038c f2fs: introduce F2FS_FEATURE_LOST_FOUND feature 8a5719615847 f2fs: release locks before return in f2fs_ioc_gc_range() 739ace131cdf f2fs: align memory boundary for bitops 4c55abe4f8d2 f2fs: remove unneeded set_cold_node() 30654507e0a2 f2fs: add nowait aio support d909e9410634 f2fs: wrap all options with f2fs_sb_info.mount_opt 5738be52b3e8 f2fs: Don't overwrite all types of node to keep node chain 0bdeb167c843 f2fs: introduce mount option for fsync mode 6bc490f0eedc f2fs: fix to restore old mount option in ->remount_fs 0c9c3e034410 f2fs: wrap sb_rdonly with f2fs_readonly 6c6611223a79 f2fs: avoid selinux denial on CAP_SYS_RESOURCE 076a6f32fe5d f2fs: support hot file extension 58edcdbca67a f2fs: fix to avoid race in between atomic write and background GC 1e0aeb0af9ed f2fs: do gc in greedy mode for whole range if gc_urgent mode is set 10b2d001d6ac f2fs: issue discard aggressively in the gc_urgent mode a5052f32b940 f2fs: set readdir_ra by default 1aa536a624cc f2fs: add auto tuning for small devices 0ffdffc8f106 f2fs: add mount option for segment allocation policy b79829891249 f2fs: don't stop GC if GC is contended 766d2321697f f2fs: expose extension_list sysfs entry 98b329de5026 f2fs: fix to set KEEP_SIZE bit in f2fs_zero_range 4d409fa3346b f2fs: introduce sb_lock to make encrypt pwsalt update exclusive 1f6bac14c100 f2fs: remove redundant initialization of pointer 'p' 946aefc7545d f2fs: flush cp pack except cp pack 2 page at first e5081a52ac09 f2fs: clean up f2fs_sb_has_xxx functions a292477154b5 f2fs: remove redundant check of page type when submit bio 190e64a819df f2fs: fix to handle looped node chain during recovery 889d98087652 f2fs: handle quota for orphan inodes 92b12bb1a23e f2fs: support passing down write hints to block layer with F2FS policy 22fa74c2b097 f2fs: support passing down write hints given by users to block layer 180900373ec1 f2fs: fix to clear CP_TRIMMED_FLAG 0671fae134bb f2fs: support large nat bitmap eceb943d5d59 f2fs: fix to check extent cache in f2fs_drop_extent_tree 2e2a339c9853 f2fs: restrict inline_xattr_size configuration 41dda1164137 f2fs: fix heap mode to reset it back 39575737bb62 f2fs: fix potential corruption in area before F2FS_SUPER_OFFSET 7e0e7995ee97 fscrypt: fix build with pre-4.6 gcc versions 31d3279a4fca fscrypt: fix up fscrypt_fname_encrypted_size() for internal use 82bec888567b fscrypt: define fscrypt_fname_alloc_buffer() to be for presented names 168a90782888 fscrypt: calculate NUL-padding length in one place only 042ae9f4cfbf fscrypt: move fscrypt_symlink_data to fscrypt_private.h f9550c24c20e fscrypt: remove fscrypt_fname_usr_to_disk() 7ac4756a2474 f2fs: switch to fscrypt_get_symlink() 6b76f58e24bd f2fs: switch to fscrypt ->symlink() helper functions fd457d2c4e04 fscrypt: new helper function - fscrypt_get_symlink() a1cdacb7ae0d fscrypt: new helper functions for ->symlink() 7f43602f4d10 fscrypt: trim down fscrypt.h includes d9cadc11bdcf fscrypt: move fscrypt_is_dot_dotdot() to fs/crypto/fname.c e6fe930580cb fscrypt: move fscrypt_valid_enc_modes() to fscrypt_private.h efefa434f47e fscrypt: move fscrypt_operations declaration to fscrypt_supp.h 7ed178bc8ae9 fscrypt: split fscrypt_dummy_context_enabled() into supp/notsupp versions 3f16e09dadfb fscrypt: move fscrypt_ctx declaration to fscrypt_supp.h 8216a0b51a3b fscrypt: move fscrypt_info_cachep declaration to fscrypt_private.h dfe0b3b1b67f fscrypt: move fscrypt_control_page() to supp/notsupp headers 3a2c79177822 fscrypt: move fscrypt_has_encryption_key() to supp/notsupp headers Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-01-05 10:44:52 -08:00
__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 */
struct f2fs_device devs[MAX_DEVICES]; /* device list */
f2fs: updates on 4.15-rc1 Pull f2fs updates from Jaegeuk Kim: "In this round, we introduce sysfile-based quota support which is required for Android by default. In addition, we allow that users are able to reserve some blocks in runtime to mitigate performance drops in low free space. Enhancements: - assign proper data segments according to write_hints given by user - issue cache_flush on dirty devices only among multiple devices - exploit cp_error flag and add more faults to enhance fault injection test - conduct more readaheads during f2fs_readdir - add a range for discard commands Bug fixes: - fix zero stat->st_blocks when inline_data is set - drop crypto key and free stale memory pointer while evict_inode is failing - fix some corner cases in free space and segment management - fix wrong last_disk_size This series includes lots of clean-ups and code enhancement in terms of xattr operations, discard/flush command control. In addition, it adds versatile debugfs entries to monitor f2fs status" Cherry-picked from origin/upstream-f2fs-stable-linux-4.4.y: 56a07b070510 f2fs: deny accessing encryption policy if encryption is off c394842e26e5 f2fs: inject fault in inc_valid_node_count 926292251022 f2fs: fix to clear FI_NO_PREALLOC e6cfc5de2d05 f2fs: expose quota information in debugfs c4cd2efe835b f2fs: separate nat entry mem alloc from nat_tree_lock 48c72b4c8c50 f2fs: validate before set/clear free nat bitmap baf9275a4bbd f2fs: avoid opened loop codes in __add_ino_entry 47af6c72d944 f2fs: apply write hints to select the type of segments for buffered write ac9819160586 f2fs: introduce scan_curseg_cache for cleanup ca28e9670e80 f2fs: optimize the way of traversing free_nid_bitmap 460688b59e8b f2fs: keep scanning until enough free nids are acquired 0186182c0c4d f2fs: trace checkpoint reason in fsync() 5d4b6efcfd09 f2fs: keep isize once block is reserved cross EOF 3c8f767e1374 f2fs: avoid race in between GC and block exchange 4423778adf0e f2fs: save a multiplication for last_nid calculation 3e3b40557525 f2fs: fix summary info corruption 44889e487981 f2fs: remove dead code in update_meta_page 55c7b9595bb9 f2fs: remove unneeded semicolon 8b92814117d5 f2fs: don't bother with inode->i_version 42c7c71824fc f2fs: check curseg space before foreground GC c5470498e59b f2fs: use rw_semaphore to protect SIT cache 82750d346ab7 f2fs: support quota sys files 26dfec49b25a f2fs: add quota_ino feature infra ddb8e2ae9811 f2fs: optimize __update_nat_bits f46ae958c701 f2fs: modify for accurate fggc node io stat c713fdb5a23c Revert "f2fs: handle dirty segments inside refresh_sit_entry" 873ec505cb07 f2fs: add a function to move nid ae66786296b4 f2fs: export SSR allocation threshold 90c28a18d2a4 f2fs: give correct trimmed blocks in fstrim 5612922fb0ac f2fs: support bio allocation error injection 583b7a274c27 f2fs: support get_page error injection 09a073cc8c56 f2fs: add missing sysfs description e945474a9c1b f2fs: support soft block reservation b7b2e629b6f6 f2fs: handle error case when adding xattr entry 7368e30495c5 f2fs: support flexible inline xattr size ada4061e191b f2fs: show current cp state 5b8ff1301a61 f2fs: add missing quota_initialize 46d4a691f035 f2fs: show # of dirty segments via sysfs fc13f9d7ce1e f2fs: stop all the operations by cp_error flag 91bea0c391b3 f2fs: remove several redundant assignments 807486c79534 f2fs: avoid using timespec 03b1cb0bb4a2 f2fs: fix to correct no_fggc_candidate 5c15033ceaea Revert "f2fs: return wrong error number on f2fs_quota_write" 5f5f59322240 f2fs: remove obsolete pointer for truncate_xattr_node 032a6906825a f2fs: retry ENOMEM for quota_read|write 171b638fc49b f2fs: limit # of inmemory pages 83ed7a615f0a f2fs: update ctx->pos correctly when hitting hole in directory 4d6e68be2534 f2fs: relocate readahead codes in readdir() c8be47b54018 f2fs: allow readdir() to be interrupted 2b903fe94cd0 f2fs: trace f2fs_readdir bb0db666d4bc f2fs: trace f2fs_lookup 40d6250f046a f2fs: skip searching non-exist range in truncate_hole 8e84f379df61 f2fs: expose some sectors to user in inline data or dentry case cb98f70dea02 f2fs: avoid stale fi->gdirty_list pointer 5562a3c53963 f2fs/crypto: drop crypto key at evict_inode only 85853e7e38d7 f2fs: fix to avoid race when accessing last_disk_size 0c47a892d555 f2fs: Fix bool initialization/comparison 68e801abc520 f2fs: give up CP_TRIMMED_FLAG if it drops discards df74eacb2075 f2fs: trace f2fs_remove_discard bd502c6e3e7a f2fs: reduce cmd_lock coverage in __issue_discard_cmd a34ab5ca4f94 f2fs: split discard policy 1e65afd14d32 f2fs: wrap discard policy 684447dad138 f2fs: support issuing/waiting discard in range 27eaad09380f f2fs: fix to flush multiple device in checkpoint 08bb9d68d51b f2fs: enhance multiple device flush 9c2526ac2ecb f2fs: fix to show ino management cache size correctly 814b463d262f f2fs: drop FI_UPDATE_WRITE tag after f2fs_issue_flush f555b0a117d3 f2fs: obsolete ALLOC_NID_LIST list 75d3164ae128 f2fs: convert inline data for direct I/O & FI_NO_PREALLOC 4de0ceb6b7ef f2fs: allow readpages with NULL file pointer 322a45d17212 f2fs: show flush list status in sysfs 6d625a93b4a8 f2fs: introduce read_xattr_block 8ea6e1c327c5 f2fs: introduce read_inline_xattr dbce11e9ee5b Revert "f2fs: reuse nids more aggressively" 131bc9f6b7f9 Revert "f2fs: node segment is prior to data segment selected victim" Change-Id: I93b9cd867b859a667a448b39299ff44a2b841b8c Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-09-23 17:02:18 +08:00
__le32 qf_ino[F2FS_MAX_QUOTAS]; /* quota inode numbers */
f2fs/fscrypt: updates to v4.17-rc1 Pull f2fs update from Jaegeuk Kim: "In this round, we've mainly focused on performance tuning and critical bug fixes occurred in low-end devices. Sheng Yong introduced lost_found feature to keep missing files during recovery instead of thrashing them. We're preparing coming fsverity implementation. And, we've got more features to communicate with users for better performance. In low-end devices, some memory-related issues were fixed, and subtle race condtions and corner cases were addressed as well. Enhancements: - large nat bitmaps for more free node ids - add three block allocation policies to pass down write hints given by user - expose extension list to user and introduce hot file extension - tune small devices seamlessly for low-end devices - set readdir_ra by default - give more resources under gc_urgent mode regarding to discard and cleaning - introduce fsync_mode to enforce posix or not - nowait aio support - add lost_found feature to keep dangling inodes - reserve bits for future fsverity feature - add test_dummy_encryption for FBE Bug fixes: - don't use highmem for dentry pages - align memory boundary for bitops - truncate preallocated blocks in write errors - guarantee i_times on fsync call - clear CP_TRIMMED_FLAG correctly - prevent node chain loop during recovery - avoid data race between atomic write and background cleaning - avoid unnecessary selinux violation warnings on resgid option - GFP_NOFS to avoid deadlock in quota and read paths - fix f2fs_skip_inode_update to allow i_size recovery In addition to the above, there are several minor bug fixes and clean-ups" Cherry-pick from origin/upstream-f2fs-stable-linux-4.4.y: 42bf67fc543b f2fs: remain written times to update inode during fsync 6cb5aa02bfbd f2fs: make assignment of t->dentry_bitmap more readable a8d07f1f9c62 f2fs: truncate preallocated blocks in error case 86444d600692 f2fs: fix a wrong condition in f2fs_skip_inode_update db2188a68704 f2fs: reserve bits for fs-verity ee2e74b3f00e f2fs: Add a segment type check in inplace write 0192e0a4502f f2fs: no need to initialize zero value for GFP_F2FS_ZERO 49338842e9b2 f2fs: don't track new nat entry in nat set d6a69d5e6568 f2fs: clean up with F2FS_BLK_ALIGN 2c8834a7a2c9 f2fs: check blkaddr more accuratly before issue a bio 6ab573a9d96f f2fs: Set GF_NOFS in read_cache_page_gfp while doing f2fs_quota_read 7419dcb8be02 f2fs: introduce a new mount option test_dummy_encryption 9321e22c038c f2fs: introduce F2FS_FEATURE_LOST_FOUND feature 8a5719615847 f2fs: release locks before return in f2fs_ioc_gc_range() 739ace131cdf f2fs: align memory boundary for bitops 4c55abe4f8d2 f2fs: remove unneeded set_cold_node() 30654507e0a2 f2fs: add nowait aio support d909e9410634 f2fs: wrap all options with f2fs_sb_info.mount_opt 5738be52b3e8 f2fs: Don't overwrite all types of node to keep node chain 0bdeb167c843 f2fs: introduce mount option for fsync mode 6bc490f0eedc f2fs: fix to restore old mount option in ->remount_fs 0c9c3e034410 f2fs: wrap sb_rdonly with f2fs_readonly 6c6611223a79 f2fs: avoid selinux denial on CAP_SYS_RESOURCE 076a6f32fe5d f2fs: support hot file extension 58edcdbca67a f2fs: fix to avoid race in between atomic write and background GC 1e0aeb0af9ed f2fs: do gc in greedy mode for whole range if gc_urgent mode is set 10b2d001d6ac f2fs: issue discard aggressively in the gc_urgent mode a5052f32b940 f2fs: set readdir_ra by default 1aa536a624cc f2fs: add auto tuning for small devices 0ffdffc8f106 f2fs: add mount option for segment allocation policy b79829891249 f2fs: don't stop GC if GC is contended 766d2321697f f2fs: expose extension_list sysfs entry 98b329de5026 f2fs: fix to set KEEP_SIZE bit in f2fs_zero_range 4d409fa3346b f2fs: introduce sb_lock to make encrypt pwsalt update exclusive 1f6bac14c100 f2fs: remove redundant initialization of pointer 'p' 946aefc7545d f2fs: flush cp pack except cp pack 2 page at first e5081a52ac09 f2fs: clean up f2fs_sb_has_xxx functions a292477154b5 f2fs: remove redundant check of page type when submit bio 190e64a819df f2fs: fix to handle looped node chain during recovery 889d98087652 f2fs: handle quota for orphan inodes 92b12bb1a23e f2fs: support passing down write hints to block layer with F2FS policy 22fa74c2b097 f2fs: support passing down write hints given by users to block layer 180900373ec1 f2fs: fix to clear CP_TRIMMED_FLAG 0671fae134bb f2fs: support large nat bitmap eceb943d5d59 f2fs: fix to check extent cache in f2fs_drop_extent_tree 2e2a339c9853 f2fs: restrict inline_xattr_size configuration 41dda1164137 f2fs: fix heap mode to reset it back 39575737bb62 f2fs: fix potential corruption in area before F2FS_SUPER_OFFSET 7e0e7995ee97 fscrypt: fix build with pre-4.6 gcc versions 31d3279a4fca fscrypt: fix up fscrypt_fname_encrypted_size() for internal use 82bec888567b fscrypt: define fscrypt_fname_alloc_buffer() to be for presented names 168a90782888 fscrypt: calculate NUL-padding length in one place only 042ae9f4cfbf fscrypt: move fscrypt_symlink_data to fscrypt_private.h f9550c24c20e fscrypt: remove fscrypt_fname_usr_to_disk() 7ac4756a2474 f2fs: switch to fscrypt_get_symlink() 6b76f58e24bd f2fs: switch to fscrypt ->symlink() helper functions fd457d2c4e04 fscrypt: new helper function - fscrypt_get_symlink() a1cdacb7ae0d fscrypt: new helper functions for ->symlink() 7f43602f4d10 fscrypt: trim down fscrypt.h includes d9cadc11bdcf fscrypt: move fscrypt_is_dot_dotdot() to fs/crypto/fname.c e6fe930580cb fscrypt: move fscrypt_valid_enc_modes() to fscrypt_private.h efefa434f47e fscrypt: move fscrypt_operations declaration to fscrypt_supp.h 7ed178bc8ae9 fscrypt: split fscrypt_dummy_context_enabled() into supp/notsupp versions 3f16e09dadfb fscrypt: move fscrypt_ctx declaration to fscrypt_supp.h 8216a0b51a3b fscrypt: move fscrypt_info_cachep declaration to fscrypt_private.h dfe0b3b1b67f fscrypt: move fscrypt_control_page() to supp/notsupp headers 3a2c79177822 fscrypt: move fscrypt_has_encryption_key() to supp/notsupp headers Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-01-05 10:44:52 -08:00
__u8 hot_ext_count; /* # of hot file extension */
__u8 reserved[314]; /* valid reserved region */
} __packed;
/*
* For checkpoint
*/
f2fs/fscrypt: updates to v4.17-rc1 Pull f2fs update from Jaegeuk Kim: "In this round, we've mainly focused on performance tuning and critical bug fixes occurred in low-end devices. Sheng Yong introduced lost_found feature to keep missing files during recovery instead of thrashing them. We're preparing coming fsverity implementation. And, we've got more features to communicate with users for better performance. In low-end devices, some memory-related issues were fixed, and subtle race condtions and corner cases were addressed as well. Enhancements: - large nat bitmaps for more free node ids - add three block allocation policies to pass down write hints given by user - expose extension list to user and introduce hot file extension - tune small devices seamlessly for low-end devices - set readdir_ra by default - give more resources under gc_urgent mode regarding to discard and cleaning - introduce fsync_mode to enforce posix or not - nowait aio support - add lost_found feature to keep dangling inodes - reserve bits for future fsverity feature - add test_dummy_encryption for FBE Bug fixes: - don't use highmem for dentry pages - align memory boundary for bitops - truncate preallocated blocks in write errors - guarantee i_times on fsync call - clear CP_TRIMMED_FLAG correctly - prevent node chain loop during recovery - avoid data race between atomic write and background cleaning - avoid unnecessary selinux violation warnings on resgid option - GFP_NOFS to avoid deadlock in quota and read paths - fix f2fs_skip_inode_update to allow i_size recovery In addition to the above, there are several minor bug fixes and clean-ups" Cherry-pick from origin/upstream-f2fs-stable-linux-4.4.y: 42bf67fc543b f2fs: remain written times to update inode during fsync 6cb5aa02bfbd f2fs: make assignment of t->dentry_bitmap more readable a8d07f1f9c62 f2fs: truncate preallocated blocks in error case 86444d600692 f2fs: fix a wrong condition in f2fs_skip_inode_update db2188a68704 f2fs: reserve bits for fs-verity ee2e74b3f00e f2fs: Add a segment type check in inplace write 0192e0a4502f f2fs: no need to initialize zero value for GFP_F2FS_ZERO 49338842e9b2 f2fs: don't track new nat entry in nat set d6a69d5e6568 f2fs: clean up with F2FS_BLK_ALIGN 2c8834a7a2c9 f2fs: check blkaddr more accuratly before issue a bio 6ab573a9d96f f2fs: Set GF_NOFS in read_cache_page_gfp while doing f2fs_quota_read 7419dcb8be02 f2fs: introduce a new mount option test_dummy_encryption 9321e22c038c f2fs: introduce F2FS_FEATURE_LOST_FOUND feature 8a5719615847 f2fs: release locks before return in f2fs_ioc_gc_range() 739ace131cdf f2fs: align memory boundary for bitops 4c55abe4f8d2 f2fs: remove unneeded set_cold_node() 30654507e0a2 f2fs: add nowait aio support d909e9410634 f2fs: wrap all options with f2fs_sb_info.mount_opt 5738be52b3e8 f2fs: Don't overwrite all types of node to keep node chain 0bdeb167c843 f2fs: introduce mount option for fsync mode 6bc490f0eedc f2fs: fix to restore old mount option in ->remount_fs 0c9c3e034410 f2fs: wrap sb_rdonly with f2fs_readonly 6c6611223a79 f2fs: avoid selinux denial on CAP_SYS_RESOURCE 076a6f32fe5d f2fs: support hot file extension 58edcdbca67a f2fs: fix to avoid race in between atomic write and background GC 1e0aeb0af9ed f2fs: do gc in greedy mode for whole range if gc_urgent mode is set 10b2d001d6ac f2fs: issue discard aggressively in the gc_urgent mode a5052f32b940 f2fs: set readdir_ra by default 1aa536a624cc f2fs: add auto tuning for small devices 0ffdffc8f106 f2fs: add mount option for segment allocation policy b79829891249 f2fs: don't stop GC if GC is contended 766d2321697f f2fs: expose extension_list sysfs entry 98b329de5026 f2fs: fix to set KEEP_SIZE bit in f2fs_zero_range 4d409fa3346b f2fs: introduce sb_lock to make encrypt pwsalt update exclusive 1f6bac14c100 f2fs: remove redundant initialization of pointer 'p' 946aefc7545d f2fs: flush cp pack except cp pack 2 page at first e5081a52ac09 f2fs: clean up f2fs_sb_has_xxx functions a292477154b5 f2fs: remove redundant check of page type when submit bio 190e64a819df f2fs: fix to handle looped node chain during recovery 889d98087652 f2fs: handle quota for orphan inodes 92b12bb1a23e f2fs: support passing down write hints to block layer with F2FS policy 22fa74c2b097 f2fs: support passing down write hints given by users to block layer 180900373ec1 f2fs: fix to clear CP_TRIMMED_FLAG 0671fae134bb f2fs: support large nat bitmap eceb943d5d59 f2fs: fix to check extent cache in f2fs_drop_extent_tree 2e2a339c9853 f2fs: restrict inline_xattr_size configuration 41dda1164137 f2fs: fix heap mode to reset it back 39575737bb62 f2fs: fix potential corruption in area before F2FS_SUPER_OFFSET 7e0e7995ee97 fscrypt: fix build with pre-4.6 gcc versions 31d3279a4fca fscrypt: fix up fscrypt_fname_encrypted_size() for internal use 82bec888567b fscrypt: define fscrypt_fname_alloc_buffer() to be for presented names 168a90782888 fscrypt: calculate NUL-padding length in one place only 042ae9f4cfbf fscrypt: move fscrypt_symlink_data to fscrypt_private.h f9550c24c20e fscrypt: remove fscrypt_fname_usr_to_disk() 7ac4756a2474 f2fs: switch to fscrypt_get_symlink() 6b76f58e24bd f2fs: switch to fscrypt ->symlink() helper functions fd457d2c4e04 fscrypt: new helper function - fscrypt_get_symlink() a1cdacb7ae0d fscrypt: new helper functions for ->symlink() 7f43602f4d10 fscrypt: trim down fscrypt.h includes d9cadc11bdcf fscrypt: move fscrypt_is_dot_dotdot() to fs/crypto/fname.c e6fe930580cb fscrypt: move fscrypt_valid_enc_modes() to fscrypt_private.h efefa434f47e fscrypt: move fscrypt_operations declaration to fscrypt_supp.h 7ed178bc8ae9 fscrypt: split fscrypt_dummy_context_enabled() into supp/notsupp versions 3f16e09dadfb fscrypt: move fscrypt_ctx declaration to fscrypt_supp.h 8216a0b51a3b fscrypt: move fscrypt_info_cachep declaration to fscrypt_private.h dfe0b3b1b67f fscrypt: move fscrypt_control_page() to supp/notsupp headers 3a2c79177822 fscrypt: move fscrypt_has_encryption_key() to supp/notsupp headers Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-01-05 10:44:52 -08:00
#define CP_LARGE_NAT_BITMAP_FLAG 0x00000400
f2fs: updates on v4.16-rc1 Pull f2fs updates from Jaegeuk Kim: "In this round, we've followed up to support some generic features such as cgroup, block reservation, linking fscrypt_ops, delivering write_hints, and some ioctls. And, we could fix some corner cases in terms of power-cut recovery and subtle deadlocks. Enhancements: - bitmap operations to handle NAT blocks - readahead to improve readdir speed - switch to use fscrypt_* - apply write hints for direct IO - add reserve_root=%u,resuid=%u,resgid=%u to reserve blocks for root/uid/gid - modify b_avail and b_free to consider root reserved blocks - support cgroup writeback - support FIEMAP_FLAG_XATTR for fibmap - add F2FS_IOC_PRECACHE_EXTENTS to pre-cache extents - add F2FS_IOC_{GET/SET}_PIN_FILE to pin LBAs for data blocks - support inode creation time Bug fixs: - sysfile-based quota operations - memory footprint accounting - allow to write data on partial preallocation case - fix deadlock case on fallocate - fix to handle fill_super errors - fix missing inode updates of fsync'ed file - recover renamed file which was fsycn'ed before - drop inmemory pages in corner error case - keep last_disk_size correctly - recover missing i_inline flags during roll-forward Various clean-up patches were added as well" Cherry-pick from origin/upstream-f2fs-stable-linux-4.4.y: 5f9b3abb911f f2fs: support inode creation time 9fb0de175172 f2fs: rebuild sit page from sit info in mem 1062a0c01829 f2fs: stop issuing discard if fs is readonly fa043fae9030 f2fs: clean up duplicated assignment in init_discard_policy b007190234d6 f2fs: use GFP_F2FS_ZERO for cleanup 35b11839a1ae f2fs: allow to recover node blocks given updated checkpoint e56500860be0 f2fs: recover some i_inline flags 64aa9569a1bf f2fs: correct removexattr behavior for null valued extended attribute 70b3a923daff f2fs: drop page cache after fs shutdown 8069a0e983d9 f2fs: stop gc/discard thread after fs shutdown bb924f777717 f2fs: hanlde error case in f2fs_ioc_shutdown 700b53f21ee8 f2fs: split need_inplace_update f31d52811c1f f2fs: fix to update last_disk_size correctly eeb0118b8340 f2fs: kill F2FS_INLINE_XATTR_ADDRS for cleanup c1b74c967092 f2fs: clean up error path of fill_super d5efd57e013b f2fs: avoid hungtask when GC encrypted block if io_bits is set c4027d08430b f2fs: allow quota to use reserved blocks 18d267c273a9 f2fs: fix to drop all inmem pages correctly 4dca47531eb0 f2fs: speed up defragment on sparse file 999f806a7c9e f2fs: support F2FS_IOC_PRECACHE_EXTENTS 84960fca96c4 f2fs: add an ioctl to disable GC for specific file 292c8e1cfd4d f2fs: prevent newly created inode from being dirtied incorrectly 58b1f5b0fcf1 f2fs: support FIEMAP_FLAG_XATTR 6afa9a94d09b f2fs: fix to cover f2fs_inline_data_fiemap with inode_lock 10f4a4140b61 f2fs: check node page again in write end io b203c58dfd55 f2fs: fix to caclulate required free section correctly d49132d45cb0 f2fs: handle newly created page when revoking inmem pages 2ce6b9d8167e f2fs: add resgid and resuid to reserve root blocks f53dcf6799ab f2fs: implement cgroup writeback support 1338f376d5a3 f2fs: remove unused pend_list_tag d4f19f6266ab f2fs: avoid high cpu usage in discard thread b78e9302e2e3 f2fs: make local functions static 62438ba87b79 f2fs: add reserved blocks for root user 06a366757ff7 f2fs: check segment type in __f2fs_replace_block 4c6bc4be375a f2fs: update inode info to inode page for new file 591b33638733 f2fs: show precise # of blocks that user/root can use b242d7edc537 f2fs: clean up unneeded declaration 87b8168e9ef0 f2fs: continue to do direct IO if we only preallocate partial blocks 2b4d859bd9d8 f2fs: enable quota at remount from r to w 54bf13a0adcd f2fs: skip stop_checkpoint for user data writes 25ef3006ba23 f2fs: fix missing error number for xattr operation cff2c7fe417b f2fs: recover directory operations by fsync e2bb618a0a6b f2fs: return error during fill_super 8a2c11d8658d f2fs: fix an error case of missing update inode page cd38d5ada5a4 f2fs: fix potential hangtask in f2fs_trace_pid e81cafbeba4b f2fs: no need return value in restore summary process 04d44000d633 f2fs: use unlikely for release case 925d0933d8f0 f2fs: don't return value in truncate_data_blocks_range f7986c416d1b f2fs: clean up f2fs_map_blocks e4f5e26cdadf f2fs: clean up hash codes 1f994d47080c f2fs: fix error handling in fill_super e7db649b5fb1 f2fs: spread f2fs_k{m,z}alloc 5d4e487b9929 f2fs: inject fault to kvmalloc 8b33886c37cd f2fs: inject fault to kzalloc d94680798786 f2fs: remove a redundant conditional expression 3bc01114a338 f2fs: apply write hints to select the type of segment for direct write c80f01959114 f2fs: switch to fscrypt_prepare_setattr() bb8b850365ff f2fs: switch to fscrypt_prepare_lookup() 9ab470eaf8a8 f2fs: switch to fscrypt_prepare_rename() aeaac517a12d f2fs: switch to fscrypt_prepare_link() 101c6a96ad1c f2fs: switch to fscrypt_file_open() 6d025237a1f8 f2fs: remove repeated f2fs_bug_on b01e03d724de f2fs: remove an excess variable e1f9be2f7c82 f2fs: fix lock dependency in between dio_rwsem & i_mmap_sem e5c7c8601030 f2fs: remove unused parameter f130dbb98a68 f2fs: still write data if preallocate only partial blocks 47ee9b259811 f2fs: introduce sysfs readdir_ra to readahead inode block in readdir 55e2f89181ce f2fs: fix concurrent problem for updating free bitmap e1398f6554b4 f2fs: remove unneeded memory footprint accounting 2d69561135f2 f2fs: no need to read nat block if nat_block_bitmap is set 4dd2d0733809 f2fs: reserve nid resource for quota sysfile Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-11-16 16:59:14 +08:00
#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
#define CP_ERROR_FLAG 0x00000008
#define CP_COMPACT_SUM_FLAG 0x00000004
#define CP_ORPHAN_PRESENT_FLAG 0x00000002
#define CP_UMOUNT_FLAG 0x00000001
#define F2FS_CP_PACKS 2 /* # of checkpoint packs */
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
#define GET_ORPHAN_BLOCKS(n) ((n + F2FS_ORPHANS_PER_BLOCK - 1) / \
F2FS_ORPHANS_PER_BLOCK)
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 */
__le32 blk; /* start block address of the extent */
__le32 len; /* lengh of the extent */
} __packed;
#define F2FS_NAME_LEN 255
f2fs: updates on 4.15-rc1 Pull f2fs updates from Jaegeuk Kim: "In this round, we introduce sysfile-based quota support which is required for Android by default. In addition, we allow that users are able to reserve some blocks in runtime to mitigate performance drops in low free space. Enhancements: - assign proper data segments according to write_hints given by user - issue cache_flush on dirty devices only among multiple devices - exploit cp_error flag and add more faults to enhance fault injection test - conduct more readaheads during f2fs_readdir - add a range for discard commands Bug fixes: - fix zero stat->st_blocks when inline_data is set - drop crypto key and free stale memory pointer while evict_inode is failing - fix some corner cases in free space and segment management - fix wrong last_disk_size This series includes lots of clean-ups and code enhancement in terms of xattr operations, discard/flush command control. In addition, it adds versatile debugfs entries to monitor f2fs status" Cherry-picked from origin/upstream-f2fs-stable-linux-4.4.y: 56a07b070510 f2fs: deny accessing encryption policy if encryption is off c394842e26e5 f2fs: inject fault in inc_valid_node_count 926292251022 f2fs: fix to clear FI_NO_PREALLOC e6cfc5de2d05 f2fs: expose quota information in debugfs c4cd2efe835b f2fs: separate nat entry mem alloc from nat_tree_lock 48c72b4c8c50 f2fs: validate before set/clear free nat bitmap baf9275a4bbd f2fs: avoid opened loop codes in __add_ino_entry 47af6c72d944 f2fs: apply write hints to select the type of segments for buffered write ac9819160586 f2fs: introduce scan_curseg_cache for cleanup ca28e9670e80 f2fs: optimize the way of traversing free_nid_bitmap 460688b59e8b f2fs: keep scanning until enough free nids are acquired 0186182c0c4d f2fs: trace checkpoint reason in fsync() 5d4b6efcfd09 f2fs: keep isize once block is reserved cross EOF 3c8f767e1374 f2fs: avoid race in between GC and block exchange 4423778adf0e f2fs: save a multiplication for last_nid calculation 3e3b40557525 f2fs: fix summary info corruption 44889e487981 f2fs: remove dead code in update_meta_page 55c7b9595bb9 f2fs: remove unneeded semicolon 8b92814117d5 f2fs: don't bother with inode->i_version 42c7c71824fc f2fs: check curseg space before foreground GC c5470498e59b f2fs: use rw_semaphore to protect SIT cache 82750d346ab7 f2fs: support quota sys files 26dfec49b25a f2fs: add quota_ino feature infra ddb8e2ae9811 f2fs: optimize __update_nat_bits f46ae958c701 f2fs: modify for accurate fggc node io stat c713fdb5a23c Revert "f2fs: handle dirty segments inside refresh_sit_entry" 873ec505cb07 f2fs: add a function to move nid ae66786296b4 f2fs: export SSR allocation threshold 90c28a18d2a4 f2fs: give correct trimmed blocks in fstrim 5612922fb0ac f2fs: support bio allocation error injection 583b7a274c27 f2fs: support get_page error injection 09a073cc8c56 f2fs: add missing sysfs description e945474a9c1b f2fs: support soft block reservation b7b2e629b6f6 f2fs: handle error case when adding xattr entry 7368e30495c5 f2fs: support flexible inline xattr size ada4061e191b f2fs: show current cp state 5b8ff1301a61 f2fs: add missing quota_initialize 46d4a691f035 f2fs: show # of dirty segments via sysfs fc13f9d7ce1e f2fs: stop all the operations by cp_error flag 91bea0c391b3 f2fs: remove several redundant assignments 807486c79534 f2fs: avoid using timespec 03b1cb0bb4a2 f2fs: fix to correct no_fggc_candidate 5c15033ceaea Revert "f2fs: return wrong error number on f2fs_quota_write" 5f5f59322240 f2fs: remove obsolete pointer for truncate_xattr_node 032a6906825a f2fs: retry ENOMEM for quota_read|write 171b638fc49b f2fs: limit # of inmemory pages 83ed7a615f0a f2fs: update ctx->pos correctly when hitting hole in directory 4d6e68be2534 f2fs: relocate readahead codes in readdir() c8be47b54018 f2fs: allow readdir() to be interrupted 2b903fe94cd0 f2fs: trace f2fs_readdir bb0db666d4bc f2fs: trace f2fs_lookup 40d6250f046a f2fs: skip searching non-exist range in truncate_hole 8e84f379df61 f2fs: expose some sectors to user in inline data or dentry case cb98f70dea02 f2fs: avoid stale fi->gdirty_list pointer 5562a3c53963 f2fs/crypto: drop crypto key at evict_inode only 85853e7e38d7 f2fs: fix to avoid race when accessing last_disk_size 0c47a892d555 f2fs: Fix bool initialization/comparison 68e801abc520 f2fs: give up CP_TRIMMED_FLAG if it drops discards df74eacb2075 f2fs: trace f2fs_remove_discard bd502c6e3e7a f2fs: reduce cmd_lock coverage in __issue_discard_cmd a34ab5ca4f94 f2fs: split discard policy 1e65afd14d32 f2fs: wrap discard policy 684447dad138 f2fs: support issuing/waiting discard in range 27eaad09380f f2fs: fix to flush multiple device in checkpoint 08bb9d68d51b f2fs: enhance multiple device flush 9c2526ac2ecb f2fs: fix to show ino management cache size correctly 814b463d262f f2fs: drop FI_UPDATE_WRITE tag after f2fs_issue_flush f555b0a117d3 f2fs: obsolete ALLOC_NID_LIST list 75d3164ae128 f2fs: convert inline data for direct I/O & FI_NO_PREALLOC 4de0ceb6b7ef f2fs: allow readpages with NULL file pointer 322a45d17212 f2fs: show flush list status in sysfs 6d625a93b4a8 f2fs: introduce read_xattr_block 8ea6e1c327c5 f2fs: introduce read_inline_xattr dbce11e9ee5b Revert "f2fs: reuse nids more aggressively" 131bc9f6b7f9 Revert "f2fs: node segment is prior to data segment selected victim" Change-Id: I93b9cd867b859a667a448b39299ff44a2b841b8c Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-09-23 17:02:18 +08:00
/* 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 */
#define NIDS_PER_BLOCK 1018 /* Node IDs in an Indirect Block */
#define ADDRS_PER_PAGE(page, inode) \
(IS_INODE(page) ? ADDRS_PER_INODE(inode) : ADDRS_PER_BLOCK)
#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)
#define F2FS_INLINE_XATTR 0x01 /* file inline xattr flag */
#define F2FS_INLINE_DATA 0x02 /* file inline data flag */
#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 F2FS_EXTRA_ATTR 0x20 /* file having extra attribute */
f2fs: updates on v4.16-rc1 Pull f2fs updates from Jaegeuk Kim: "In this round, we've followed up to support some generic features such as cgroup, block reservation, linking fscrypt_ops, delivering write_hints, and some ioctls. And, we could fix some corner cases in terms of power-cut recovery and subtle deadlocks. Enhancements: - bitmap operations to handle NAT blocks - readahead to improve readdir speed - switch to use fscrypt_* - apply write hints for direct IO - add reserve_root=%u,resuid=%u,resgid=%u to reserve blocks for root/uid/gid - modify b_avail and b_free to consider root reserved blocks - support cgroup writeback - support FIEMAP_FLAG_XATTR for fibmap - add F2FS_IOC_PRECACHE_EXTENTS to pre-cache extents - add F2FS_IOC_{GET/SET}_PIN_FILE to pin LBAs for data blocks - support inode creation time Bug fixs: - sysfile-based quota operations - memory footprint accounting - allow to write data on partial preallocation case - fix deadlock case on fallocate - fix to handle fill_super errors - fix missing inode updates of fsync'ed file - recover renamed file which was fsycn'ed before - drop inmemory pages in corner error case - keep last_disk_size correctly - recover missing i_inline flags during roll-forward Various clean-up patches were added as well" Cherry-pick from origin/upstream-f2fs-stable-linux-4.4.y: 5f9b3abb911f f2fs: support inode creation time 9fb0de175172 f2fs: rebuild sit page from sit info in mem 1062a0c01829 f2fs: stop issuing discard if fs is readonly fa043fae9030 f2fs: clean up duplicated assignment in init_discard_policy b007190234d6 f2fs: use GFP_F2FS_ZERO for cleanup 35b11839a1ae f2fs: allow to recover node blocks given updated checkpoint e56500860be0 f2fs: recover some i_inline flags 64aa9569a1bf f2fs: correct removexattr behavior for null valued extended attribute 70b3a923daff f2fs: drop page cache after fs shutdown 8069a0e983d9 f2fs: stop gc/discard thread after fs shutdown bb924f777717 f2fs: hanlde error case in f2fs_ioc_shutdown 700b53f21ee8 f2fs: split need_inplace_update f31d52811c1f f2fs: fix to update last_disk_size correctly eeb0118b8340 f2fs: kill F2FS_INLINE_XATTR_ADDRS for cleanup c1b74c967092 f2fs: clean up error path of fill_super d5efd57e013b f2fs: avoid hungtask when GC encrypted block if io_bits is set c4027d08430b f2fs: allow quota to use reserved blocks 18d267c273a9 f2fs: fix to drop all inmem pages correctly 4dca47531eb0 f2fs: speed up defragment on sparse file 999f806a7c9e f2fs: support F2FS_IOC_PRECACHE_EXTENTS 84960fca96c4 f2fs: add an ioctl to disable GC for specific file 292c8e1cfd4d f2fs: prevent newly created inode from being dirtied incorrectly 58b1f5b0fcf1 f2fs: support FIEMAP_FLAG_XATTR 6afa9a94d09b f2fs: fix to cover f2fs_inline_data_fiemap with inode_lock 10f4a4140b61 f2fs: check node page again in write end io b203c58dfd55 f2fs: fix to caclulate required free section correctly d49132d45cb0 f2fs: handle newly created page when revoking inmem pages 2ce6b9d8167e f2fs: add resgid and resuid to reserve root blocks f53dcf6799ab f2fs: implement cgroup writeback support 1338f376d5a3 f2fs: remove unused pend_list_tag d4f19f6266ab f2fs: avoid high cpu usage in discard thread b78e9302e2e3 f2fs: make local functions static 62438ba87b79 f2fs: add reserved blocks for root user 06a366757ff7 f2fs: check segment type in __f2fs_replace_block 4c6bc4be375a f2fs: update inode info to inode page for new file 591b33638733 f2fs: show precise # of blocks that user/root can use b242d7edc537 f2fs: clean up unneeded declaration 87b8168e9ef0 f2fs: continue to do direct IO if we only preallocate partial blocks 2b4d859bd9d8 f2fs: enable quota at remount from r to w 54bf13a0adcd f2fs: skip stop_checkpoint for user data writes 25ef3006ba23 f2fs: fix missing error number for xattr operation cff2c7fe417b f2fs: recover directory operations by fsync e2bb618a0a6b f2fs: return error during fill_super 8a2c11d8658d f2fs: fix an error case of missing update inode page cd38d5ada5a4 f2fs: fix potential hangtask in f2fs_trace_pid e81cafbeba4b f2fs: no need return value in restore summary process 04d44000d633 f2fs: use unlikely for release case 925d0933d8f0 f2fs: don't return value in truncate_data_blocks_range f7986c416d1b f2fs: clean up f2fs_map_blocks e4f5e26cdadf f2fs: clean up hash codes 1f994d47080c f2fs: fix error handling in fill_super e7db649b5fb1 f2fs: spread f2fs_k{m,z}alloc 5d4e487b9929 f2fs: inject fault to kvmalloc 8b33886c37cd f2fs: inject fault to kzalloc d94680798786 f2fs: remove a redundant conditional expression 3bc01114a338 f2fs: apply write hints to select the type of segment for direct write c80f01959114 f2fs: switch to fscrypt_prepare_setattr() bb8b850365ff f2fs: switch to fscrypt_prepare_lookup() 9ab470eaf8a8 f2fs: switch to fscrypt_prepare_rename() aeaac517a12d f2fs: switch to fscrypt_prepare_link() 101c6a96ad1c f2fs: switch to fscrypt_file_open() 6d025237a1f8 f2fs: remove repeated f2fs_bug_on b01e03d724de f2fs: remove an excess variable e1f9be2f7c82 f2fs: fix lock dependency in between dio_rwsem & i_mmap_sem e5c7c8601030 f2fs: remove unused parameter f130dbb98a68 f2fs: still write data if preallocate only partial blocks 47ee9b259811 f2fs: introduce sysfs readdir_ra to readahead inode block in readdir 55e2f89181ce f2fs: fix concurrent problem for updating free bitmap e1398f6554b4 f2fs: remove unneeded memory footprint accounting 2d69561135f2 f2fs: no need to read nat block if nat_block_bitmap is set 4dd2d0733809 f2fs: reserve nid resource for quota sysfile Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-11-16 16:59:14 +08:00
#define F2FS_PIN_FILE 0x40 /* file should not be gced */
struct f2fs_inode {
__le16 i_mode; /* file mode */
__u8 i_advise; /* file hints */
__u8 i_inline; /* file inline flags */
__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) */
f2fs: updates on v4.16-rc1 Pull f2fs updates from Jaegeuk Kim: "In this round, we've followed up to support some generic features such as cgroup, block reservation, linking fscrypt_ops, delivering write_hints, and some ioctls. And, we could fix some corner cases in terms of power-cut recovery and subtle deadlocks. Enhancements: - bitmap operations to handle NAT blocks - readahead to improve readdir speed - switch to use fscrypt_* - apply write hints for direct IO - add reserve_root=%u,resuid=%u,resgid=%u to reserve blocks for root/uid/gid - modify b_avail and b_free to consider root reserved blocks - support cgroup writeback - support FIEMAP_FLAG_XATTR for fibmap - add F2FS_IOC_PRECACHE_EXTENTS to pre-cache extents - add F2FS_IOC_{GET/SET}_PIN_FILE to pin LBAs for data blocks - support inode creation time Bug fixs: - sysfile-based quota operations - memory footprint accounting - allow to write data on partial preallocation case - fix deadlock case on fallocate - fix to handle fill_super errors - fix missing inode updates of fsync'ed file - recover renamed file which was fsycn'ed before - drop inmemory pages in corner error case - keep last_disk_size correctly - recover missing i_inline flags during roll-forward Various clean-up patches were added as well" Cherry-pick from origin/upstream-f2fs-stable-linux-4.4.y: 5f9b3abb911f f2fs: support inode creation time 9fb0de175172 f2fs: rebuild sit page from sit info in mem 1062a0c01829 f2fs: stop issuing discard if fs is readonly fa043fae9030 f2fs: clean up duplicated assignment in init_discard_policy b007190234d6 f2fs: use GFP_F2FS_ZERO for cleanup 35b11839a1ae f2fs: allow to recover node blocks given updated checkpoint e56500860be0 f2fs: recover some i_inline flags 64aa9569a1bf f2fs: correct removexattr behavior for null valued extended attribute 70b3a923daff f2fs: drop page cache after fs shutdown 8069a0e983d9 f2fs: stop gc/discard thread after fs shutdown bb924f777717 f2fs: hanlde error case in f2fs_ioc_shutdown 700b53f21ee8 f2fs: split need_inplace_update f31d52811c1f f2fs: fix to update last_disk_size correctly eeb0118b8340 f2fs: kill F2FS_INLINE_XATTR_ADDRS for cleanup c1b74c967092 f2fs: clean up error path of fill_super d5efd57e013b f2fs: avoid hungtask when GC encrypted block if io_bits is set c4027d08430b f2fs: allow quota to use reserved blocks 18d267c273a9 f2fs: fix to drop all inmem pages correctly 4dca47531eb0 f2fs: speed up defragment on sparse file 999f806a7c9e f2fs: support F2FS_IOC_PRECACHE_EXTENTS 84960fca96c4 f2fs: add an ioctl to disable GC for specific file 292c8e1cfd4d f2fs: prevent newly created inode from being dirtied incorrectly 58b1f5b0fcf1 f2fs: support FIEMAP_FLAG_XATTR 6afa9a94d09b f2fs: fix to cover f2fs_inline_data_fiemap with inode_lock 10f4a4140b61 f2fs: check node page again in write end io b203c58dfd55 f2fs: fix to caclulate required free section correctly d49132d45cb0 f2fs: handle newly created page when revoking inmem pages 2ce6b9d8167e f2fs: add resgid and resuid to reserve root blocks f53dcf6799ab f2fs: implement cgroup writeback support 1338f376d5a3 f2fs: remove unused pend_list_tag d4f19f6266ab f2fs: avoid high cpu usage in discard thread b78e9302e2e3 f2fs: make local functions static 62438ba87b79 f2fs: add reserved blocks for root user 06a366757ff7 f2fs: check segment type in __f2fs_replace_block 4c6bc4be375a f2fs: update inode info to inode page for new file 591b33638733 f2fs: show precise # of blocks that user/root can use b242d7edc537 f2fs: clean up unneeded declaration 87b8168e9ef0 f2fs: continue to do direct IO if we only preallocate partial blocks 2b4d859bd9d8 f2fs: enable quota at remount from r to w 54bf13a0adcd f2fs: skip stop_checkpoint for user data writes 25ef3006ba23 f2fs: fix missing error number for xattr operation cff2c7fe417b f2fs: recover directory operations by fsync e2bb618a0a6b f2fs: return error during fill_super 8a2c11d8658d f2fs: fix an error case of missing update inode page cd38d5ada5a4 f2fs: fix potential hangtask in f2fs_trace_pid e81cafbeba4b f2fs: no need return value in restore summary process 04d44000d633 f2fs: use unlikely for release case 925d0933d8f0 f2fs: don't return value in truncate_data_blocks_range f7986c416d1b f2fs: clean up f2fs_map_blocks e4f5e26cdadf f2fs: clean up hash codes 1f994d47080c f2fs: fix error handling in fill_super e7db649b5fb1 f2fs: spread f2fs_k{m,z}alloc 5d4e487b9929 f2fs: inject fault to kvmalloc 8b33886c37cd f2fs: inject fault to kzalloc d94680798786 f2fs: remove a redundant conditional expression 3bc01114a338 f2fs: apply write hints to select the type of segment for direct write c80f01959114 f2fs: switch to fscrypt_prepare_setattr() bb8b850365ff f2fs: switch to fscrypt_prepare_lookup() 9ab470eaf8a8 f2fs: switch to fscrypt_prepare_rename() aeaac517a12d f2fs: switch to fscrypt_prepare_link() 101c6a96ad1c f2fs: switch to fscrypt_file_open() 6d025237a1f8 f2fs: remove repeated f2fs_bug_on b01e03d724de f2fs: remove an excess variable e1f9be2f7c82 f2fs: fix lock dependency in between dio_rwsem & i_mmap_sem e5c7c8601030 f2fs: remove unused parameter f130dbb98a68 f2fs: still write data if preallocate only partial blocks 47ee9b259811 f2fs: introduce sysfs readdir_ra to readahead inode block in readdir 55e2f89181ce f2fs: fix concurrent problem for updating free bitmap e1398f6554b4 f2fs: remove unneeded memory footprint accounting 2d69561135f2 f2fs: no need to read nat block if nat_block_bitmap is set 4dd2d0733809 f2fs: reserve nid resource for quota sysfile Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-11-16 16:59:14 +08:00
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 */
__le32 i_namelen; /* file name length */
__u8 i_name[F2FS_NAME_LEN]; /* file name for SPOR */
f2fs: introduce large directory support This patch introduces an i_dir_level field to support large directory. Previously, f2fs maintains multi-level hash tables to find a dentry quickly from a bunch of chiild dentries in a directory, and the hash tables consist of the following tree structure as below. In Documentation/filesystems/f2fs.txt, ---------------------- A : bucket B : block N : MAX_DIR_HASH_DEPTH ---------------------- level #0 | A(2B) | level #1 | A(2B) - A(2B) | level #2 | A(2B) - A(2B) - A(2B) - A(2B) . | . . . . level #N/2 | A(2B) - A(2B) - A(2B) - A(2B) - A(2B) - ... - A(2B) . | . . . . level #N | A(4B) - A(4B) - A(4B) - A(4B) - A(4B) - ... - A(4B) But, if we can guess that a directory will handle a number of child files, we don't need to traverse the tree from level #0 to #N all the time. Since the lower level tables contain relatively small number of dentries, the miss ratio of the target dentry is likely to be high. In order to avoid that, we can configure the hash tables sparsely from level #0 like this. level #0 | A(2B) - A(2B) - A(2B) - A(2B) level #1 | A(2B) - A(2B) - A(2B) - A(2B) - A(2B) - ... - A(2B) . | . . . . level #N/2 | A(2B) - A(2B) - A(2B) - A(2B) - A(2B) - ... - A(2B) . | . . . . level #N | A(4B) - A(4B) - A(4B) - A(4B) - A(4B) - ... - A(4B) With this structure, we can skip the ineffective tree searches in lower level hash tables. This patch adds just a facility for this by introducing i_dir_level in f2fs_inode. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-02-27 18:20:00 +09:00
__u8 i_dir_level; /* dentry_level for large dir */
struct f2fs_extent i_ext; /* caching a largest extent */
union {
struct {
__le16 i_extra_isize; /* extra inode attribute size */
f2fs: updates on 4.15-rc1 Pull f2fs updates from Jaegeuk Kim: "In this round, we introduce sysfile-based quota support which is required for Android by default. In addition, we allow that users are able to reserve some blocks in runtime to mitigate performance drops in low free space. Enhancements: - assign proper data segments according to write_hints given by user - issue cache_flush on dirty devices only among multiple devices - exploit cp_error flag and add more faults to enhance fault injection test - conduct more readaheads during f2fs_readdir - add a range for discard commands Bug fixes: - fix zero stat->st_blocks when inline_data is set - drop crypto key and free stale memory pointer while evict_inode is failing - fix some corner cases in free space and segment management - fix wrong last_disk_size This series includes lots of clean-ups and code enhancement in terms of xattr operations, discard/flush command control. In addition, it adds versatile debugfs entries to monitor f2fs status" Cherry-picked from origin/upstream-f2fs-stable-linux-4.4.y: 56a07b070510 f2fs: deny accessing encryption policy if encryption is off c394842e26e5 f2fs: inject fault in inc_valid_node_count 926292251022 f2fs: fix to clear FI_NO_PREALLOC e6cfc5de2d05 f2fs: expose quota information in debugfs c4cd2efe835b f2fs: separate nat entry mem alloc from nat_tree_lock 48c72b4c8c50 f2fs: validate before set/clear free nat bitmap baf9275a4bbd f2fs: avoid opened loop codes in __add_ino_entry 47af6c72d944 f2fs: apply write hints to select the type of segments for buffered write ac9819160586 f2fs: introduce scan_curseg_cache for cleanup ca28e9670e80 f2fs: optimize the way of traversing free_nid_bitmap 460688b59e8b f2fs: keep scanning until enough free nids are acquired 0186182c0c4d f2fs: trace checkpoint reason in fsync() 5d4b6efcfd09 f2fs: keep isize once block is reserved cross EOF 3c8f767e1374 f2fs: avoid race in between GC and block exchange 4423778adf0e f2fs: save a multiplication for last_nid calculation 3e3b40557525 f2fs: fix summary info corruption 44889e487981 f2fs: remove dead code in update_meta_page 55c7b9595bb9 f2fs: remove unneeded semicolon 8b92814117d5 f2fs: don't bother with inode->i_version 42c7c71824fc f2fs: check curseg space before foreground GC c5470498e59b f2fs: use rw_semaphore to protect SIT cache 82750d346ab7 f2fs: support quota sys files 26dfec49b25a f2fs: add quota_ino feature infra ddb8e2ae9811 f2fs: optimize __update_nat_bits f46ae958c701 f2fs: modify for accurate fggc node io stat c713fdb5a23c Revert "f2fs: handle dirty segments inside refresh_sit_entry" 873ec505cb07 f2fs: add a function to move nid ae66786296b4 f2fs: export SSR allocation threshold 90c28a18d2a4 f2fs: give correct trimmed blocks in fstrim 5612922fb0ac f2fs: support bio allocation error injection 583b7a274c27 f2fs: support get_page error injection 09a073cc8c56 f2fs: add missing sysfs description e945474a9c1b f2fs: support soft block reservation b7b2e629b6f6 f2fs: handle error case when adding xattr entry 7368e30495c5 f2fs: support flexible inline xattr size ada4061e191b f2fs: show current cp state 5b8ff1301a61 f2fs: add missing quota_initialize 46d4a691f035 f2fs: show # of dirty segments via sysfs fc13f9d7ce1e f2fs: stop all the operations by cp_error flag 91bea0c391b3 f2fs: remove several redundant assignments 807486c79534 f2fs: avoid using timespec 03b1cb0bb4a2 f2fs: fix to correct no_fggc_candidate 5c15033ceaea Revert "f2fs: return wrong error number on f2fs_quota_write" 5f5f59322240 f2fs: remove obsolete pointer for truncate_xattr_node 032a6906825a f2fs: retry ENOMEM for quota_read|write 171b638fc49b f2fs: limit # of inmemory pages 83ed7a615f0a f2fs: update ctx->pos correctly when hitting hole in directory 4d6e68be2534 f2fs: relocate readahead codes in readdir() c8be47b54018 f2fs: allow readdir() to be interrupted 2b903fe94cd0 f2fs: trace f2fs_readdir bb0db666d4bc f2fs: trace f2fs_lookup 40d6250f046a f2fs: skip searching non-exist range in truncate_hole 8e84f379df61 f2fs: expose some sectors to user in inline data or dentry case cb98f70dea02 f2fs: avoid stale fi->gdirty_list pointer 5562a3c53963 f2fs/crypto: drop crypto key at evict_inode only 85853e7e38d7 f2fs: fix to avoid race when accessing last_disk_size 0c47a892d555 f2fs: Fix bool initialization/comparison 68e801abc520 f2fs: give up CP_TRIMMED_FLAG if it drops discards df74eacb2075 f2fs: trace f2fs_remove_discard bd502c6e3e7a f2fs: reduce cmd_lock coverage in __issue_discard_cmd a34ab5ca4f94 f2fs: split discard policy 1e65afd14d32 f2fs: wrap discard policy 684447dad138 f2fs: support issuing/waiting discard in range 27eaad09380f f2fs: fix to flush multiple device in checkpoint 08bb9d68d51b f2fs: enhance multiple device flush 9c2526ac2ecb f2fs: fix to show ino management cache size correctly 814b463d262f f2fs: drop FI_UPDATE_WRITE tag after f2fs_issue_flush f555b0a117d3 f2fs: obsolete ALLOC_NID_LIST list 75d3164ae128 f2fs: convert inline data for direct I/O & FI_NO_PREALLOC 4de0ceb6b7ef f2fs: allow readpages with NULL file pointer 322a45d17212 f2fs: show flush list status in sysfs 6d625a93b4a8 f2fs: introduce read_xattr_block 8ea6e1c327c5 f2fs: introduce read_inline_xattr dbce11e9ee5b Revert "f2fs: reuse nids more aggressively" 131bc9f6b7f9 Revert "f2fs: node segment is prior to data segment selected victim" Change-Id: I93b9cd867b859a667a448b39299ff44a2b841b8c Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-09-23 17:02:18 +08:00
__le16 i_inline_xattr_size; /* inline xattr size, unit: 4 bytes */
__le32 i_projid; /* project id */
__le32 i_inode_checksum;/* inode meta checksum */
f2fs: updates on v4.16-rc1 Pull f2fs updates from Jaegeuk Kim: "In this round, we've followed up to support some generic features such as cgroup, block reservation, linking fscrypt_ops, delivering write_hints, and some ioctls. And, we could fix some corner cases in terms of power-cut recovery and subtle deadlocks. Enhancements: - bitmap operations to handle NAT blocks - readahead to improve readdir speed - switch to use fscrypt_* - apply write hints for direct IO - add reserve_root=%u,resuid=%u,resgid=%u to reserve blocks for root/uid/gid - modify b_avail and b_free to consider root reserved blocks - support cgroup writeback - support FIEMAP_FLAG_XATTR for fibmap - add F2FS_IOC_PRECACHE_EXTENTS to pre-cache extents - add F2FS_IOC_{GET/SET}_PIN_FILE to pin LBAs for data blocks - support inode creation time Bug fixs: - sysfile-based quota operations - memory footprint accounting - allow to write data on partial preallocation case - fix deadlock case on fallocate - fix to handle fill_super errors - fix missing inode updates of fsync'ed file - recover renamed file which was fsycn'ed before - drop inmemory pages in corner error case - keep last_disk_size correctly - recover missing i_inline flags during roll-forward Various clean-up patches were added as well" Cherry-pick from origin/upstream-f2fs-stable-linux-4.4.y: 5f9b3abb911f f2fs: support inode creation time 9fb0de175172 f2fs: rebuild sit page from sit info in mem 1062a0c01829 f2fs: stop issuing discard if fs is readonly fa043fae9030 f2fs: clean up duplicated assignment in init_discard_policy b007190234d6 f2fs: use GFP_F2FS_ZERO for cleanup 35b11839a1ae f2fs: allow to recover node blocks given updated checkpoint e56500860be0 f2fs: recover some i_inline flags 64aa9569a1bf f2fs: correct removexattr behavior for null valued extended attribute 70b3a923daff f2fs: drop page cache after fs shutdown 8069a0e983d9 f2fs: stop gc/discard thread after fs shutdown bb924f777717 f2fs: hanlde error case in f2fs_ioc_shutdown 700b53f21ee8 f2fs: split need_inplace_update f31d52811c1f f2fs: fix to update last_disk_size correctly eeb0118b8340 f2fs: kill F2FS_INLINE_XATTR_ADDRS for cleanup c1b74c967092 f2fs: clean up error path of fill_super d5efd57e013b f2fs: avoid hungtask when GC encrypted block if io_bits is set c4027d08430b f2fs: allow quota to use reserved blocks 18d267c273a9 f2fs: fix to drop all inmem pages correctly 4dca47531eb0 f2fs: speed up defragment on sparse file 999f806a7c9e f2fs: support F2FS_IOC_PRECACHE_EXTENTS 84960fca96c4 f2fs: add an ioctl to disable GC for specific file 292c8e1cfd4d f2fs: prevent newly created inode from being dirtied incorrectly 58b1f5b0fcf1 f2fs: support FIEMAP_FLAG_XATTR 6afa9a94d09b f2fs: fix to cover f2fs_inline_data_fiemap with inode_lock 10f4a4140b61 f2fs: check node page again in write end io b203c58dfd55 f2fs: fix to caclulate required free section correctly d49132d45cb0 f2fs: handle newly created page when revoking inmem pages 2ce6b9d8167e f2fs: add resgid and resuid to reserve root blocks f53dcf6799ab f2fs: implement cgroup writeback support 1338f376d5a3 f2fs: remove unused pend_list_tag d4f19f6266ab f2fs: avoid high cpu usage in discard thread b78e9302e2e3 f2fs: make local functions static 62438ba87b79 f2fs: add reserved blocks for root user 06a366757ff7 f2fs: check segment type in __f2fs_replace_block 4c6bc4be375a f2fs: update inode info to inode page for new file 591b33638733 f2fs: show precise # of blocks that user/root can use b242d7edc537 f2fs: clean up unneeded declaration 87b8168e9ef0 f2fs: continue to do direct IO if we only preallocate partial blocks 2b4d859bd9d8 f2fs: enable quota at remount from r to w 54bf13a0adcd f2fs: skip stop_checkpoint for user data writes 25ef3006ba23 f2fs: fix missing error number for xattr operation cff2c7fe417b f2fs: recover directory operations by fsync e2bb618a0a6b f2fs: return error during fill_super 8a2c11d8658d f2fs: fix an error case of missing update inode page cd38d5ada5a4 f2fs: fix potential hangtask in f2fs_trace_pid e81cafbeba4b f2fs: no need return value in restore summary process 04d44000d633 f2fs: use unlikely for release case 925d0933d8f0 f2fs: don't return value in truncate_data_blocks_range f7986c416d1b f2fs: clean up f2fs_map_blocks e4f5e26cdadf f2fs: clean up hash codes 1f994d47080c f2fs: fix error handling in fill_super e7db649b5fb1 f2fs: spread f2fs_k{m,z}alloc 5d4e487b9929 f2fs: inject fault to kvmalloc 8b33886c37cd f2fs: inject fault to kzalloc d94680798786 f2fs: remove a redundant conditional expression 3bc01114a338 f2fs: apply write hints to select the type of segment for direct write c80f01959114 f2fs: switch to fscrypt_prepare_setattr() bb8b850365ff f2fs: switch to fscrypt_prepare_lookup() 9ab470eaf8a8 f2fs: switch to fscrypt_prepare_rename() aeaac517a12d f2fs: switch to fscrypt_prepare_link() 101c6a96ad1c f2fs: switch to fscrypt_file_open() 6d025237a1f8 f2fs: remove repeated f2fs_bug_on b01e03d724de f2fs: remove an excess variable e1f9be2f7c82 f2fs: fix lock dependency in between dio_rwsem & i_mmap_sem e5c7c8601030 f2fs: remove unused parameter f130dbb98a68 f2fs: still write data if preallocate only partial blocks 47ee9b259811 f2fs: introduce sysfs readdir_ra to readahead inode block in readdir 55e2f89181ce f2fs: fix concurrent problem for updating free bitmap e1398f6554b4 f2fs: remove unneeded memory footprint accounting 2d69561135f2 f2fs: no need to read nat block if nat_block_bitmap is set 4dd2d0733809 f2fs: reserve nid resource for quota sysfile Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-11-16 16:59:14 +08:00
__le64 i_crtime; /* creation time */
__le32 i_crtime_nsec; /* creation time in nano scale */
__le32 i_extra_end[0]; /* for attribute size calculation */
f2fs: updates on v4.16-rc1 Pull f2fs updates from Jaegeuk Kim: "In this round, we've followed up to support some generic features such as cgroup, block reservation, linking fscrypt_ops, delivering write_hints, and some ioctls. And, we could fix some corner cases in terms of power-cut recovery and subtle deadlocks. Enhancements: - bitmap operations to handle NAT blocks - readahead to improve readdir speed - switch to use fscrypt_* - apply write hints for direct IO - add reserve_root=%u,resuid=%u,resgid=%u to reserve blocks for root/uid/gid - modify b_avail and b_free to consider root reserved blocks - support cgroup writeback - support FIEMAP_FLAG_XATTR for fibmap - add F2FS_IOC_PRECACHE_EXTENTS to pre-cache extents - add F2FS_IOC_{GET/SET}_PIN_FILE to pin LBAs for data blocks - support inode creation time Bug fixs: - sysfile-based quota operations - memory footprint accounting - allow to write data on partial preallocation case - fix deadlock case on fallocate - fix to handle fill_super errors - fix missing inode updates of fsync'ed file - recover renamed file which was fsycn'ed before - drop inmemory pages in corner error case - keep last_disk_size correctly - recover missing i_inline flags during roll-forward Various clean-up patches were added as well" Cherry-pick from origin/upstream-f2fs-stable-linux-4.4.y: 5f9b3abb911f f2fs: support inode creation time 9fb0de175172 f2fs: rebuild sit page from sit info in mem 1062a0c01829 f2fs: stop issuing discard if fs is readonly fa043fae9030 f2fs: clean up duplicated assignment in init_discard_policy b007190234d6 f2fs: use GFP_F2FS_ZERO for cleanup 35b11839a1ae f2fs: allow to recover node blocks given updated checkpoint e56500860be0 f2fs: recover some i_inline flags 64aa9569a1bf f2fs: correct removexattr behavior for null valued extended attribute 70b3a923daff f2fs: drop page cache after fs shutdown 8069a0e983d9 f2fs: stop gc/discard thread after fs shutdown bb924f777717 f2fs: hanlde error case in f2fs_ioc_shutdown 700b53f21ee8 f2fs: split need_inplace_update f31d52811c1f f2fs: fix to update last_disk_size correctly eeb0118b8340 f2fs: kill F2FS_INLINE_XATTR_ADDRS for cleanup c1b74c967092 f2fs: clean up error path of fill_super d5efd57e013b f2fs: avoid hungtask when GC encrypted block if io_bits is set c4027d08430b f2fs: allow quota to use reserved blocks 18d267c273a9 f2fs: fix to drop all inmem pages correctly 4dca47531eb0 f2fs: speed up defragment on sparse file 999f806a7c9e f2fs: support F2FS_IOC_PRECACHE_EXTENTS 84960fca96c4 f2fs: add an ioctl to disable GC for specific file 292c8e1cfd4d f2fs: prevent newly created inode from being dirtied incorrectly 58b1f5b0fcf1 f2fs: support FIEMAP_FLAG_XATTR 6afa9a94d09b f2fs: fix to cover f2fs_inline_data_fiemap with inode_lock 10f4a4140b61 f2fs: check node page again in write end io b203c58dfd55 f2fs: fix to caclulate required free section correctly d49132d45cb0 f2fs: handle newly created page when revoking inmem pages 2ce6b9d8167e f2fs: add resgid and resuid to reserve root blocks f53dcf6799ab f2fs: implement cgroup writeback support 1338f376d5a3 f2fs: remove unused pend_list_tag d4f19f6266ab f2fs: avoid high cpu usage in discard thread b78e9302e2e3 f2fs: make local functions static 62438ba87b79 f2fs: add reserved blocks for root user 06a366757ff7 f2fs: check segment type in __f2fs_replace_block 4c6bc4be375a f2fs: update inode info to inode page for new file 591b33638733 f2fs: show precise # of blocks that user/root can use b242d7edc537 f2fs: clean up unneeded declaration 87b8168e9ef0 f2fs: continue to do direct IO if we only preallocate partial blocks 2b4d859bd9d8 f2fs: enable quota at remount from r to w 54bf13a0adcd f2fs: skip stop_checkpoint for user data writes 25ef3006ba23 f2fs: fix missing error number for xattr operation cff2c7fe417b f2fs: recover directory operations by fsync e2bb618a0a6b f2fs: return error during fill_super 8a2c11d8658d f2fs: fix an error case of missing update inode page cd38d5ada5a4 f2fs: fix potential hangtask in f2fs_trace_pid e81cafbeba4b f2fs: no need return value in restore summary process 04d44000d633 f2fs: use unlikely for release case 925d0933d8f0 f2fs: don't return value in truncate_data_blocks_range f7986c416d1b f2fs: clean up f2fs_map_blocks e4f5e26cdadf f2fs: clean up hash codes 1f994d47080c f2fs: fix error handling in fill_super e7db649b5fb1 f2fs: spread f2fs_k{m,z}alloc 5d4e487b9929 f2fs: inject fault to kvmalloc 8b33886c37cd f2fs: inject fault to kzalloc d94680798786 f2fs: remove a redundant conditional expression 3bc01114a338 f2fs: apply write hints to select the type of segment for direct write c80f01959114 f2fs: switch to fscrypt_prepare_setattr() bb8b850365ff f2fs: switch to fscrypt_prepare_lookup() 9ab470eaf8a8 f2fs: switch to fscrypt_prepare_rename() aeaac517a12d f2fs: switch to fscrypt_prepare_link() 101c6a96ad1c f2fs: switch to fscrypt_file_open() 6d025237a1f8 f2fs: remove repeated f2fs_bug_on b01e03d724de f2fs: remove an excess variable e1f9be2f7c82 f2fs: fix lock dependency in between dio_rwsem & i_mmap_sem e5c7c8601030 f2fs: remove unused parameter f130dbb98a68 f2fs: still write data if preallocate only partial blocks 47ee9b259811 f2fs: introduce sysfs readdir_ra to readahead inode block in readdir 55e2f89181ce f2fs: fix concurrent problem for updating free bitmap e1398f6554b4 f2fs: remove unneeded memory footprint accounting 2d69561135f2 f2fs: no need to read nat block if nat_block_bitmap is set 4dd2d0733809 f2fs: reserve nid resource for quota sysfile Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-11-16 16:59:14 +08:00
} __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;
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
};
#define OFFSET_BIT_MASK (0x07) /* (0x01 << OFFSET_BIT_SHIFT) - 1 */
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
*/
#define NAT_ENTRY_PER_BLOCK (PAGE_SIZE / sizeof(struct f2fs_nat_entry))
#define NAT_ENTRY_BITMAP_SIZE ((NAT_ENTRY_PER_BLOCK + 7) / 8)
f2fs/fscrypt: updates to v4.17-rc1 Pull f2fs update from Jaegeuk Kim: "In this round, we've mainly focused on performance tuning and critical bug fixes occurred in low-end devices. Sheng Yong introduced lost_found feature to keep missing files during recovery instead of thrashing them. We're preparing coming fsverity implementation. And, we've got more features to communicate with users for better performance. In low-end devices, some memory-related issues were fixed, and subtle race condtions and corner cases were addressed as well. Enhancements: - large nat bitmaps for more free node ids - add three block allocation policies to pass down write hints given by user - expose extension list to user and introduce hot file extension - tune small devices seamlessly for low-end devices - set readdir_ra by default - give more resources under gc_urgent mode regarding to discard and cleaning - introduce fsync_mode to enforce posix or not - nowait aio support - add lost_found feature to keep dangling inodes - reserve bits for future fsverity feature - add test_dummy_encryption for FBE Bug fixes: - don't use highmem for dentry pages - align memory boundary for bitops - truncate preallocated blocks in write errors - guarantee i_times on fsync call - clear CP_TRIMMED_FLAG correctly - prevent node chain loop during recovery - avoid data race between atomic write and background cleaning - avoid unnecessary selinux violation warnings on resgid option - GFP_NOFS to avoid deadlock in quota and read paths - fix f2fs_skip_inode_update to allow i_size recovery In addition to the above, there are several minor bug fixes and clean-ups" Cherry-pick from origin/upstream-f2fs-stable-linux-4.4.y: 42bf67fc543b f2fs: remain written times to update inode during fsync 6cb5aa02bfbd f2fs: make assignment of t->dentry_bitmap more readable a8d07f1f9c62 f2fs: truncate preallocated blocks in error case 86444d600692 f2fs: fix a wrong condition in f2fs_skip_inode_update db2188a68704 f2fs: reserve bits for fs-verity ee2e74b3f00e f2fs: Add a segment type check in inplace write 0192e0a4502f f2fs: no need to initialize zero value for GFP_F2FS_ZERO 49338842e9b2 f2fs: don't track new nat entry in nat set d6a69d5e6568 f2fs: clean up with F2FS_BLK_ALIGN 2c8834a7a2c9 f2fs: check blkaddr more accuratly before issue a bio 6ab573a9d96f f2fs: Set GF_NOFS in read_cache_page_gfp while doing f2fs_quota_read 7419dcb8be02 f2fs: introduce a new mount option test_dummy_encryption 9321e22c038c f2fs: introduce F2FS_FEATURE_LOST_FOUND feature 8a5719615847 f2fs: release locks before return in f2fs_ioc_gc_range() 739ace131cdf f2fs: align memory boundary for bitops 4c55abe4f8d2 f2fs: remove unneeded set_cold_node() 30654507e0a2 f2fs: add nowait aio support d909e9410634 f2fs: wrap all options with f2fs_sb_info.mount_opt 5738be52b3e8 f2fs: Don't overwrite all types of node to keep node chain 0bdeb167c843 f2fs: introduce mount option for fsync mode 6bc490f0eedc f2fs: fix to restore old mount option in ->remount_fs 0c9c3e034410 f2fs: wrap sb_rdonly with f2fs_readonly 6c6611223a79 f2fs: avoid selinux denial on CAP_SYS_RESOURCE 076a6f32fe5d f2fs: support hot file extension 58edcdbca67a f2fs: fix to avoid race in between atomic write and background GC 1e0aeb0af9ed f2fs: do gc in greedy mode for whole range if gc_urgent mode is set 10b2d001d6ac f2fs: issue discard aggressively in the gc_urgent mode a5052f32b940 f2fs: set readdir_ra by default 1aa536a624cc f2fs: add auto tuning for small devices 0ffdffc8f106 f2fs: add mount option for segment allocation policy b79829891249 f2fs: don't stop GC if GC is contended 766d2321697f f2fs: expose extension_list sysfs entry 98b329de5026 f2fs: fix to set KEEP_SIZE bit in f2fs_zero_range 4d409fa3346b f2fs: introduce sb_lock to make encrypt pwsalt update exclusive 1f6bac14c100 f2fs: remove redundant initialization of pointer 'p' 946aefc7545d f2fs: flush cp pack except cp pack 2 page at first e5081a52ac09 f2fs: clean up f2fs_sb_has_xxx functions a292477154b5 f2fs: remove redundant check of page type when submit bio 190e64a819df f2fs: fix to handle looped node chain during recovery 889d98087652 f2fs: handle quota for orphan inodes 92b12bb1a23e f2fs: support passing down write hints to block layer with F2FS policy 22fa74c2b097 f2fs: support passing down write hints given by users to block layer 180900373ec1 f2fs: fix to clear CP_TRIMMED_FLAG 0671fae134bb f2fs: support large nat bitmap eceb943d5d59 f2fs: fix to check extent cache in f2fs_drop_extent_tree 2e2a339c9853 f2fs: restrict inline_xattr_size configuration 41dda1164137 f2fs: fix heap mode to reset it back 39575737bb62 f2fs: fix potential corruption in area before F2FS_SUPER_OFFSET 7e0e7995ee97 fscrypt: fix build with pre-4.6 gcc versions 31d3279a4fca fscrypt: fix up fscrypt_fname_encrypted_size() for internal use 82bec888567b fscrypt: define fscrypt_fname_alloc_buffer() to be for presented names 168a90782888 fscrypt: calculate NUL-padding length in one place only 042ae9f4cfbf fscrypt: move fscrypt_symlink_data to fscrypt_private.h f9550c24c20e fscrypt: remove fscrypt_fname_usr_to_disk() 7ac4756a2474 f2fs: switch to fscrypt_get_symlink() 6b76f58e24bd f2fs: switch to fscrypt ->symlink() helper functions fd457d2c4e04 fscrypt: new helper function - fscrypt_get_symlink() a1cdacb7ae0d fscrypt: new helper functions for ->symlink() 7f43602f4d10 fscrypt: trim down fscrypt.h includes d9cadc11bdcf fscrypt: move fscrypt_is_dot_dotdot() to fs/crypto/fname.c e6fe930580cb fscrypt: move fscrypt_valid_enc_modes() to fscrypt_private.h efefa434f47e fscrypt: move fscrypt_operations declaration to fscrypt_supp.h 7ed178bc8ae9 fscrypt: split fscrypt_dummy_context_enabled() into supp/notsupp versions 3f16e09dadfb fscrypt: move fscrypt_ctx declaration to fscrypt_supp.h 8216a0b51a3b fscrypt: move fscrypt_info_cachep declaration to fscrypt_private.h dfe0b3b1b67f fscrypt: move fscrypt_control_page() to supp/notsupp headers 3a2c79177822 fscrypt: move fscrypt_has_encryption_key() to supp/notsupp headers Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-01-05 10:44:52 -08:00
#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 */
__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
#define SIT_ENTRY_PER_BLOCK (PAGE_SIZE / sizeof(struct f2fs_sit_entry))
/*
* F2FS uses 4 bytes to represent block address. As a result, supported size of
* disk is 16 TB and it equals to 16 * 1024 * 1024 / 2 segments.
*/
#define F2FS_MAX_SEGMENT ((16 * 1024 * 1024) / 2)
/*
* 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
#define SUMMARY_SIZE (7) /* sizeof(struct summary) */
#define SUM_FOOTER_SIZE (5) /* sizeof(struct summary_footer) */
#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 */
__le32 check_sum; /* summary checksum */
} __packed;
#define SUM_JOURNAL_SIZE (F2FS_BLKSIZE - SUM_FOOTER_SIZE -\
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))
/* 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)
/*
* 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;
struct f2fs_extra_info {
__le64 kbytes_written;
__u8 reserved[EXTRA_INFO_RESERVED];
} __packed;
struct f2fs_journal {
union {
__le16 n_nats;
__le16 n_sits;
};
/* spare area is used by NAT or SIT journals or extra info */
union {
struct nat_journal nat_j;
struct sit_journal sit_j;
struct f2fs_extra_info info;
};
} __packed;
/* 4KB-sized summary block structure */
struct f2fs_summary_block {
struct f2fs_summary entries[ENTRIES_IN_SUM];
struct f2fs_journal journal;
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 */
#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)
/* MAX level for dir lookup */
#define MAX_DIR_HASH_DEPTH 63
/* MAX buckets in one level of dir */
#define MAX_DIR_BUCKETS (1 << ((MAX_DIR_HASH_DEPTH / 2) - 1))
/*
* 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
* 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 */
#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 + \
F2FS_SLOT_LEN) * \
NR_DENTRY_IN_BLOCK + SIZE_OF_DENTRY_BITMAP))
/* One directory entry slot representing F2FS_SLOT_LEN-sized file name */
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];
__u8 filename[NR_DENTRY_IN_BLOCK][F2FS_SLOT_LEN];
} __packed;
/* 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
};
#define S_SHIFT 12
#define F2FS_DEF_PROJID 0 /* default project ID */
#endif /* _LINUX_F2FS_FS_H */