fs/nilfs2/ifile.c
Source file repositories/reference/linux-study-clean/fs/nilfs2/ifile.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nilfs2/ifile.c- Extension
.c- Size
- 5595 bytes
- Lines
- 217
- 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.hnilfs.hmdt.halloc.hifile.hcpfile.h
Detected Declarations
struct nilfs_ifile_infofunction nilfs_ifile_create_inodefunction nilfs_ifile_delete_inodefunction nilfs_ifile_get_inode_blockfunction nilfs_ifile_count_free_inodesfunction nilfs_ifile_read
Annotated Snippet
struct nilfs_ifile_info {
struct nilfs_mdt_info mi;
struct nilfs_palloc_cache palloc_cache;
};
static inline struct nilfs_ifile_info *NILFS_IFILE_I(struct inode *ifile)
{
return (struct nilfs_ifile_info *)NILFS_MDT(ifile);
}
/**
* nilfs_ifile_create_inode - create a new disk inode
* @ifile: ifile inode
* @out_ino: pointer to a variable to store inode number
* @out_bh: buffer_head contains newly allocated disk inode
*
* nilfs_ifile_create_inode() allocates a new inode in the ifile metadata
* file and stores the inode number in the variable pointed to by @out_ino,
* as well as storing the ifile's buffer with the disk inode in the location
* pointed to by @out_bh.
*
* Return: 0 on success, or one of the following negative error codes on
* failure:
* * %-EIO - I/O error (including metadata corruption).
* * %-ENOMEM - Insufficient memory available.
* * %-ENOSPC - No inode left.
*/
int nilfs_ifile_create_inode(struct inode *ifile, ino_t *out_ino,
struct buffer_head **out_bh)
{
struct nilfs_palloc_req req;
int ret;
req.pr_entry_nr = NILFS_FIRST_INO(ifile->i_sb);
req.pr_entry_bh = NULL;
ret = nilfs_palloc_prepare_alloc_entry(ifile, &req, false);
if (!ret) {
ret = nilfs_palloc_get_entry_block(ifile, req.pr_entry_nr, 1,
&req.pr_entry_bh);
if (ret < 0)
nilfs_palloc_abort_alloc_entry(ifile, &req);
}
if (ret < 0) {
brelse(req.pr_entry_bh);
return ret;
}
nilfs_palloc_commit_alloc_entry(ifile, &req);
mark_buffer_dirty(req.pr_entry_bh);
nilfs_mdt_mark_dirty(ifile);
*out_ino = (ino_t)req.pr_entry_nr;
*out_bh = req.pr_entry_bh;
return 0;
}
/**
* nilfs_ifile_delete_inode - delete a disk inode
* @ifile: ifile inode
* @ino: inode number
*
* Return: 0 on success, or one of the following negative error codes on
* failure:
* * %-EIO - I/O error (including metadata corruption).
* * %-ENOENT - Inode number unallocated.
* * %-ENOMEM - Insufficient memory available.
*/
int nilfs_ifile_delete_inode(struct inode *ifile, ino_t ino)
{
struct nilfs_palloc_req req = {
.pr_entry_nr = ino, .pr_entry_bh = NULL
};
struct nilfs_inode *raw_inode;
size_t offset;
int ret;
ret = nilfs_palloc_prepare_free_entry(ifile, &req);
if (!ret) {
ret = nilfs_palloc_get_entry_block(ifile, req.pr_entry_nr, 0,
&req.pr_entry_bh);
if (ret < 0)
nilfs_palloc_abort_free_entry(ifile, &req);
}
if (ret < 0) {
brelse(req.pr_entry_bh);
return ret;
}
offset = nilfs_palloc_entry_offset(ifile, req.pr_entry_nr,
req.pr_entry_bh);
raw_inode = kmap_local_folio(req.pr_entry_bh->b_folio, offset);
Annotation
- Immediate include surface: `linux/types.h`, `linux/buffer_head.h`, `nilfs.h`, `mdt.h`, `alloc.h`, `ifile.h`, `cpfile.h`.
- Detected declarations: `struct nilfs_ifile_info`, `function nilfs_ifile_create_inode`, `function nilfs_ifile_delete_inode`, `function nilfs_ifile_get_inode_block`, `function nilfs_ifile_count_free_inodes`, `function nilfs_ifile_read`.
- 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.