fs/f2fs/recovery.c
Source file repositories/reference/linux-study-clean/fs/f2fs/recovery.c
File Facts
- System
- Linux kernel
- Corpus path
fs/f2fs/recovery.c- Extension
.c- Size
- 24057 bytes
- Lines
- 969
- 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.
- 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/unaligned.hlinux/fs.hlinux/f2fs_fs.hlinux/sched/mm.hf2fs.hnode.hsegment.h
Detected Declarations
function f2fs_space_for_roll_forwardfunction del_fsync_inodefunction init_recovered_filenamefunction recover_dentryfunction recover_quota_datafunction recover_inline_flagsfunction recover_inodefunction adjust_por_ra_blocksfunction sanity_check_node_chainfunction find_fsync_dnodesfunction destroy_fsync_dnodesfunction check_index_in_prev_nodesfunction f2fs_reserve_new_block_retryfunction do_recover_datafunction recover_datafunction inodefunction f2fs_recover_fsync_datafunction f2fs_create_recovery_cachefunction f2fs_destroy_recovery_cache
Annotated Snippet
if (IS_ERR(entry)) {
dir = ERR_CAST(entry);
err = PTR_ERR(entry);
goto out;
}
}
dir = entry->inode;
err = init_recovered_filename(dir, raw_inode, &fname, &usr_fname);
if (err)
goto out;
retry:
de = __f2fs_find_entry(dir, &fname, &folio);
if (de && inode->i_ino == le32_to_cpu(de->ino))
goto out_put;
if (de) {
einode = f2fs_iget_retry(inode->i_sb, le32_to_cpu(de->ino));
if (IS_ERR(einode)) {
WARN_ON(1);
err = PTR_ERR(einode);
if (err == -ENOENT)
err = -EEXIST;
goto out_put;
}
err = f2fs_dquot_initialize(einode);
if (err) {
iput(einode);
goto out_put;
}
err = f2fs_acquire_orphan_inode(F2FS_I_SB(inode));
if (err) {
iput(einode);
goto out_put;
}
f2fs_delete_entry(de, folio, dir, einode);
iput(einode);
goto retry;
} else if (IS_ERR(folio)) {
err = PTR_ERR(folio);
} else {
err = f2fs_add_dentry(dir, &fname, inode,
inode->i_ino, inode->i_mode);
}
if (err == -ENOMEM)
goto retry;
goto out;
out_put:
f2fs_folio_put(folio, false);
out:
if (file_enc_name(inode))
name = "<encrypted>";
else
name = raw_inode->i_name;
f2fs_notice(F2FS_I_SB(inode), "%s: ino = %x, name = %s, dir = %llu, err = %d",
__func__, ino_of_node(ifolio), name,
IS_ERR(dir) ? 0 : dir->i_ino, err);
return err;
}
static int recover_quota_data(struct inode *inode, struct folio *folio)
{
struct f2fs_inode *raw = F2FS_INODE(folio);
struct iattr attr;
uid_t i_uid = le32_to_cpu(raw->i_uid);
gid_t i_gid = le32_to_cpu(raw->i_gid);
int err;
memset(&attr, 0, sizeof(attr));
attr.ia_vfsuid = VFSUIDT_INIT(make_kuid(inode->i_sb->s_user_ns, i_uid));
attr.ia_vfsgid = VFSGIDT_INIT(make_kgid(inode->i_sb->s_user_ns, i_gid));
if (!vfsuid_eq(attr.ia_vfsuid, i_uid_into_vfsuid(&nop_mnt_idmap, inode)))
attr.ia_valid |= ATTR_UID;
if (!vfsgid_eq(attr.ia_vfsgid, i_gid_into_vfsgid(&nop_mnt_idmap, inode)))
attr.ia_valid |= ATTR_GID;
if (!attr.ia_valid)
return 0;
err = dquot_transfer(&nop_mnt_idmap, inode, &attr);
if (err)
set_sbi_flag(F2FS_I_SB(inode), SBI_QUOTA_NEED_REPAIR);
return err;
}
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/fs.h`, `linux/f2fs_fs.h`, `linux/sched/mm.h`, `f2fs.h`, `node.h`, `segment.h`.
- Detected declarations: `function f2fs_space_for_roll_forward`, `function del_fsync_inode`, `function init_recovered_filename`, `function recover_dentry`, `function recover_quota_data`, `function recover_inline_flags`, `function recover_inode`, `function adjust_por_ra_blocks`, `function sanity_check_node_chain`, `function find_fsync_dnodes`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
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.