fs/ntfs/index.c
Source file repositories/reference/linux-study-clean/fs/ntfs/index.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ntfs/index.c- Extension
.c- Size
- 54587 bytes
- Lines
- 2231
- 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.
- 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
collate.hindex.hntfs.hattrlist.h
Detected Declarations
struct split_infofunction Copyrightfunction ntfs_index_entry_mark_dirtyfunction ntfs_ib_vcn_to_posfunction ntfs_ib_pos_to_vcnfunction ntfs_ib_writefunction ntfs_icx_ib_writefunction ntfs_icx_ib_sync_writefunction ntfs_index_ctx_freefunction ntfs_index_ctx_putfunction ntfs_index_ctx_reinitfunction ntfs_ie_get_vcnfunction ntfs_ie_endfunction ntfs_index_header_inconsistentfunction ntfs_index_entries_inconsistentfunction ntfs_ih_numof_entriesfunction ntfs_ih_one_entryfunction ntfs_ih_zero_entryfunction ntfs_ie_deletefunction ntfs_ie_set_vcnfunction ntfs_ie_insertfunction sizefunction ntfs_index_root_inconsistentfunction ntfs_ie_lookupfunction ntfs_ib_readfunction ntfs_icx_parent_incfunction ntfs_icx_parent_decfunction ntfs_index_lookupfunction ntfs_ibm_vcn_to_posfunction ntfs_ibm_pos_to_vcnfunction ntfs_ibm_addfunction ntfs_ibm_modifyfunction ntfs_ibm_setfunction ntfs_ibm_clearfunction ntfs_ibm_get_freefunction ntfs_ir_nillfunction ntfs_ib_copy_tailfunction ntfs_ib_cut_tailfunction ntfs_ia_addfunction ntfs_ir_reparentfunction ntfs_ir_truncatefunction ntfs_ir_make_spacefunction ntfs_ie_add_vcnfunction ntfs_ih_insertfunction ntfs_icx_parent_vcnfunction ntfs_icx_parent_posfunction ntfs_ir_insert_medianfunction ntfs_ib_insert
Annotated Snippet
struct split_info {
struct list_head entry;
s64 new_vcn;
struct index_block *ib;
};
static int ntfs_ib_insert(struct ntfs_index_context *icx, struct index_entry *ie, s64 new_vcn,
struct split_info *si)
{
struct index_block *ib;
u32 idx_size, allocated_size;
int err;
s64 old_vcn;
ntfs_debug("Entering\n");
ib = kvzalloc(icx->block_size, GFP_NOFS);
if (!ib)
return -ENOMEM;
old_vcn = ntfs_icx_parent_vcn(icx);
err = ntfs_ib_read(icx, old_vcn, ib);
if (err)
goto err_out;
idx_size = le32_to_cpu(ib->index.index_length);
allocated_size = le32_to_cpu(ib->index.allocated_size);
if (idx_size + le16_to_cpu(ie->length) + sizeof(s64) > allocated_size) {
si->ib = ib;
si->new_vcn = new_vcn;
return -EAGAIN;
}
err = ntfs_ih_insert(&ib->index, ie, new_vcn, ntfs_icx_parent_pos(icx));
if (err)
goto err_out;
err = ntfs_ib_write(icx, ib);
err_out:
kvfree(ib);
return err;
}
/*
* ntfs_ib_split - Split an index block
* @icx: index context
* @ib: index block to split
*/
static int ntfs_ib_split(struct ntfs_index_context *icx, struct index_block *ib)
{
struct index_entry *median;
s64 new_vcn;
int ret;
struct split_info *si;
LIST_HEAD(ntfs_cut_tail_list);
ntfs_debug("Entering\n");
resplit:
ret = ntfs_icx_parent_dec(icx);
if (ret)
goto out;
median = ntfs_ie_get_median(&ib->index);
new_vcn = ntfs_ibm_get_free(icx);
if (new_vcn < 0) {
ret = -EINVAL;
goto out;
}
ret = ntfs_ib_copy_tail(icx, ib, median, new_vcn);
if (ret) {
ntfs_ibm_clear(icx, new_vcn);
goto out;
}
if (ntfs_icx_parent_vcn(icx) == VCN_INDEX_ROOT_PARENT) {
ret = ntfs_ir_insert_median(icx, median, new_vcn);
if (ret) {
ntfs_ibm_clear(icx, new_vcn);
goto out;
}
} else {
si = kzalloc(sizeof(struct split_info), GFP_NOFS);
if (!si) {
ntfs_ibm_clear(icx, new_vcn);
ret = -ENOMEM;
goto out;
Annotation
- Immediate include surface: `collate.h`, `index.h`, `ntfs.h`, `attrlist.h`.
- Detected declarations: `struct split_info`, `function Copyright`, `function ntfs_index_entry_mark_dirty`, `function ntfs_ib_vcn_to_pos`, `function ntfs_ib_pos_to_vcn`, `function ntfs_ib_write`, `function ntfs_icx_ib_write`, `function ntfs_icx_ib_sync_write`, `function ntfs_index_ctx_free`, `function ntfs_index_ctx_put`.
- 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.