fs/f2fs/data.c
Source file repositories/reference/linux-study-clean/fs/f2fs/data.c
File Facts
- System
- Linux kernel
- Corpus path
fs/f2fs/data.c- Extension
.c- Size
- 115766 bytes
- Lines
- 4606
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fs.hlinux/f2fs_fs.hlinux/sched/mm.hlinux/mpage.hlinux/writeback.hlinux/folio_batch.hlinux/blkdev.hlinux/bio.hlinux/blk-crypto.hlinux/swap.hlinux/prefetch.hlinux/uio.hlinux/sched/signal.hlinux/fiemap.hlinux/iomap.hf2fs.hnode.hsegment.hiostat.htrace/events/f2fs.h
Detected Declarations
struct f2fs_folio_statestruct bio_post_read_ctxenum bio_post_read_stepfunction f2fs_init_biosetfunction f2fs_destroy_biosetfunction f2fs_is_cp_guaranteedfunction __read_io_typefunction calledfunction bio_for_each_folio_allfunction f2fs_verify_biofunction f2fs_end_read_compressed_pagefunction bio_for_each_folio_allfunction f2fs_verify_and_finish_biofunction clustersfunction bio_for_each_folio_allfunction f2fs_post_read_workfunction f2fs_read_end_iofunction f2fs_write_end_iofunction bio_for_each_folio_allfunction f2fs_zone_write_end_iofunction f2fs_target_device_indexfunction f2fs_io_flagsfunction f2fs_set_bio_crypt_ctxfunction f2fs_crypt_mergeable_biofunction f2fs_submit_read_biofunction f2fs_submit_write_biofunction __submit_merged_biofunction __has_merged_pagefunction bio_for_each_folio_allfunction f2fs_init_write_merge_iofunction __f2fs_submit_merged_writefunction __submit_merged_write_condfunction f2fs_submit_merged_writefunction f2fs_submit_merged_write_condfunction f2fs_submit_merged_write_foliofunction f2fs_flush_merged_writesfunction f2fs_submit_page_biofunction page_is_mergeablefunction io_type_is_mergeablefunction io_is_mergeablefunction add_bio_entryfunction del_bio_entryfunction add_ipu_pagefunction list_for_each_entryfunction f2fs_submit_merged_ipu_writefunction list_for_each_entryfunction list_for_each_entryfunction f2fs_merge_page_bio
Annotated Snippet
struct f2fs_folio_state {
spinlock_t state_lock;
unsigned int read_pages_pending;
};
#define F2FS_BIO_POOL_SIZE NR_CURSEG_TYPE
int __init f2fs_init_bioset(void)
{
return bioset_init(&f2fs_bioset, F2FS_BIO_POOL_SIZE,
0, BIOSET_NEED_BVECS);
}
void f2fs_destroy_bioset(void)
{
bioset_exit(&f2fs_bioset);
}
bool f2fs_is_cp_guaranteed(const struct folio *folio)
{
struct address_space *mapping = folio->mapping;
struct inode *inode;
struct f2fs_sb_info *sbi;
if (fscrypt_is_bounce_folio(folio))
return folio_test_f2fs_gcing(fscrypt_pagecache_folio(folio));
inode = mapping->host;
sbi = F2FS_I_SB(inode);
if (inode->i_ino == F2FS_META_INO(sbi) ||
inode->i_ino == F2FS_NODE_INO(sbi) ||
S_ISDIR(inode->i_mode))
return true;
if ((S_ISREG(inode->i_mode) && IS_NOQUOTA(inode)) ||
folio_test_f2fs_gcing(folio))
return true;
return false;
}
static enum count_type __read_io_type(struct folio *folio)
{
struct address_space *mapping = folio->mapping;
if (mapping) {
struct inode *inode = mapping->host;
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
if (inode->i_ino == F2FS_META_INO(sbi))
return F2FS_RD_META;
if (inode->i_ino == F2FS_NODE_INO(sbi))
return F2FS_RD_NODE;
}
return F2FS_RD_DATA;
}
/* postprocessing steps for read bios */
enum bio_post_read_step {
#ifdef CONFIG_FS_ENCRYPTION
STEP_DECRYPT = BIT(0),
#else
STEP_DECRYPT = 0, /* compile out the decryption-related code */
#endif
#ifdef CONFIG_F2FS_FS_COMPRESSION
STEP_DECOMPRESS = BIT(1),
#else
STEP_DECOMPRESS = 0, /* compile out the decompression-related code */
#endif
#ifdef CONFIG_FS_VERITY
STEP_VERITY = BIT(2),
#else
STEP_VERITY = 0, /* compile out the verity-related code */
#endif
};
struct bio_post_read_ctx {
struct bio *bio;
struct f2fs_sb_info *sbi;
struct fsverity_info *vi;
struct work_struct work;
unsigned int enabled_steps;
/*
* decompression_attempted keeps track of whether
* f2fs_end_read_compressed_page() has been called on the pages in the
* bio that belong to a compressed cluster yet.
*/
bool decompression_attempted;
block_t fs_blkaddr;
Annotation
- Immediate include surface: `linux/fs.h`, `linux/f2fs_fs.h`, `linux/sched/mm.h`, `linux/mpage.h`, `linux/writeback.h`, `linux/folio_batch.h`, `linux/blkdev.h`, `linux/bio.h`.
- Detected declarations: `struct f2fs_folio_state`, `struct bio_post_read_ctx`, `enum bio_post_read_step`, `function f2fs_init_bioset`, `function f2fs_destroy_bioset`, `function f2fs_is_cp_guaranteed`, `function __read_io_type`, `function called`, `function bio_for_each_folio_all`, `function f2fs_verify_bio`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.