fs/ceph/inode.c
Source file repositories/reference/linux-study-clean/fs/ceph/inode.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ceph/inode.c- Extension
.c- Size
- 92691 bytes
- Lines
- 3258
- 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/ceph/ceph_debug.hlinux/module.hlinux/fs.hlinux/slab.hlinux/string.hlinux/uaccess.hlinux/kernel.hlinux/writeback.hlinux/vmalloc.hlinux/xattr.hlinux/posix_acl.hlinux/random.hlinux/sort.hlinux/iversion.hlinux/fscrypt.hsuper.hmds_client.hcache.hcrypto.hlinux/ceph/decode.h
Detected Declarations
function ceph_set_ino_cbfunction ceph_vino_matches_parentfunction handle_replyfunction ceph_as_ctx_to_reqfunction inodefunction __ceph_choose_fragfunction ceph_choose_fragfunction dirfragfunction frag_tree_split_cmpfunction is_frag_childfunction ceph_fill_fragtreefunction ceph_free_inodefunction ceph_evict_inodefunction calc_inode_blocksfunction truncatefunction CEPH_SUBVOLUME_ID_NONEfunction ceph_fill_file_timefunction decode_encrypted_symlinkfunction decode_encrypted_symlinkfunction ceph_fill_inodefunction le64_to_cpufunction __update_dentry_leasefunction update_dentry_leasefunction update_dentry_lease_carefulfunction splice_dentryfunction snap_rwsemfunction ceph_snapfunction test_bitfunction test_bitfunction readdir_prepopulate_inodes_onlyfunction ceph_readdir_cache_releasefunction fill_readdir_cachefunction ceph_readdir_prepopulatefunction ceph_snapfunction ceph_inode_set_sizefunction ceph_queue_inode_workfunction ceph_do_invalidate_pagesfunction __ceph_do_pending_vmtruncatefunction ceph_inode_workfunction ceph_encrypted_symlink_getattrfunction fill_fscrypt_truncatefunction __ceph_setattrfunction memcmpfunction timespec64_comparefunction timespec64_comparefunction ceph_setattrfunction ceph_try_to_choose_auth_mdsfunction __ceph_do_getattr
Annotated Snippet
if (ci->fscrypt_auth) {
inode->i_flags |= S_ENCRYPTED;
ci->fscrypt_auth_len = pci->fscrypt_auth_len;
} else {
doutc(cl, "Failed to alloc snapdir fscrypt_auth\n");
ret = -ENOMEM;
goto err;
}
}
#endif
if (inode_state_read_once(inode) & I_NEW) {
inode->i_op = &ceph_snapdir_iops;
inode->i_fop = &ceph_snapdir_fops;
ci->i_snap_caps = CEPH_CAP_PIN; /* so we can open */
unlock_new_inode(inode);
}
return inode;
err:
if ((inode_state_read_once(inode) & I_NEW))
discard_new_inode(inode);
else
iput(inode);
return ERR_PTR(ret);
}
const struct inode_operations ceph_file_iops = {
.permission = ceph_permission,
.setattr = ceph_setattr,
.getattr = ceph_getattr,
.listxattr = ceph_listxattr,
.get_inode_acl = ceph_get_acl,
.set_acl = ceph_set_acl,
};
/*
* We use a 'frag tree' to keep track of the MDS's directory fragments
* for a given inode (usually there is just a single fragment). We
* need to know when a child frag is delegated to a new MDS, or when
* it is flagged as replicated, so we can direct our requests
* accordingly.
*/
/*
* find/create a frag in the tree
*/
static struct ceph_inode_frag *__get_or_create_frag(struct ceph_inode_info *ci,
u32 f)
{
struct inode *inode = &ci->netfs.inode;
struct ceph_client *cl = ceph_inode_to_client(inode);
struct rb_node **p;
struct rb_node *parent = NULL;
struct ceph_inode_frag *frag;
int c;
p = &ci->i_fragtree.rb_node;
while (*p) {
parent = *p;
frag = rb_entry(parent, struct ceph_inode_frag, node);
c = ceph_frag_compare(f, frag->frag);
if (c < 0)
p = &(*p)->rb_left;
else if (c > 0)
p = &(*p)->rb_right;
else
return frag;
}
frag = kmalloc_obj(*frag, GFP_NOFS);
if (!frag)
return ERR_PTR(-ENOMEM);
frag->frag = f;
frag->split_by = 0;
frag->mds = -1;
frag->ndist = 0;
rb_link_node(&frag->node, parent, p);
rb_insert_color(&frag->node, &ci->i_fragtree);
doutc(cl, "added %p %llx.%llx frag %x\n", inode, ceph_vinop(inode), f);
return frag;
}
/*
* find a specific frag @f
*/
struct ceph_inode_frag *__ceph_find_frag(struct ceph_inode_info *ci, u32 f)
Annotation
- Immediate include surface: `linux/ceph/ceph_debug.h`, `linux/module.h`, `linux/fs.h`, `linux/slab.h`, `linux/string.h`, `linux/uaccess.h`, `linux/kernel.h`, `linux/writeback.h`.
- Detected declarations: `function ceph_set_ino_cb`, `function ceph_vino_matches_parent`, `function handle_reply`, `function ceph_as_ctx_to_req`, `function inode`, `function __ceph_choose_frag`, `function ceph_choose_frag`, `function dirfrag`, `function frag_tree_split_cmp`, `function is_frag_child`.
- 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.