fs/nilfs2/cpfile.c
Source file repositories/reference/linux-study-clean/fs/nilfs2/cpfile.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nilfs2/cpfile.c- Extension
.c- Size
- 32412 bytes
- Lines
- 1173
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/fs.hlinux/string.hlinux/buffer_head.hlinux/errno.hmdt.hcpfile.h
Detected Declarations
function Copyrightfunction nilfs_cpfile_get_blkofffunction nilfs_cpfile_get_offsetfunction nilfs_cpfile_first_checkpoint_in_blockfunction nilfs_cpfile_checkpoints_in_blockfunction nilfs_cpfile_is_in_firstfunction nilfs_cpfile_block_add_valid_checkpointsfunction nilfs_cpfile_block_sub_valid_checkpointsfunction nilfs_cpfile_block_initfunction nilfs_cpfile_checkpoint_offsetfunction nilfs_cpfile_cp_snapshot_list_offsetfunction nilfs_cpfile_ch_snapshot_list_offsetfunction nilfs_cpfile_get_header_blockfunction nilfs_cpfile_get_checkpoint_blockfunction nilfs_cpfile_find_checkpoint_blockfunction nilfs_cpfile_delete_checkpoint_blockfunction nilfs_cpfile_read_checkpointfunction nilfs_cpfile_create_checkpointfunction nilfs_cpfile_finalize_checkpointfunction nilfs_cpfile_delete_checkpointsfunction nilfs_cpfile_checkpoint_to_cpinfofunction nilfs_cpfile_do_get_cpinfofunction nilfs_cpfile_do_get_ssinfofunction nilfs_cpfile_get_cpinfofunction nilfs_cpfile_delete_checkpointfunction nilfs_cpfile_set_snapshotfunction nilfs_cpfile_clear_snapshotfunction nilfs_cpfile_is_snapshotfunction nilfs_cpfile_change_cpmodefunction nilfs_cpfile_get_statfunction nilfs_cpfile_read
Annotated Snippet
if (ret < 0) {
if (ret != -ENOENT)
break;
/* skip hole */
ret = 0;
continue;
}
offset = nilfs_cpfile_checkpoint_offset(cpfile, cno, cp_bh);
cp = kaddr = kmap_local_folio(cp_bh->b_folio, offset);
nicps = 0;
for (i = 0; i < ncps; i++, cp = (void *)cp + cpsz) {
if (nilfs_checkpoint_snapshot(cp)) {
nss++;
} else if (!nilfs_checkpoint_invalid(cp)) {
nilfs_checkpoint_set_invalid(cp);
nicps++;
}
}
kunmap_local(kaddr);
if (nicps <= 0) {
brelse(cp_bh);
continue;
}
tnicps += nicps;
mark_buffer_dirty(cp_bh);
nilfs_mdt_mark_dirty(cpfile);
if (nilfs_cpfile_is_in_first(cpfile, cno)) {
brelse(cp_bh);
continue;
}
count = nilfs_cpfile_block_sub_valid_checkpoints(cpfile, cp_bh,
nicps);
brelse(cp_bh);
if (count)
continue;
/* Delete the block if there are no more valid checkpoints */
ret = nilfs_cpfile_delete_checkpoint_block(cpfile, cno);
if (unlikely(ret)) {
nilfs_err(cpfile->i_sb,
"error %d deleting checkpoint block", ret);
break;
}
}
if (tnicps > 0) {
header = kmap_local_folio(header_bh->b_folio, 0);
le64_add_cpu(&header->ch_ncheckpoints, -(u64)tnicps);
mark_buffer_dirty(header_bh);
nilfs_mdt_mark_dirty(cpfile);
kunmap_local(header);
}
brelse(header_bh);
if (nss > 0)
ret = -EBUSY;
out_sem:
up_write(&NILFS_MDT(cpfile)->mi_sem);
return ret;
}
static void nilfs_cpfile_checkpoint_to_cpinfo(struct inode *cpfile,
struct nilfs_checkpoint *cp,
struct nilfs_cpinfo *ci)
{
ci->ci_flags = le32_to_cpu(cp->cp_flags);
ci->ci_cno = le64_to_cpu(cp->cp_cno);
ci->ci_create = le64_to_cpu(cp->cp_create);
ci->ci_nblk_inc = le64_to_cpu(cp->cp_nblk_inc);
ci->ci_inodes_count = le64_to_cpu(cp->cp_inodes_count);
ci->ci_blocks_count = le64_to_cpu(cp->cp_blocks_count);
ci->ci_next = le64_to_cpu(cp->cp_snapshot_list.ssl_next);
}
static ssize_t nilfs_cpfile_do_get_cpinfo(struct inode *cpfile, __u64 *cnop,
void *buf, unsigned int cisz,
size_t nci)
{
struct nilfs_checkpoint *cp;
struct nilfs_cpinfo *ci = buf;
struct buffer_head *bh;
size_t cpsz = NILFS_MDT(cpfile)->mi_entry_size;
__u64 cur_cno = nilfs_mdt_cno(cpfile), cno = *cnop;
size_t offset;
void *kaddr;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/fs.h`, `linux/string.h`, `linux/buffer_head.h`, `linux/errno.h`, `mdt.h`, `cpfile.h`.
- Detected declarations: `function Copyright`, `function nilfs_cpfile_get_blkoff`, `function nilfs_cpfile_get_offset`, `function nilfs_cpfile_first_checkpoint_in_block`, `function nilfs_cpfile_checkpoints_in_block`, `function nilfs_cpfile_is_in_first`, `function nilfs_cpfile_block_add_valid_checkpoints`, `function nilfs_cpfile_block_sub_valid_checkpoints`, `function nilfs_cpfile_block_init`, `function nilfs_cpfile_checkpoint_offset`.
- 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.