fs/xfs/libxfs/xfs_attr_leaf.c
Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_attr_leaf.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/libxfs/xfs_attr_leaf.c- Extension
.c- Size
- 89760 bytes
- Lines
- 3148
- 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
xfs_platform.hxfs_fs.hxfs_shared.hxfs_format.hxfs_log_format.hxfs_trans_resv.hxfs_sb.hxfs_mount.hxfs_da_format.hxfs_da_btree.hxfs_inode.hxfs_trans.hxfs_bmap_btree.hxfs_bmap.hxfs_attr_sf.hxfs_attr.hxfs_attr_remote.hxfs_attr_leaf.hxfs_error.hxfs_trace.hxfs_buf_item.hxfs_dir2.hxfs_log.hxfs_ag.hxfs_errortag.hxfs_health.h
Detected Declarations
function xfs_attr_leaf_entries_endfunction ichdr_freemaps_overlapfunction xfs_attr_leaf_ichdr_freemaps_verifyfunction xfs_attr3_leaf_firstused_from_diskfunction xfs_attr3_leaf_firstused_to_diskfunction xfs_attr3_leaf_hdr_from_diskfunction xfs_attr3_leaf_hdr_to_diskfunction xfs_attr3_leaf_verify_entryfunction xfs_attr3_leaf_verifyfunction xfs_attr3_leaf_header_checkfunction xfs_attr3_leaf_write_verifyfunction xfs_attr3_leaf_read_verifyfunction xfs_attr3_leaf_readfunction xfs_attr_match_maskfunction xfs_attr_parent_matchfunction xfs_attr_matchfunction xfs_attr_copy_valuefunction xfs_attr_shortform_bytesfitfunction bitfunction xfs_attr_shortform_createfunction xfs_attr_sf_findnamefunction xfs_attr_shortform_replacefunction xfs_attr_shortform_addfunction xfs_attr_fork_removefunction xfs_attr_sf_removenamefunction xfs_attr_shortform_getvaluefunction xfs_attr_shortform_to_leaffunction xfs_attr_shortform_allfitfunction xfs_attr_shortform_verifyfunction xfs_attr3_leaf_to_shortformfunction xfs_attr3_leaf_to_nodefunction xfs_attr3_leaf_createfunction xfs_attr3_leaf_initfunction xfs_attr3_leaf_splitfunction xfs_attr3_leaf_addfunction xfs_attr3_leaf_add_workfunction transactionfunction xfs_attr3_leaf_compactfunction xfs_attr3_leaf_orderfunction be32_to_cpufunction xfs_attr_leaf_orderfunction xfs_attr3_leaf_rebalancefunction xfs_attr3_leaf_figure_balancefunction xfs_attr3_leaf_toosmallfunction xfs_attr3_leaf_removefunction regionfunction xfs_attr3_leaf_unbalancefunction xfs_attr3_leaf_lookup_int
Annotated Snippet
if (dp->i_forkoff) {
if (offset < dp->i_forkoff)
return 0;
return dp->i_forkoff;
}
dsize = xfs_bmap_bmdr_space(dp->i_df.if_broot);
break;
}
/*
* A data fork btree root must have space for at least
* MINDBTPTRS key/ptr pairs if the data fork is small or empty.
*/
minforkoff = max_t(int64_t, dsize, xfs_bmdr_space_calc(MINDBTPTRS));
minforkoff = roundup(minforkoff, 8) >> 3;
/* attr fork btree root can have at least this many key/ptr pairs */
maxforkoff = XFS_LITINO(mp) - xfs_bmdr_space_calc(MINABTPTRS);
maxforkoff = maxforkoff >> 3; /* rounded down */
if (offset >= maxforkoff)
return maxforkoff;
if (offset >= minforkoff)
return offset;
return 0;
}
/*
* Switch on the ATTR2 superblock bit (implies also FEATURES2) unless
* on-disk version bit says it is already set
*/
STATIC void
xfs_sbversion_add_attr2(
struct xfs_mount *mp,
struct xfs_trans *tp)
{
if (mp->m_sb.sb_features2 & XFS_SB_VERSION2_ATTR2BIT)
return;
spin_lock(&mp->m_sb_lock);
xfs_add_attr2(mp);
spin_unlock(&mp->m_sb_lock);
xfs_log_sb(tp);
}
/*
* Create the initial contents of a shortform attribute list.
*/
void
xfs_attr_shortform_create(
struct xfs_da_args *args)
{
struct xfs_inode *dp = args->dp;
struct xfs_ifork *ifp = &dp->i_af;
struct xfs_attr_sf_hdr *hdr;
trace_xfs_attr_sf_create(args);
ASSERT(ifp->if_bytes == 0);
if (ifp->if_format == XFS_DINODE_FMT_EXTENTS)
ifp->if_format = XFS_DINODE_FMT_LOCAL;
hdr = xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK);
memset(hdr, 0, sizeof(*hdr));
hdr->totsize = cpu_to_be16(sizeof(*hdr));
xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
}
/*
* Return the entry if the attr in args is found, or NULL if not.
*/
struct xfs_attr_sf_entry *
xfs_attr_sf_findname(
struct xfs_da_args *args)
{
struct xfs_attr_sf_hdr *sf = args->dp->i_af.if_data;
struct xfs_attr_sf_entry *sfe;
for (sfe = xfs_attr_sf_firstentry(sf);
sfe < xfs_attr_sf_endptr(sf);
sfe = xfs_attr_sf_nextentry(sfe)) {
if (xfs_attr_match(args, sfe->flags, sfe->nameval,
sfe->namelen, &sfe->nameval[sfe->namelen],
sfe->valuelen))
return sfe;
}
return NULL;
}
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_log_format.h`, `xfs_trans_resv.h`, `xfs_sb.h`, `xfs_mount.h`.
- Detected declarations: `function xfs_attr_leaf_entries_end`, `function ichdr_freemaps_overlap`, `function xfs_attr_leaf_ichdr_freemaps_verify`, `function xfs_attr3_leaf_firstused_from_disk`, `function xfs_attr3_leaf_firstused_to_disk`, `function xfs_attr3_leaf_hdr_from_disk`, `function xfs_attr3_leaf_hdr_to_disk`, `function xfs_attr3_leaf_verify_entry`, `function xfs_attr3_leaf_verify`, `function xfs_attr3_leaf_header_check`.
- 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.