f2fs.h (a8253684eb4b30abd3faf055bc475c23da748dc6) f2fs.h (d98af5f4552058a5c22030641ef79cee92c61f54)
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * fs/f2fs/f2fs.h
4 *
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * http://www.samsung.com/
7 */
8#ifndef _LINUX_F2FS_H

--- 109 unchanged lines hidden (view full) ---

118typedef u32 block_t; /*
119 * should not change u32, since it is the on-disk block
120 * address format, __le32.
121 */
122typedef u32 nid_t;
123
124#define COMPRESS_EXT_NUM 16
125
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * fs/f2fs/f2fs.h
4 *
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * http://www.samsung.com/
7 */
8#ifndef _LINUX_F2FS_H

--- 109 unchanged lines hidden (view full) ---

118typedef u32 block_t; /*
119 * should not change u32, since it is the on-disk block
120 * address format, __le32.
121 */
122typedef u32 nid_t;
123
124#define COMPRESS_EXT_NUM 16
125
126/*
127 * An implementation of an rwsem that is explicitly unfair to readers. This
128 * prevents priority inversion when a low-priority reader acquires the read lock
129 * while sleeping on the write lock but the write lock is needed by
130 * higher-priority clients.
131 */
132
133struct f2fs_rwsem {
134 struct rw_semaphore internal_rwsem;
135#ifdef CONFIG_F2FS_UNFAIR_RWSEM
136 wait_queue_head_t read_waiters;
137#endif
138};
139
126struct f2fs_mount_info {
127 unsigned int opt;
128 int write_io_size_bits; /* Write IO size bits */
129 block_t root_reserved_blocks; /* root reserved blocks */
130 kuid_t s_resuid; /* reserved blocks for uid */
131 kgid_t s_resgid; /* reserved blocks for gid */
132 int active_logs; /* # of active logs */
133 int inline_xattr_size; /* inline xattr size */

--- 247 unchanged lines hidden (view full) ---

381 struct list_head pend_list[MAX_PLIST_NUM];/* store pending entries */
382 struct list_head wait_list; /* store on-flushing entries */
383 struct list_head fstrim_list; /* in-flight discard from fstrim */
384 wait_queue_head_t discard_wait_queue; /* waiting queue for wake-up */
385 unsigned int discard_wake; /* to wake up discard thread */
386 struct mutex cmd_lock;
387 unsigned int nr_discards; /* # of discards in the list */
388 unsigned int max_discards; /* max. discards to be issued */
140struct f2fs_mount_info {
141 unsigned int opt;
142 int write_io_size_bits; /* Write IO size bits */
143 block_t root_reserved_blocks; /* root reserved blocks */
144 kuid_t s_resuid; /* reserved blocks for uid */
145 kgid_t s_resgid; /* reserved blocks for gid */
146 int active_logs; /* # of active logs */
147 int inline_xattr_size; /* inline xattr size */

--- 247 unchanged lines hidden (view full) ---

395 struct list_head pend_list[MAX_PLIST_NUM];/* store pending entries */
396 struct list_head wait_list; /* store on-flushing entries */
397 struct list_head fstrim_list; /* in-flight discard from fstrim */
398 wait_queue_head_t discard_wait_queue; /* waiting queue for wake-up */
399 unsigned int discard_wake; /* to wake up discard thread */
400 struct mutex cmd_lock;
401 unsigned int nr_discards; /* # of discards in the list */
402 unsigned int max_discards; /* max. discards to be issued */
403 unsigned int max_discard_request; /* max. discard request per round */
404 unsigned int min_discard_issue_time; /* min. interval between discard issue */
405 unsigned int mid_discard_issue_time; /* mid. interval between discard issue */
406 unsigned int max_discard_issue_time; /* max. interval between discard issue */
389 unsigned int discard_granularity; /* discard granularity */
390 unsigned int undiscard_blks; /* # of undiscard blocks */
391 unsigned int next_pos; /* next discard position */
392 atomic_t issued_discard; /* # of issued discard */
393 atomic_t queued_discard; /* # of queued discard */
394 atomic_t discard_cmd_cnt; /* # of cached cmd count */
395 struct rb_root_cached root; /* root of discard rb-tree */
396 bool rbtree_check; /* config for consistence check */

--- 86 unchanged lines hidden (view full) ---

483
484#ifdef CONFIG_FS_ENCRYPTION
485 /*
486 * For lookups in encrypted directories: either the buffer backing
487 * disk_name, or a buffer that holds the decoded no-key name.
488 */
489 struct fscrypt_str crypto_buf;
490#endif
407 unsigned int discard_granularity; /* discard granularity */
408 unsigned int undiscard_blks; /* # of undiscard blocks */
409 unsigned int next_pos; /* next discard position */
410 atomic_t issued_discard; /* # of issued discard */
411 atomic_t queued_discard; /* # of queued discard */
412 atomic_t discard_cmd_cnt; /* # of cached cmd count */
413 struct rb_root_cached root; /* root of discard rb-tree */
414 bool rbtree_check; /* config for consistence check */

--- 86 unchanged lines hidden (view full) ---

501
502#ifdef CONFIG_FS_ENCRYPTION
503 /*
504 * For lookups in encrypted directories: either the buffer backing
505 * disk_name, or a buffer that holds the decoded no-key name.
506 */
507 struct fscrypt_str crypto_buf;
508#endif
491#if IS_ENABLED(CONFIG_UNICODE)
509#ifdef CONFIG_UNICODE
492 /*
493 * For casefolded directories: the casefolded name, but it's left NULL
494 * if the original name is not valid Unicode, if the directory is both
495 * casefolded and encrypted and its encryption key is unavailable, or if
496 * the filesystem is doing an internal operation where usr_fname is also
497 * NULL. In all these cases we fall back to treating the name as an
498 * opaque byte sequence.
499 */

--- 56 unchanged lines hidden (view full) ---

556#define DEFAULT_RETRY_IO_COUNT 8 /* maximum retry read IO or flush count */
557
558/* congestion wait timeout value, default: 20ms */
559#define DEFAULT_IO_TIMEOUT (msecs_to_jiffies(20))
560
561/* maximum retry quota flush count */
562#define DEFAULT_RETRY_QUOTA_FLUSH_COUNT 8
563
510 /*
511 * For casefolded directories: the casefolded name, but it's left NULL
512 * if the original name is not valid Unicode, if the directory is both
513 * casefolded and encrypted and its encryption key is unavailable, or if
514 * the filesystem is doing an internal operation where usr_fname is also
515 * NULL. In all these cases we fall back to treating the name as an
516 * opaque byte sequence.
517 */

--- 56 unchanged lines hidden (view full) ---

574#define DEFAULT_RETRY_IO_COUNT 8 /* maximum retry read IO or flush count */
575
576/* congestion wait timeout value, default: 20ms */
577#define DEFAULT_IO_TIMEOUT (msecs_to_jiffies(20))
578
579/* maximum retry quota flush count */
580#define DEFAULT_RETRY_QUOTA_FLUSH_COUNT 8
581
582/* maximum retry of EIO'ed meta page */
583#define MAX_RETRY_META_PAGE_EIO 100
584
564#define F2FS_LINK_MAX 0xffffffff /* maximum link count per file */
565
566#define MAX_DIR_RA_PAGES 4 /* maximum ra pages of dir */
567
568/* dirty segments threshold for triggering CP */
569#define DEFAULT_DIRTY_THRESHOLD 4
570
571/* for in-memory extent cache entry */
572#define F2FS_MIN_EXTENT_LEN 64 /* minimum extent length */
573
574/* number of extent info in extent cache we try to shrink */
575#define EXTENT_CACHE_SHRINK_NUMBER 128
576
585#define F2FS_LINK_MAX 0xffffffff /* maximum link count per file */
586
587#define MAX_DIR_RA_PAGES 4 /* maximum ra pages of dir */
588
589/* dirty segments threshold for triggering CP */
590#define DEFAULT_DIRTY_THRESHOLD 4
591
592/* for in-memory extent cache entry */
593#define F2FS_MIN_EXTENT_LEN 64 /* minimum extent length */
594
595/* number of extent info in extent cache we try to shrink */
596#define EXTENT_CACHE_SHRINK_NUMBER 128
597
598#define RECOVERY_MAX_RA_BLOCKS BIO_MAX_VECS
599#define RECOVERY_MIN_RA_BLOCKS 1
600
577struct rb_entry {
578 struct rb_node rb_node; /* rb node located in rb-tree */
579 union {
580 struct {
581 unsigned int ofs; /* start offset of the entry */
582 unsigned int len; /* length of the entry */
583 };
584 unsigned long long key; /* 64-bits key */

--- 131 unchanged lines hidden (view full) ---

716 FI_NEED_IPU, /* used for ipu per file */
717 FI_ATOMIC_FILE, /* indicate atomic file */
718 FI_ATOMIC_COMMIT, /* indicate the state of atomical committing */
719 FI_VOLATILE_FILE, /* indicate volatile file */
720 FI_FIRST_BLOCK_WRITTEN, /* indicate #0 data block was written */
721 FI_DROP_CACHE, /* drop dirty page cache */
722 FI_DATA_EXIST, /* indicate data exists */
723 FI_INLINE_DOTS, /* indicate inline dot dentries */
601struct rb_entry {
602 struct rb_node rb_node; /* rb node located in rb-tree */
603 union {
604 struct {
605 unsigned int ofs; /* start offset of the entry */
606 unsigned int len; /* length of the entry */
607 };
608 unsigned long long key; /* 64-bits key */

--- 131 unchanged lines hidden (view full) ---

740 FI_NEED_IPU, /* used for ipu per file */
741 FI_ATOMIC_FILE, /* indicate atomic file */
742 FI_ATOMIC_COMMIT, /* indicate the state of atomical committing */
743 FI_VOLATILE_FILE, /* indicate volatile file */
744 FI_FIRST_BLOCK_WRITTEN, /* indicate #0 data block was written */
745 FI_DROP_CACHE, /* drop dirty page cache */
746 FI_DATA_EXIST, /* indicate data exists */
747 FI_INLINE_DOTS, /* indicate inline dot dentries */
724 FI_DO_DEFRAG, /* indicate defragment is running */
748 FI_SKIP_WRITES, /* should skip data page writeback */
749 FI_OPU_WRITE, /* used for opu per file */
725 FI_DIRTY_FILE, /* indicate regular/symlink has dirty pages */
726 FI_PREALLOCATED_ALL, /* all blocks for write were preallocated */
727 FI_HOT_DATA, /* indicate file is hot */
728 FI_EXTRA_ATTR, /* indicate file has extra attribute */
729 FI_PROJ_INHERIT, /* indicate file inherits projectid */
730 FI_PIN_FILE, /* indicate file should not be gced */
731 FI_ATOMIC_REVOKE_REQUEST, /* request to drop atomic data */
732 FI_VERITY_IN_PROGRESS, /* building fs-verity Merkle tree */

--- 14 unchanged lines hidden (view full) ---

747 unsigned int i_current_depth; /* only for directory depth */
748 /* for gc failure statistic */
749 unsigned int i_gc_failures[MAX_GC_FAILURE];
750 unsigned int i_pino; /* parent inode number */
751 umode_t i_acl_mode; /* keep file acl mode temporarily */
752
753 /* Use below internally in f2fs*/
754 unsigned long flags[BITS_TO_LONGS(FI_MAX)]; /* use to pass per-file flags */
750 FI_DIRTY_FILE, /* indicate regular/symlink has dirty pages */
751 FI_PREALLOCATED_ALL, /* all blocks for write were preallocated */
752 FI_HOT_DATA, /* indicate file is hot */
753 FI_EXTRA_ATTR, /* indicate file has extra attribute */
754 FI_PROJ_INHERIT, /* indicate file inherits projectid */
755 FI_PIN_FILE, /* indicate file should not be gced */
756 FI_ATOMIC_REVOKE_REQUEST, /* request to drop atomic data */
757 FI_VERITY_IN_PROGRESS, /* building fs-verity Merkle tree */

--- 14 unchanged lines hidden (view full) ---

772 unsigned int i_current_depth; /* only for directory depth */
773 /* for gc failure statistic */
774 unsigned int i_gc_failures[MAX_GC_FAILURE];
775 unsigned int i_pino; /* parent inode number */
776 umode_t i_acl_mode; /* keep file acl mode temporarily */
777
778 /* Use below internally in f2fs*/
779 unsigned long flags[BITS_TO_LONGS(FI_MAX)]; /* use to pass per-file flags */
755 struct rw_semaphore i_sem; /* protect fi info */
780 struct f2fs_rwsem i_sem; /* protect fi info */
756 atomic_t dirty_pages; /* # of dirty pages */
757 f2fs_hash_t chash; /* hash value of given file name */
758 unsigned int clevel; /* maximum level of given file name */
759 struct task_struct *task; /* lookup and create consistency */
760 struct task_struct *cp_task; /* separate cp/wb IO stats*/
761 nid_t i_xattr_nid; /* node id that contains xattrs */
762 loff_t last_disk_size; /* lastly written file size */
763 spinlock_t i_size_lock; /* protect last_disk_size */

--- 8 unchanged lines hidden (view full) ---

772 struct list_head gdirty_list; /* linked in global dirty list */
773 struct list_head inmem_ilist; /* list for inmem inodes */
774 struct list_head inmem_pages; /* inmemory pages managed by f2fs */
775 struct task_struct *inmem_task; /* store inmemory task */
776 struct mutex inmem_lock; /* lock for inmemory pages */
777 struct extent_tree *extent_tree; /* cached extent_tree entry */
778
779 /* avoid racing between foreground op and gc */
781 atomic_t dirty_pages; /* # of dirty pages */
782 f2fs_hash_t chash; /* hash value of given file name */
783 unsigned int clevel; /* maximum level of given file name */
784 struct task_struct *task; /* lookup and create consistency */
785 struct task_struct *cp_task; /* separate cp/wb IO stats*/
786 nid_t i_xattr_nid; /* node id that contains xattrs */
787 loff_t last_disk_size; /* lastly written file size */
788 spinlock_t i_size_lock; /* protect last_disk_size */

--- 8 unchanged lines hidden (view full) ---

797 struct list_head gdirty_list; /* linked in global dirty list */
798 struct list_head inmem_ilist; /* list for inmem inodes */
799 struct list_head inmem_pages; /* inmemory pages managed by f2fs */
800 struct task_struct *inmem_task; /* store inmemory task */
801 struct mutex inmem_lock; /* lock for inmemory pages */
802 struct extent_tree *extent_tree; /* cached extent_tree entry */
803
804 /* avoid racing between foreground op and gc */
780 struct rw_semaphore i_gc_rwsem[2];
781 struct rw_semaphore i_xattr_sem; /* avoid racing between reading and changing EAs */
805 struct f2fs_rwsem i_gc_rwsem[2];
806 struct f2fs_rwsem i_xattr_sem; /* avoid racing between reading and changing EAs */
782
783 int i_extra_isize; /* size of extra space located in i_addr */
784 kprojid_t i_projid; /* id for project quota */
785 int i_inline_xattr_size; /* inline xattr size */
786 struct timespec64 i_crtime; /* inode creation time */
787 struct timespec64 i_disk_time[4];/* inode disk times */
788
789 /* for file compress */

--- 102 unchanged lines hidden (view full) ---

892 MAX_NAT_STATE,
893};
894
895struct f2fs_nm_info {
896 block_t nat_blkaddr; /* base disk address of NAT */
897 nid_t max_nid; /* maximum possible node ids */
898 nid_t available_nids; /* # of available node ids */
899 nid_t next_scan_nid; /* the next nid to be scanned */
807
808 int i_extra_isize; /* size of extra space located in i_addr */
809 kprojid_t i_projid; /* id for project quota */
810 int i_inline_xattr_size; /* inline xattr size */
811 struct timespec64 i_crtime; /* inode creation time */
812 struct timespec64 i_disk_time[4];/* inode disk times */
813
814 /* for file compress */

--- 102 unchanged lines hidden (view full) ---

917 MAX_NAT_STATE,
918};
919
920struct f2fs_nm_info {
921 block_t nat_blkaddr; /* base disk address of NAT */
922 nid_t max_nid; /* maximum possible node ids */
923 nid_t available_nids; /* # of available node ids */
924 nid_t next_scan_nid; /* the next nid to be scanned */
925 nid_t max_rf_node_blocks; /* max # of nodes for recovery */
900 unsigned int ram_thresh; /* control the memory footprint */
901 unsigned int ra_nid_pages; /* # of nid pages to be readaheaded */
902 unsigned int dirty_nats_ratio; /* control dirty nats ratio threshold */
903
904 /* NAT cache management */
905 struct radix_tree_root nat_root;/* root of the nat entry cache */
906 struct radix_tree_root nat_set_root;/* root of the nat set cache */
926 unsigned int ram_thresh; /* control the memory footprint */
927 unsigned int ra_nid_pages; /* # of nid pages to be readaheaded */
928 unsigned int dirty_nats_ratio; /* control dirty nats ratio threshold */
929
930 /* NAT cache management */
931 struct radix_tree_root nat_root;/* root of the nat entry cache */
932 struct radix_tree_root nat_set_root;/* root of the nat set cache */
907 struct rw_semaphore nat_tree_lock; /* protect nat entry tree */
933 struct f2fs_rwsem nat_tree_lock; /* protect nat entry tree */
908 struct list_head nat_entries; /* cached nat entry list (clean) */
909 spinlock_t nat_list_lock; /* protect clean nat entry list */
910 unsigned int nat_cnt[MAX_NAT_STATE]; /* the # of cached nat entries */
911 unsigned int nat_blocks; /* # of nat blocks */
912
913 /* free node ids management */
914 struct radix_tree_root free_nid_root;/* root of the free_nid cache */
915 struct list_head free_nid_list; /* list for free nids excluding preallocated nids */

--- 96 unchanged lines hidden (view full) ---

1012};
1013
1014struct f2fs_sm_info {
1015 struct sit_info *sit_info; /* whole segment information */
1016 struct free_segmap_info *free_info; /* free segment information */
1017 struct dirty_seglist_info *dirty_info; /* dirty segment information */
1018 struct curseg_info *curseg_array; /* active segment information */
1019
934 struct list_head nat_entries; /* cached nat entry list (clean) */
935 spinlock_t nat_list_lock; /* protect clean nat entry list */
936 unsigned int nat_cnt[MAX_NAT_STATE]; /* the # of cached nat entries */
937 unsigned int nat_blocks; /* # of nat blocks */
938
939 /* free node ids management */
940 struct radix_tree_root free_nid_root;/* root of the free_nid cache */
941 struct list_head free_nid_list; /* list for free nids excluding preallocated nids */

--- 96 unchanged lines hidden (view full) ---

1038};
1039
1040struct f2fs_sm_info {
1041 struct sit_info *sit_info; /* whole segment information */
1042 struct free_segmap_info *free_info; /* free segment information */
1043 struct dirty_seglist_info *dirty_info; /* dirty segment information */
1044 struct curseg_info *curseg_array; /* active segment information */
1045
1020 struct rw_semaphore curseg_lock; /* for preventing curseg change */
1046 struct f2fs_rwsem curseg_lock; /* for preventing curseg change */
1021
1022 block_t seg0_blkaddr; /* block address of 0'th segment */
1023 block_t main_blkaddr; /* start block address of main area */
1024 block_t ssa_blkaddr; /* start block address of SSA area */
1025
1026 unsigned int segment_count; /* total # of segments */
1027 unsigned int main_segments; /* # of segments in main area */
1028 unsigned int reserved_segments; /* # of reserved segments */

--- 167 unchanged lines hidden (view full) ---

1196};
1197
1198#define is_read_io(rw) ((rw) == READ)
1199struct f2fs_bio_info {
1200 struct f2fs_sb_info *sbi; /* f2fs superblock */
1201 struct bio *bio; /* bios to merge */
1202 sector_t last_block_in_bio; /* last block number */
1203 struct f2fs_io_info fio; /* store buffered io info. */
1047
1048 block_t seg0_blkaddr; /* block address of 0'th segment */
1049 block_t main_blkaddr; /* start block address of main area */
1050 block_t ssa_blkaddr; /* start block address of SSA area */
1051
1052 unsigned int segment_count; /* total # of segments */
1053 unsigned int main_segments; /* # of segments in main area */
1054 unsigned int reserved_segments; /* # of reserved segments */

--- 167 unchanged lines hidden (view full) ---

1222};
1223
1224#define is_read_io(rw) ((rw) == READ)
1225struct f2fs_bio_info {
1226 struct f2fs_sb_info *sbi; /* f2fs superblock */
1227 struct bio *bio; /* bios to merge */
1228 sector_t last_block_in_bio; /* last block number */
1229 struct f2fs_io_info fio; /* store buffered io info. */
1204 struct rw_semaphore io_rwsem; /* blocking op for bio */
1230 struct f2fs_rwsem io_rwsem; /* blocking op for bio */
1205 spinlock_t io_lock; /* serialize DATA/NODE IOs */
1206 struct list_head io_list; /* track fios */
1207 struct list_head bio_list; /* bio entry list head */
1231 spinlock_t io_lock; /* serialize DATA/NODE IOs */
1232 struct list_head io_list; /* track fios */
1233 struct list_head bio_list; /* bio entry list head */
1208 struct rw_semaphore bio_list_lock; /* lock to protect bio entry list */
1234 struct f2fs_rwsem bio_list_lock; /* lock to protect bio entry list */
1209};
1210
1211#define FDEV(i) (sbi->devs[i])
1212#define RDEV(i) (raw_super->devs[i])
1213struct f2fs_dev_info {
1214 struct block_device *bdev;
1215 char path[MAX_PATH_LEN];
1216 unsigned int total_segments;

--- 45 unchanged lines hidden (view full) ---

1262 SBI_IS_SHUTDOWN, /* shutdown by ioctl */
1263 SBI_IS_RECOVERED, /* recovered orphan/data */
1264 SBI_CP_DISABLED, /* CP was disabled last mount */
1265 SBI_CP_DISABLED_QUICK, /* CP was disabled quickly */
1266 SBI_QUOTA_NEED_FLUSH, /* need to flush quota info in CP */
1267 SBI_QUOTA_SKIP_FLUSH, /* skip flushing quota in current CP */
1268 SBI_QUOTA_NEED_REPAIR, /* quota file may be corrupted */
1269 SBI_IS_RESIZEFS, /* resizefs is in process */
1235};
1236
1237#define FDEV(i) (sbi->devs[i])
1238#define RDEV(i) (raw_super->devs[i])
1239struct f2fs_dev_info {
1240 struct block_device *bdev;
1241 char path[MAX_PATH_LEN];
1242 unsigned int total_segments;

--- 45 unchanged lines hidden (view full) ---

1288 SBI_IS_SHUTDOWN, /* shutdown by ioctl */
1289 SBI_IS_RECOVERED, /* recovered orphan/data */
1290 SBI_CP_DISABLED, /* CP was disabled last mount */
1291 SBI_CP_DISABLED_QUICK, /* CP was disabled quickly */
1292 SBI_QUOTA_NEED_FLUSH, /* need to flush quota info in CP */
1293 SBI_QUOTA_SKIP_FLUSH, /* skip flushing quota in current CP */
1294 SBI_QUOTA_NEED_REPAIR, /* quota file may be corrupted */
1295 SBI_IS_RESIZEFS, /* resizefs is in process */
1296 SBI_IS_FREEZING, /* freezefs is in process */
1270};
1271
1272enum {
1273 CP_TIME,
1274 REQ_TIME,
1275 DISCARD_TIME,
1276 GC_TIME,
1277 DISABLE_TIME,
1278 UMOUNT_DISCARD_TIMEOUT,
1279 MAX_TIME,
1280};
1281
1282enum {
1283 GC_NORMAL,
1284 GC_IDLE_CB,
1285 GC_IDLE_GREEDY,
1286 GC_IDLE_AT,
1287 GC_URGENT_HIGH,
1288 GC_URGENT_LOW,
1297};
1298
1299enum {
1300 CP_TIME,
1301 REQ_TIME,
1302 DISCARD_TIME,
1303 GC_TIME,
1304 DISABLE_TIME,
1305 UMOUNT_DISCARD_TIMEOUT,
1306 MAX_TIME,
1307};
1308
1309enum {
1310 GC_NORMAL,
1311 GC_IDLE_CB,
1312 GC_IDLE_GREEDY,
1313 GC_IDLE_AT,
1314 GC_URGENT_HIGH,
1315 GC_URGENT_LOW,
1316 GC_URGENT_MID,
1289 MAX_GC_MODE,
1290};
1291
1292enum {
1293 BGGC_MODE_ON, /* background gc is on */
1294 BGGC_MODE_OFF, /* background gc is off */
1295 BGGC_MODE_SYNC, /*
1296 * background gc is on, migrating blocks

--- 269 unchanged lines hidden (view full) ---

1566#define MIN_COMPRESS_LOG_SIZE 2
1567#define MAX_COMPRESS_LOG_SIZE 8
1568#define MAX_COMPRESS_WINDOW_SIZE(log_size) ((PAGE_SIZE) << (log_size))
1569
1570struct f2fs_sb_info {
1571 struct super_block *sb; /* pointer to VFS super block */
1572 struct proc_dir_entry *s_proc; /* proc entry */
1573 struct f2fs_super_block *raw_super; /* raw super block pointer */
1317 MAX_GC_MODE,
1318};
1319
1320enum {
1321 BGGC_MODE_ON, /* background gc is on */
1322 BGGC_MODE_OFF, /* background gc is off */
1323 BGGC_MODE_SYNC, /*
1324 * background gc is on, migrating blocks

--- 269 unchanged lines hidden (view full) ---

1594#define MIN_COMPRESS_LOG_SIZE 2
1595#define MAX_COMPRESS_LOG_SIZE 8
1596#define MAX_COMPRESS_WINDOW_SIZE(log_size) ((PAGE_SIZE) << (log_size))
1597
1598struct f2fs_sb_info {
1599 struct super_block *sb; /* pointer to VFS super block */
1600 struct proc_dir_entry *s_proc; /* proc entry */
1601 struct f2fs_super_block *raw_super; /* raw super block pointer */
1574 struct rw_semaphore sb_lock; /* lock for raw super block */
1602 struct f2fs_rwsem sb_lock; /* lock for raw super block */
1575 int valid_super_block; /* valid super block no */
1576 unsigned long s_flag; /* flags for sbi */
1577 struct mutex writepages; /* mutex for writepages() */
1578
1579#ifdef CONFIG_BLK_DEV_ZONED
1580 unsigned int blocks_per_blkz; /* F2FS blocks per zone */
1581 unsigned int log_blocks_per_blkz; /* log2 F2FS blocks per zone */
1582#endif
1583
1584 /* for node-related operations */
1585 struct f2fs_nm_info *nm_info; /* node manager */
1586 struct inode *node_inode; /* cache node blocks */
1587
1588 /* for segment-related operations */
1589 struct f2fs_sm_info *sm_info; /* segment manager */
1590
1591 /* for bio operations */
1592 struct f2fs_bio_info *write_io[NR_PAGE_TYPE]; /* for write bios */
1593 /* keep migration IO order for LFS mode */
1603 int valid_super_block; /* valid super block no */
1604 unsigned long s_flag; /* flags for sbi */
1605 struct mutex writepages; /* mutex for writepages() */
1606
1607#ifdef CONFIG_BLK_DEV_ZONED
1608 unsigned int blocks_per_blkz; /* F2FS blocks per zone */
1609 unsigned int log_blocks_per_blkz; /* log2 F2FS blocks per zone */
1610#endif
1611
1612 /* for node-related operations */
1613 struct f2fs_nm_info *nm_info; /* node manager */
1614 struct inode *node_inode; /* cache node blocks */
1615
1616 /* for segment-related operations */
1617 struct f2fs_sm_info *sm_info; /* segment manager */
1618
1619 /* for bio operations */
1620 struct f2fs_bio_info *write_io[NR_PAGE_TYPE]; /* for write bios */
1621 /* keep migration IO order for LFS mode */
1594 struct rw_semaphore io_order_lock;
1622 struct f2fs_rwsem io_order_lock;
1595 mempool_t *write_io_dummy; /* Dummy pages */
1623 mempool_t *write_io_dummy; /* Dummy pages */
1624 pgoff_t metapage_eio_ofs; /* EIO page offset */
1625 int metapage_eio_cnt; /* EIO count */
1596
1597 /* for checkpoint */
1598 struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */
1599 int cur_cp_pack; /* remain current cp pack */
1600 spinlock_t cp_lock; /* for flag in ckpt */
1601 struct inode *meta_inode; /* cache meta blocks */
1626
1627 /* for checkpoint */
1628 struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */
1629 int cur_cp_pack; /* remain current cp pack */
1630 spinlock_t cp_lock; /* for flag in ckpt */
1631 struct inode *meta_inode; /* cache meta blocks */
1602 struct rw_semaphore cp_global_sem; /* checkpoint procedure lock */
1603 struct rw_semaphore cp_rwsem; /* blocking FS operations */
1604 struct rw_semaphore node_write; /* locking node writes */
1605 struct rw_semaphore node_change; /* locking node change */
1632 struct f2fs_rwsem cp_global_sem; /* checkpoint procedure lock */
1633 struct f2fs_rwsem cp_rwsem; /* blocking FS operations */
1634 struct f2fs_rwsem node_write; /* locking node writes */
1635 struct f2fs_rwsem node_change; /* locking node change */
1606 wait_queue_head_t cp_wait;
1607 unsigned long last_time[MAX_TIME]; /* to store time in jiffies */
1608 long interval_time[MAX_TIME]; /* to store thresholds */
1609 struct ckpt_req_control cprc_info; /* for checkpoint request control */
1610
1611 struct inode_management im[MAX_INO_ENTRY]; /* manage inode cache */
1612
1613 spinlock_t fsync_node_lock; /* for node entry lock */

--- 43 unchanged lines hidden (view full) ---

1657 block_t last_valid_block_count; /* for recovery */
1658 block_t reserved_blocks; /* configurable reserved blocks */
1659 block_t current_reserved_blocks; /* current reserved blocks */
1660
1661 /* Additional tracking for no checkpoint mode */
1662 block_t unusable_block_count; /* # of blocks saved by last cp */
1663
1664 unsigned int nquota_files; /* # of quota sysfile */
1636 wait_queue_head_t cp_wait;
1637 unsigned long last_time[MAX_TIME]; /* to store time in jiffies */
1638 long interval_time[MAX_TIME]; /* to store thresholds */
1639 struct ckpt_req_control cprc_info; /* for checkpoint request control */
1640
1641 struct inode_management im[MAX_INO_ENTRY]; /* manage inode cache */
1642
1643 spinlock_t fsync_node_lock; /* for node entry lock */

--- 43 unchanged lines hidden (view full) ---

1687 block_t last_valid_block_count; /* for recovery */
1688 block_t reserved_blocks; /* configurable reserved blocks */
1689 block_t current_reserved_blocks; /* current reserved blocks */
1690
1691 /* Additional tracking for no checkpoint mode */
1692 block_t unusable_block_count; /* # of blocks saved by last cp */
1693
1694 unsigned int nquota_files; /* # of quota sysfile */
1665 struct rw_semaphore quota_sem; /* blocking cp for flags */
1695 struct f2fs_rwsem quota_sem; /* blocking cp for flags */
1666
1667 /* # of pages, see count_type */
1668 atomic_t nr_pages[NR_COUNT_TYPE];
1669 /* # of allocated blocks */
1670 struct percpu_counter alloc_valid_block_count;
1696
1697 /* # of pages, see count_type */
1698 atomic_t nr_pages[NR_COUNT_TYPE];
1699 /* # of allocated blocks */
1700 struct percpu_counter alloc_valid_block_count;
1701 /* # of node block writes as roll forward recovery */
1702 struct percpu_counter rf_node_block_count;
1671
1672 /* writeback control */
1673 atomic_t wb_sync_req[META]; /* count # of WB_SYNC threads */
1674
1675 /* valid inode count */
1676 struct percpu_counter total_valid_inode_count;
1677
1678 struct f2fs_mount_info mount_opt; /* mount options */
1679
1680 /* for cleaning operations */
1703
1704 /* writeback control */
1705 atomic_t wb_sync_req[META]; /* count # of WB_SYNC threads */
1706
1707 /* valid inode count */
1708 struct percpu_counter total_valid_inode_count;
1709
1710 struct f2fs_mount_info mount_opt; /* mount options */
1711
1712 /* for cleaning operations */
1681 struct rw_semaphore gc_lock; /*
1713 struct f2fs_rwsem gc_lock; /*
1682 * semaphore for GC, avoid
1683 * race between GC and GC or CP
1684 */
1685 struct f2fs_gc_kthread *gc_thread; /* GC thread */
1686 struct atgc_management am; /* atgc management */
1687 unsigned int cur_victim_sec; /* current victim section num */
1688 unsigned int gc_mode; /* current GC state */
1689 unsigned int next_victim_seg[2]; /* next segment in victim section */
1690 spinlock_t gc_urgent_high_lock;
1691 bool gc_urgent_high_limited; /* indicates having limited trial count */
1692 unsigned int gc_urgent_high_remaining; /* remaining trial count for GC_URGENT_HIGH */
1693
1694 /* for skip statistic */
1695 unsigned int atomic_files; /* # of opened atomic file */
1696 unsigned long long skipped_atomic_files[2]; /* FG_GC and BG_GC */
1697 unsigned long long skipped_gc_rwsem; /* FG_GC only */
1698
1699 /* threshold for gc trials on pinned files */
1700 u64 gc_pin_file_threshold;
1714 * semaphore for GC, avoid
1715 * race between GC and GC or CP
1716 */
1717 struct f2fs_gc_kthread *gc_thread; /* GC thread */
1718 struct atgc_management am; /* atgc management */
1719 unsigned int cur_victim_sec; /* current victim section num */
1720 unsigned int gc_mode; /* current GC state */
1721 unsigned int next_victim_seg[2]; /* next segment in victim section */
1722 spinlock_t gc_urgent_high_lock;
1723 bool gc_urgent_high_limited; /* indicates having limited trial count */
1724 unsigned int gc_urgent_high_remaining; /* remaining trial count for GC_URGENT_HIGH */
1725
1726 /* for skip statistic */
1727 unsigned int atomic_files; /* # of opened atomic file */
1728 unsigned long long skipped_atomic_files[2]; /* FG_GC and BG_GC */
1729 unsigned long long skipped_gc_rwsem; /* FG_GC only */
1730
1731 /* threshold for gc trials on pinned files */
1732 u64 gc_pin_file_threshold;
1701 struct rw_semaphore pin_sem;
1733 struct f2fs_rwsem pin_sem;
1702
1703 /* maximum # of trials to find a victim segment for SSR and GC */
1704 unsigned int max_victim_search;
1705 /* migration granularity of garbage collection, unit: segment */
1706 unsigned int migration_granularity;
1707
1708 /*
1709 * for stat information.

--- 377 unchanged lines hidden (view full) ---

2087{
2088 unsigned long flags;
2089
2090 spin_lock_irqsave(&sbi->cp_lock, flags);
2091 __clear_ckpt_flags(F2FS_CKPT(sbi), f);
2092 spin_unlock_irqrestore(&sbi->cp_lock, flags);
2093}
2094
1734
1735 /* maximum # of trials to find a victim segment for SSR and GC */
1736 unsigned int max_victim_search;
1737 /* migration granularity of garbage collection, unit: segment */
1738 unsigned int migration_granularity;
1739
1740 /*
1741 * for stat information.

--- 377 unchanged lines hidden (view full) ---

2119{
2120 unsigned long flags;
2121
2122 spin_lock_irqsave(&sbi->cp_lock, flags);
2123 __clear_ckpt_flags(F2FS_CKPT(sbi), f);
2124 spin_unlock_irqrestore(&sbi->cp_lock, flags);
2125}
2126
2127#define init_f2fs_rwsem(sem) \
2128do { \
2129 static struct lock_class_key __key; \
2130 \
2131 __init_f2fs_rwsem((sem), #sem, &__key); \
2132} while (0)
2133
2134static inline void __init_f2fs_rwsem(struct f2fs_rwsem *sem,
2135 const char *sem_name, struct lock_class_key *key)
2136{
2137 __init_rwsem(&sem->internal_rwsem, sem_name, key);
2138#ifdef CONFIG_F2FS_UNFAIR_RWSEM
2139 init_waitqueue_head(&sem->read_waiters);
2140#endif
2141}
2142
2143static inline int f2fs_rwsem_is_locked(struct f2fs_rwsem *sem)
2144{
2145 return rwsem_is_locked(&sem->internal_rwsem);
2146}
2147
2148static inline int f2fs_rwsem_is_contended(struct f2fs_rwsem *sem)
2149{
2150 return rwsem_is_contended(&sem->internal_rwsem);
2151}
2152
2153static inline void f2fs_down_read(struct f2fs_rwsem *sem)
2154{
2155#ifdef CONFIG_F2FS_UNFAIR_RWSEM
2156 wait_event(sem->read_waiters, down_read_trylock(&sem->internal_rwsem));
2157#else
2158 down_read(&sem->internal_rwsem);
2159#endif
2160}
2161
2162static inline int f2fs_down_read_trylock(struct f2fs_rwsem *sem)
2163{
2164 return down_read_trylock(&sem->internal_rwsem);
2165}
2166
2167#ifdef CONFIG_DEBUG_LOCK_ALLOC
2168static inline void f2fs_down_read_nested(struct f2fs_rwsem *sem, int subclass)
2169{
2170 down_read_nested(&sem->internal_rwsem, subclass);
2171}
2172#else
2173#define f2fs_down_read_nested(sem, subclass) f2fs_down_read(sem)
2174#endif
2175
2176static inline void f2fs_up_read(struct f2fs_rwsem *sem)
2177{
2178 up_read(&sem->internal_rwsem);
2179}
2180
2181static inline void f2fs_down_write(struct f2fs_rwsem *sem)
2182{
2183 down_write(&sem->internal_rwsem);
2184}
2185
2186static inline int f2fs_down_write_trylock(struct f2fs_rwsem *sem)
2187{
2188 return down_write_trylock(&sem->internal_rwsem);
2189}
2190
2191static inline void f2fs_up_write(struct f2fs_rwsem *sem)
2192{
2193 up_write(&sem->internal_rwsem);
2194#ifdef CONFIG_F2FS_UNFAIR_RWSEM
2195 wake_up_all(&sem->read_waiters);
2196#endif
2197}
2198
2095static inline void f2fs_lock_op(struct f2fs_sb_info *sbi)
2096{
2199static inline void f2fs_lock_op(struct f2fs_sb_info *sbi)
2200{
2097 down_read(&sbi->cp_rwsem);
2201 f2fs_down_read(&sbi->cp_rwsem);
2098}
2099
2100static inline int f2fs_trylock_op(struct f2fs_sb_info *sbi)
2101{
2102 if (time_to_inject(sbi, FAULT_LOCK_OP)) {
2103 f2fs_show_injection_info(sbi, FAULT_LOCK_OP);
2104 return 0;
2105 }
2202}
2203
2204static inline int f2fs_trylock_op(struct f2fs_sb_info *sbi)
2205{
2206 if (time_to_inject(sbi, FAULT_LOCK_OP)) {
2207 f2fs_show_injection_info(sbi, FAULT_LOCK_OP);
2208 return 0;
2209 }
2106 return down_read_trylock(&sbi->cp_rwsem);
2210 return f2fs_down_read_trylock(&sbi->cp_rwsem);
2107}
2108
2109static inline void f2fs_unlock_op(struct f2fs_sb_info *sbi)
2110{
2211}
2212
2213static inline void f2fs_unlock_op(struct f2fs_sb_info *sbi)
2214{
2111 up_read(&sbi->cp_rwsem);
2215 f2fs_up_read(&sbi->cp_rwsem);
2112}
2113
2114static inline void f2fs_lock_all(struct f2fs_sb_info *sbi)
2115{
2216}
2217
2218static inline void f2fs_lock_all(struct f2fs_sb_info *sbi)
2219{
2116 down_write(&sbi->cp_rwsem);
2220 f2fs_down_write(&sbi->cp_rwsem);
2117}
2118
2119static inline void f2fs_unlock_all(struct f2fs_sb_info *sbi)
2120{
2221}
2222
2223static inline void f2fs_unlock_all(struct f2fs_sb_info *sbi)
2224{
2121 up_write(&sbi->cp_rwsem);
2225 f2fs_up_write(&sbi->cp_rwsem);
2122}
2123
2124static inline int __get_cp_reason(struct f2fs_sb_info *sbi)
2125{
2126 int reason = CP_SYNC;
2127
2128 if (test_opt(sbi, FASTBOOT))
2129 reason = CP_FASTBOOT;

--- 546 unchanged lines hidden (view full) ---

2676static inline bool is_idle(struct f2fs_sb_info *sbi, int type)
2677{
2678 if (sbi->gc_mode == GC_URGENT_HIGH)
2679 return true;
2680
2681 if (is_inflight_io(sbi, type))
2682 return false;
2683
2226}
2227
2228static inline int __get_cp_reason(struct f2fs_sb_info *sbi)
2229{
2230 int reason = CP_SYNC;
2231
2232 if (test_opt(sbi, FASTBOOT))
2233 reason = CP_FASTBOOT;

--- 546 unchanged lines hidden (view full) ---

2780static inline bool is_idle(struct f2fs_sb_info *sbi, int type)
2781{
2782 if (sbi->gc_mode == GC_URGENT_HIGH)
2783 return true;
2784
2785 if (is_inflight_io(sbi, type))
2786 return false;
2787
2788 if (sbi->gc_mode == GC_URGENT_MID)
2789 return true;
2790
2684 if (sbi->gc_mode == GC_URGENT_LOW &&
2685 (type == DISCARD_TIME || type == GC_TIME))
2686 return true;
2687
2688 return f2fs_time_over(sbi, type);
2689}
2690
2691static inline void f2fs_radix_tree_insert(struct radix_tree_root *root,

--- 882 unchanged lines hidden (view full) ---

3574struct page *f2fs_grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index);
3575struct page *f2fs_get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index);
3576struct page *f2fs_get_meta_page_retry(struct f2fs_sb_info *sbi, pgoff_t index);
3577struct page *f2fs_get_tmp_page(struct f2fs_sb_info *sbi, pgoff_t index);
3578bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
3579 block_t blkaddr, int type);
3580int f2fs_ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages,
3581 int type, bool sync);
2791 if (sbi->gc_mode == GC_URGENT_LOW &&
2792 (type == DISCARD_TIME || type == GC_TIME))
2793 return true;
2794
2795 return f2fs_time_over(sbi, type);
2796}
2797
2798static inline void f2fs_radix_tree_insert(struct radix_tree_root *root,

--- 882 unchanged lines hidden (view full) ---

3681struct page *f2fs_grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index);
3682struct page *f2fs_get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index);
3683struct page *f2fs_get_meta_page_retry(struct f2fs_sb_info *sbi, pgoff_t index);
3684struct page *f2fs_get_tmp_page(struct f2fs_sb_info *sbi, pgoff_t index);
3685bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
3686 block_t blkaddr, int type);
3687int f2fs_ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages,
3688 int type, bool sync);
3582void f2fs_ra_meta_pages_cond(struct f2fs_sb_info *sbi, pgoff_t index);
3689void f2fs_ra_meta_pages_cond(struct f2fs_sb_info *sbi, pgoff_t index,
3690 unsigned int ra_blocks);
3583long f2fs_sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
3584 long nr_to_write, enum iostat_type io_type);
3585void f2fs_add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type);
3586void f2fs_remove_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type);
3587void f2fs_release_ino_entry(struct f2fs_sb_info *sbi, bool all);
3588bool f2fs_exist_written_data(struct f2fs_sb_info *sbi, nid_t ino, int mode);
3589void f2fs_set_dirty_device(struct f2fs_sb_info *sbi, nid_t ino,
3590 unsigned int devidx, int type);

--- 842 unchanged lines hidden ---
3691long f2fs_sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
3692 long nr_to_write, enum iostat_type io_type);
3693void f2fs_add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type);
3694void f2fs_remove_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type);
3695void f2fs_release_ino_entry(struct f2fs_sb_info *sbi, bool all);
3696bool f2fs_exist_written_data(struct f2fs_sb_info *sbi, nid_t ino, int mode);
3697void f2fs_set_dirty_device(struct f2fs_sb_info *sbi, nid_t ino,
3698 unsigned int devidx, int type);

--- 842 unchanged lines hidden ---