fs/btrfs/inode-item.c
Source file repositories/reference/linux-study-clean/fs/btrfs/inode-item.c
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/inode-item.c- Extension
.c- Size
- 20218 bytes
- Lines
- 734
- 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
ctree.hfs.hmessages.hinode-item.hdisk-io.htransaction.hspace-info.haccessors.hextent-tree.hfile-item.h
Detected Declarations
function Copyrightfunction btrfs_del_inode_extreffunction btrfs_del_inode_reffunction btrfs_insert_inode_extreffunction btrfs_insert_inode_reffunction btrfs_insert_empty_inodefunction btrfs_lookup_inodefunction btrfs_trace_truncatefunction btrfs_truncate_inode_itemsfunction btrfs_should_end_transaction
Annotated Snippet
if (ret == -EOVERFLOW) {
if (btrfs_find_name_in_backref(path->nodes[0],
path->slots[0],
name))
ret = -EEXIST;
else
ret = -EMLINK;
}
goto out;
} else {
ref = btrfs_item_ptr(path->nodes[0], path->slots[0],
struct btrfs_inode_ref);
btrfs_set_inode_ref_name_len(path->nodes[0], ref, name->len);
btrfs_set_inode_ref_index(path->nodes[0], ref, index);
ptr = (unsigned long)(ref + 1);
}
write_extent_buffer(path->nodes[0], name->name, ptr, name->len);
out:
btrfs_free_path(path);
if (ret == -EMLINK) {
struct btrfs_super_block *disk_super = fs_info->super_copy;
/* We ran out of space in the ref array. Need to
* add an extended ref. */
if (btrfs_super_incompat_flags(disk_super)
& BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF)
ret = btrfs_insert_inode_extref(trans, root, name,
inode_objectid,
ref_objectid, index);
}
return ret;
}
int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
struct btrfs_path *path, u64 objectid)
{
struct btrfs_key key;
key.objectid = objectid;
key.type = BTRFS_INODE_ITEM_KEY;
key.offset = 0;
return btrfs_insert_empty_item(trans, root, path, &key,
sizeof(struct btrfs_inode_item));
}
int btrfs_lookup_inode(struct btrfs_trans_handle *trans, struct btrfs_root
*root, struct btrfs_path *path,
struct btrfs_key *location, int mod)
{
int ins_len = mod < 0 ? -1 : 0;
int cow = mod != 0;
int ret;
int slot;
struct extent_buffer *leaf;
struct btrfs_key found_key;
ret = btrfs_search_slot(trans, root, location, path, ins_len, cow);
if (ret > 0 && location->type == BTRFS_ROOT_ITEM_KEY &&
location->offset == (u64)-1 && path->slots[0] != 0) {
slot = path->slots[0] - 1;
leaf = path->nodes[0];
btrfs_item_key_to_cpu(leaf, &found_key, slot);
if (found_key.objectid == location->objectid &&
found_key.type == location->type) {
path->slots[0]--;
return 0;
}
}
return ret;
}
static inline void btrfs_trace_truncate(const struct btrfs_inode *inode,
const struct extent_buffer *leaf,
const struct btrfs_file_extent_item *fi,
u64 offset, int extent_type, int slot)
{
if (!inode)
return;
if (extent_type == BTRFS_FILE_EXTENT_INLINE)
trace_btrfs_truncate_show_fi_inline(inode, leaf, fi, slot,
offset);
else
trace_btrfs_truncate_show_fi_regular(inode, leaf, fi, offset);
}
/*
* Remove inode items from a given root.
Annotation
- Immediate include surface: `ctree.h`, `fs.h`, `messages.h`, `inode-item.h`, `disk-io.h`, `transaction.h`, `space-info.h`, `accessors.h`.
- Detected declarations: `function Copyright`, `function btrfs_del_inode_extref`, `function btrfs_del_inode_ref`, `function btrfs_insert_inode_extref`, `function btrfs_insert_inode_ref`, `function btrfs_insert_empty_inode`, `function btrfs_lookup_inode`, `function btrfs_trace_truncate`, `function btrfs_truncate_inode_items`, `function btrfs_should_end_transaction`.
- 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.