fs/xfs/libxfs/xfs_parent.c
Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_parent.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/libxfs/xfs_parent.c- Extension
.c- Size
- 9934 bytes
- Lines
- 381
- 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
xfs_platform.hxfs_fs.hxfs_format.hxfs_da_format.hxfs_log_format.hxfs_shared.hxfs_trans_resv.hxfs_mount.hxfs_bmap_btree.hxfs_inode.hxfs_error.hxfs_trace.hxfs_trans.hxfs_da_btree.hxfs_attr.hxfs_dir2.hxfs_dir2_priv.hxfs_attr_sf.hxfs_bmap.hxfs_defer.hxfs_xattr.hxfs_parent.hxfs_trans_space.hxfs_attr_item.hxfs_health.hxfs_attr_leaf.h
Detected Declarations
function xfs_attr_leaf_entsize_local_maxfunction xfs_parent_valuecheckfunction xfs_parent_hashvalfunction xfs_parent_hashattrfunction xfs_parent_da_args_initfunction xfs_parent_iread_extentsfunction xfs_parent_addnamefunction xfs_parent_removenamefunction xfs_parent_replacenamefunction xfs_parent_from_attrfunction recordfunction xfs_parent_sanity_checkfunction pointerfunction pointer
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2022-2024 Oracle.
* All rights reserved.
*/
#include "xfs_platform.h"
#include "xfs_fs.h"
#include "xfs_format.h"
#include "xfs_da_format.h"
#include "xfs_log_format.h"
#include "xfs_shared.h"
#include "xfs_trans_resv.h"
#include "xfs_mount.h"
#include "xfs_bmap_btree.h"
#include "xfs_inode.h"
#include "xfs_error.h"
#include "xfs_trace.h"
#include "xfs_trans.h"
#include "xfs_da_btree.h"
#include "xfs_attr.h"
#include "xfs_dir2.h"
#include "xfs_dir2_priv.h"
#include "xfs_attr_sf.h"
#include "xfs_bmap.h"
#include "xfs_defer.h"
#include "xfs_xattr.h"
#include "xfs_parent.h"
#include "xfs_trans_space.h"
#include "xfs_attr_item.h"
#include "xfs_health.h"
#include "xfs_attr_leaf.h"
struct kmem_cache *xfs_parent_args_cache;
/*
* Parent pointer attribute handling.
*
* Because the attribute name is a filename component, it will never be longer
* than 255 bytes and must not contain nulls or slashes. These are roughly the
* same constraints that apply to attribute names.
*
* The attribute value must always be a struct xfs_parent_rec. This means the
* attribute will never be in remote format because 12 bytes is nowhere near
* xfs_attr_leaf_entsize_local_max() (~75% of block size).
*
* Creating a new parent attribute will always create a new attribute - there
* should never, ever be an existing attribute in the tree for a new inode.
* ENOSPC behavior is problematic - creating the inode without the parent
* pointer is effectively a corruption, so we allow parent attribute creation
* to dip into the reserve block pool to avoid unexpected ENOSPC errors from
* occurring.
*/
/* Return true if parent pointer attr name is valid. */
bool
xfs_parent_namecheck(
unsigned int attr_flags,
const void *name,
size_t length)
{
/*
* Parent pointers always use logged operations, so there should never
* be incomplete xattrs.
*/
if (attr_flags & XFS_ATTR_INCOMPLETE)
return false;
return xfs_dir2_namecheck(name, length);
}
/* Return true if parent pointer attr value is valid. */
bool
xfs_parent_valuecheck(
struct xfs_mount *mp,
const void *value,
size_t valuelen)
{
const struct xfs_parent_rec *rec = value;
if (!xfs_has_parent(mp))
return false;
/* The xattr value must be a parent record. */
if (valuelen != sizeof(struct xfs_parent_rec))
return false;
/* The parent record must be local. */
if (value == NULL)
return false;
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_format.h`, `xfs_da_format.h`, `xfs_log_format.h`, `xfs_shared.h`, `xfs_trans_resv.h`, `xfs_mount.h`.
- Detected declarations: `function xfs_attr_leaf_entsize_local_max`, `function xfs_parent_valuecheck`, `function xfs_parent_hashval`, `function xfs_parent_hashattr`, `function xfs_parent_da_args_init`, `function xfs_parent_iread_extents`, `function xfs_parent_addname`, `function xfs_parent_removename`, `function xfs_parent_replacename`, `function xfs_parent_from_attr`.
- 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.