fs/gfs2/inode.c
Source file repositories/reference/linux-study-clean/fs/gfs2/inode.c
File Facts
- System
- Linux kernel
- Corpus path
fs/gfs2/inode.c- Extension
.c- Size
- 56272 bytes
- Lines
- 2340
- 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.
- 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/slab.hlinux/spinlock.hlinux/completion.hlinux/buffer_head.hlinux/namei.hlinux/mm.hlinux/cred.hlinux/xattr.hlinux/posix_acl.hlinux/gfs2_ondisk.hlinux/crc32.hlinux/iomap.hlinux/security.hlinux/fiemap.hlinux/uaccess.hgfs2.hincore.hacl.hbmap.hdir.hxattr.hglock.hinode.hmeta_io.hquota.hrgrp.htrans.hutil.hsuper.hglops.h
Detected Declarations
function gfs2_inode_lookupfunction iget_testfunction iget_setfunction gfs2_setup_inodefunction create_okfunction munge_mode_uid_gidfunction alloc_dinodefunction gfs2_final_release_pagesfunction gfs2_dinode_deallocfunction gfs2_init_dirfunction gfs2_init_xattrfunction init_dinodefunction gfs2_trans_da_blksfunction link_dinodefunction gfs2_initxattrsfunction gfs2_create_inodefunction gfs2_createfunction gfs2_linkfunction onfunction gfs2_unlink_inodefunction gfs2_unlinkfunction gfs2_symlinkfunction gfs2_mknodfunction gfs2_atomic_openfunction gfs2_ok_to_movefunction update_moved_inofunction gfs2_renamefunction gfs2_exchangefunction gfs2_rename2function gfs2_permissionfunction __gfs2_setattr_simplefunction gfs2_setattr_simplefunction setattr_chownfunction gfs2_setattrfunction calledfunction fault_in_fiemapfunction gfs2_fiemapfunction gfs2_seek_datafunction gfs2_seek_holefunction gfs2_update_time
Annotated Snippet
if (type == DT_UNKNOWN || blktype != GFS2_BLKST_FREE) {
/*
* The GL_SKIP flag indicates to skip reading the inode
* block. We read the inode when instantiating it
* after possibly checking the block type.
*/
error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE,
GL_SKIP, &i_gh);
if (error)
goto fail;
error = -ESTALE;
if (no_formal_ino &&
gfs2_inode_already_deleted(ip->i_gl, no_formal_ino))
goto fail;
if (blktype != GFS2_BLKST_FREE) {
error = gfs2_check_blk_type(sdp, no_addr,
blktype);
if (error)
goto fail;
}
}
set_bit(GLF_INSTANTIATE_NEEDED, &ip->i_gl->gl_flags);
/* Lowest possible timestamp; will be overwritten in gfs2_dinode_in. */
inode_set_atime(inode,
1LL << (8 * sizeof(inode_get_atime_sec(inode)) - 1),
0);
glock_set_object(ip->i_gl, ip);
if (type == DT_UNKNOWN) {
/* Inode glock must be locked already */
error = gfs2_instantiate(&i_gh);
if (error) {
glock_clear_object(ip->i_gl, ip);
goto fail;
}
} else {
ip->i_no_formal_ino = no_formal_ino;
inode->i_mode = DT2IF(type);
}
if (gfs2_holder_initialized(&i_gh))
gfs2_glock_dq_uninit(&i_gh);
glock_set_object(ip->i_iopen_gh.gh_gl, ip);
gfs2_set_iop(inode);
unlock_new_inode(inode);
}
if (no_formal_ino && ip->i_no_formal_ino &&
no_formal_ino != ip->i_no_formal_ino) {
iput(inode);
return ERR_PTR(-ESTALE);
}
return inode;
fail:
if (error == GLR_TRYFAILED)
error = -EAGAIN;
if (gfs2_holder_initialized(&ip->i_iopen_gh))
gfs2_glock_dq_uninit(&ip->i_iopen_gh);
if (gfs2_holder_initialized(&i_gh))
gfs2_glock_dq_uninit(&i_gh);
if (ip->i_gl) {
gfs2_glock_put(ip->i_gl);
ip->i_gl = NULL;
}
iget_failed(inode);
return ERR_PTR(error);
}
/**
* gfs2_lookup_by_inum - look up an inode by inode number
* @sdp: The super block
* @no_addr: The inode number
* @no_formal_ino: The inode generation number (0 for any)
* @blktype: Requested block type (see gfs2_inode_lookup)
*/
struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr,
u64 no_formal_ino, unsigned int blktype)
{
struct super_block *sb = sdp->sd_vfs;
struct inode *inode;
int error;
Annotation
- Immediate include surface: `linux/slab.h`, `linux/spinlock.h`, `linux/completion.h`, `linux/buffer_head.h`, `linux/namei.h`, `linux/mm.h`, `linux/cred.h`, `linux/xattr.h`.
- Detected declarations: `function gfs2_inode_lookup`, `function iget_test`, `function iget_set`, `function gfs2_setup_inode`, `function create_ok`, `function munge_mode_uid_gid`, `function alloc_dinode`, `function gfs2_final_release_pages`, `function gfs2_dinode_dealloc`, `function gfs2_init_dir`.
- 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.