fs/nilfs2/dat.c
Source file repositories/reference/linux-study-clean/fs/nilfs2/dat.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nilfs2/dat.c- Extension
.c- Size
- 14405 bytes
- Lines
- 542
- 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/types.hlinux/buffer_head.hlinux/string.hlinux/errno.hnilfs.hmdt.halloc.hdat.h
Detected Declarations
struct nilfs_dat_infofunction nilfs_dat_prepare_entryfunction nilfs_dat_commit_entryfunction nilfs_dat_abort_entryfunction nilfs_dat_prepare_allocfunction nilfs_dat_commit_allocfunction nilfs_dat_abort_allocfunction nilfs_dat_commit_freefunction nilfs_dat_prepare_startfunction nilfs_dat_commit_startfunction nilfs_dat_prepare_endfunction nilfs_dat_commit_endfunction nilfs_dat_abort_endfunction nilfs_dat_prepare_updatefunction nilfs_dat_commit_updatefunction nilfs_dat_abort_updatefunction nilfs_dat_mark_dirtyfunction nilfs_dat_freevfunction nilfs_dat_movefunction numberfunction nilfs_dat_translatefunction nilfs_dat_get_vinfofunction nilfs_dat_read
Annotated Snippet
struct nilfs_dat_info {
struct nilfs_mdt_info mi;
struct nilfs_palloc_cache palloc_cache;
struct nilfs_shadow_map shadow;
};
static inline struct nilfs_dat_info *NILFS_DAT_I(struct inode *dat)
{
return (struct nilfs_dat_info *)NILFS_MDT(dat);
}
static int nilfs_dat_prepare_entry(struct inode *dat,
struct nilfs_palloc_req *req, int create)
{
int ret;
ret = nilfs_palloc_get_entry_block(dat, req->pr_entry_nr,
create, &req->pr_entry_bh);
if (unlikely(ret == -ENOENT)) {
nilfs_err(dat->i_sb,
"DAT doesn't have a block to manage vblocknr = %llu",
(unsigned long long)req->pr_entry_nr);
/*
* Return internal code -EINVAL to notify bmap layer of
* metadata corruption.
*/
ret = -EINVAL;
}
return ret;
}
static void nilfs_dat_commit_entry(struct inode *dat,
struct nilfs_palloc_req *req)
{
mark_buffer_dirty(req->pr_entry_bh);
nilfs_mdt_mark_dirty(dat);
brelse(req->pr_entry_bh);
}
static void nilfs_dat_abort_entry(struct inode *dat,
struct nilfs_palloc_req *req)
{
brelse(req->pr_entry_bh);
}
int nilfs_dat_prepare_alloc(struct inode *dat, struct nilfs_palloc_req *req)
{
int ret;
ret = nilfs_palloc_prepare_alloc_entry(dat, req, true);
if (ret < 0)
return ret;
ret = nilfs_dat_prepare_entry(dat, req, 1);
if (ret < 0)
nilfs_palloc_abort_alloc_entry(dat, req);
return ret;
}
void nilfs_dat_commit_alloc(struct inode *dat, struct nilfs_palloc_req *req)
{
struct nilfs_dat_entry *entry;
size_t offset;
offset = nilfs_palloc_entry_offset(dat, req->pr_entry_nr,
req->pr_entry_bh);
entry = kmap_local_folio(req->pr_entry_bh->b_folio, offset);
entry->de_start = cpu_to_le64(NILFS_CNO_MIN);
entry->de_end = cpu_to_le64(NILFS_CNO_MAX);
entry->de_blocknr = cpu_to_le64(0);
kunmap_local(entry);
nilfs_palloc_commit_alloc_entry(dat, req);
nilfs_dat_commit_entry(dat, req);
}
void nilfs_dat_abort_alloc(struct inode *dat, struct nilfs_palloc_req *req)
{
nilfs_dat_abort_entry(dat, req);
nilfs_palloc_abort_alloc_entry(dat, req);
}
static void nilfs_dat_commit_free(struct inode *dat,
struct nilfs_palloc_req *req)
{
struct nilfs_dat_entry *entry;
size_t offset;
offset = nilfs_palloc_entry_offset(dat, req->pr_entry_nr,
Annotation
- Immediate include surface: `linux/types.h`, `linux/buffer_head.h`, `linux/string.h`, `linux/errno.h`, `nilfs.h`, `mdt.h`, `alloc.h`, `dat.h`.
- Detected declarations: `struct nilfs_dat_info`, `function nilfs_dat_prepare_entry`, `function nilfs_dat_commit_entry`, `function nilfs_dat_abort_entry`, `function nilfs_dat_prepare_alloc`, `function nilfs_dat_commit_alloc`, `function nilfs_dat_abort_alloc`, `function nilfs_dat_commit_free`, `function nilfs_dat_prepare_start`, `function nilfs_dat_commit_start`.
- 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.