fs/xfs/scrub/xfarray.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/xfarray.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/xfarray.c- Extension
.c- Size
- 28315 bytes
- Lines
- 1074
- 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
xfs_platform.hxfs_fs.hxfs_shared.hxfs_format.hscrub/scrub.hscrub/xfile.hscrub/xfarray.hscrub/trace.h
Detected Declarations
function Copyrightfunction xfarray_idxfunction xfarray_posfunction xfarray_createfunction xfarray_destroyfunction xfarray_loadfunction xfarray_is_unsetfunction xfarray_unsetfunction xfarray_storefunction xfarray_element_is_nullfunction xfarray_store_anywherefunction xfarray_lengthfunction afunction xfarray_load_nextfunction xfarray_sort_loadfunction xfarray_sort_storefunction xfarray_sort_cmpfunction xfarray_pivot_rec_szfunction xfarray_sortinfo_allocfunction xfarray_sort_terminatedfunction xfarray_want_isortfunction xfarray_isortfunction hifunction xfarray_sortinfo_pivot_arrayfunction xfarray_pivot_array_recfunction xfarray_pivot_array_idxfunction xfarray_qsort_pivotfunction xfarray_qsort_pushfunction xfarray_sort_scan_donefunction xfarray_sort_scanfunction behaviorfunction xfarray_bytesfunction xfarray_truncate
Annotated Snippet
if (array->max_nr < required_capacity) {
error = -ENOMEM;
goto out_xfarray;
}
array->max_nr = required_capacity;
}
*arrayp = array;
return 0;
out_xfarray:
kfree(array);
out_xfile:
xfile_destroy(xfile);
return error;
}
/* Destroy the array. */
void
xfarray_destroy(
struct xfarray *array)
{
xfile_destroy(array->xfile);
kfree(array);
}
/* Load an element from the array. */
int
xfarray_load(
struct xfarray *array,
xfarray_idx_t idx,
void *ptr)
{
if (idx >= array->nr)
return -ENODATA;
return xfile_load(array->xfile, ptr, array->obj_size,
xfarray_pos(array, idx));
}
/* Is this array element potentially unset? */
static inline bool
xfarray_is_unset(
struct xfarray *array,
loff_t pos)
{
void *temp = xfarray_scratch(array);
int error;
if (array->unset_slots == 0)
return false;
error = xfile_load(array->xfile, temp, array->obj_size, pos);
if (!error && xfarray_element_is_null(array, temp))
return true;
return false;
}
/*
* Unset an array element. If @idx is the last element in the array, the
* array will be truncated. Otherwise, the entry will be zeroed.
*/
int
xfarray_unset(
struct xfarray *array,
xfarray_idx_t idx)
{
void *temp = xfarray_scratch(array);
loff_t pos = xfarray_pos(array, idx);
int error;
if (idx >= array->nr)
return -ENODATA;
if (idx == array->nr - 1) {
array->nr--;
return 0;
}
if (xfarray_is_unset(array, pos))
return 0;
memset(temp, 0, array->obj_size);
error = xfile_store(array->xfile, temp, array->obj_size, pos);
if (error)
return error;
array->unset_slots++;
return 0;
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `scrub/scrub.h`, `scrub/xfile.h`, `scrub/xfarray.h`, `scrub/trace.h`.
- Detected declarations: `function Copyright`, `function xfarray_idx`, `function xfarray_pos`, `function xfarray_create`, `function xfarray_destroy`, `function xfarray_load`, `function xfarray_is_unset`, `function xfarray_unset`, `function xfarray_store`, `function xfarray_element_is_null`.
- 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.