fs/jfs/inode.c
Source file repositories/reference/linux-study-clean/fs/jfs/inode.c
File Facts
- System
- Linux kernel
- Corpus path
fs/jfs/inode.c- Extension
.c- Size
- 10197 bytes
- Lines
- 423
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fs.hlinux/mpage.hlinux/buffer_head.hlinux/pagemap.hlinux/quotaops.hlinux/uio.hlinux/writeback.hjfs_incore.hjfs_inode.hjfs_filsys.hjfs_imap.hjfs_extent.hjfs_unicode.hjfs_debug.hjfs_dmap.h
Detected Declarations
function Copyrightfunction S_ISFIFOfunction jfs_commit_inodefunction jfs_write_inodefunction jfs_evict_inodefunction jfs_dirty_inodefunction jfs_get_blockfunction jfs_writepagesfunction jfs_read_foliofunction jfs_readaheadfunction jfs_write_failedfunction jfs_write_beginfunction jfs_write_endfunction jfs_bmapfunction jfs_direct_IOfunction jfs_truncate_nolockfunction jfs_truncate
Annotated Snippet
if (inode->i_size >= IDATASIZE) {
inode->i_op = &page_symlink_inode_operations;
inode_nohighmem(inode);
inode->i_mapping->a_ops = &jfs_aops;
} else {
inode->i_op = &jfs_fast_symlink_inode_operations;
inode->i_link = JFS_IP(inode)->i_inline;
/*
* The inline data should be null-terminated, but
* don't let on-disk corruption crash the kernel
*/
inode->i_link[inode->i_size] = '\0';
}
} else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
inode->i_op = &jfs_file_inode_operations;
init_special_inode(inode, inode->i_mode, inode->i_rdev);
} else {
printk(KERN_DEBUG "JFS: Invalid file type 0%04o for inode %llu.\n",
inode->i_mode, inode->i_ino);
iget_failed(inode);
return ERR_PTR(-EIO);
}
unlock_new_inode(inode);
return inode;
}
/*
* Workhorse of both fsync & write_inode
*/
int jfs_commit_inode(struct inode *inode, int wait)
{
int rc = 0;
tid_t tid;
static int noisy = 5;
jfs_info("In jfs_commit_inode, inode = 0x%p", inode);
/*
* Don't commit if inode has been committed since last being
* marked dirty, or if it has been deleted.
*/
if (inode->i_nlink == 0 || !test_cflag(COMMIT_Dirty, inode))
return 0;
if (isReadOnly(inode)) {
/* kernel allows writes to devices on read-only
* partitions and may think inode is dirty
*/
if (!special_file(inode->i_mode) && noisy) {
jfs_err("jfs_commit_inode(0x%p) called on read-only volume",
inode);
jfs_err("Is remount racy?");
noisy--;
}
return 0;
}
tid = txBegin(inode->i_sb, COMMIT_INODE);
mutex_lock(&JFS_IP(inode)->commit_mutex);
/*
* Retest inode state after taking commit_mutex
*/
if (inode->i_nlink && test_cflag(COMMIT_Dirty, inode))
rc = txCommit(tid, 1, &inode, wait ? COMMIT_SYNC : 0);
txEnd(tid);
mutex_unlock(&JFS_IP(inode)->commit_mutex);
return rc;
}
int jfs_write_inode(struct inode *inode, struct writeback_control *wbc)
{
int wait = wbc->sync_mode == WB_SYNC_ALL;
if (inode->i_nlink == 0)
return 0;
/*
* If COMMIT_DIRTY is not set, the inode isn't really dirty.
* It has been committed since the last change, but was still
* on the dirty inode list.
*/
if (!test_cflag(COMMIT_Dirty, inode)) {
/* Make sure committed changes hit the disk */
jfs_flush_journal(JFS_SBI(inode->i_sb)->log, wait);
return 0;
}
if (jfs_commit_inode(inode, wait)) {
Annotation
- Immediate include surface: `linux/fs.h`, `linux/mpage.h`, `linux/buffer_head.h`, `linux/pagemap.h`, `linux/quotaops.h`, `linux/uio.h`, `linux/writeback.h`, `jfs_incore.h`.
- Detected declarations: `function Copyright`, `function S_ISFIFO`, `function jfs_commit_inode`, `function jfs_write_inode`, `function jfs_evict_inode`, `function jfs_dirty_inode`, `function jfs_get_block`, `function jfs_writepages`, `function jfs_read_folio`, `function jfs_readahead`.
- 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.