fs/xfs/libxfs/xfs_metadir.c
Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_metadir.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/libxfs/xfs_metadir.c- Extension
.c- Size
- 11885 bytes
- Lines
- 486
- 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_shared.hxfs_format.hxfs_log_format.hxfs_trans_resv.hxfs_bit.hxfs_sb.hxfs_mount.hxfs_defer.hxfs_trans.hxfs_metafile.hxfs_metadir.hxfs_trace.hxfs_inode.hxfs_quota.hxfs_ialloc.hxfs_bmap_btree.hxfs_da_format.hxfs_da_btree.hxfs_trans_space.hxfs_ag.hxfs_dir2.hxfs_dir2_priv.hxfs_parent.hxfs_health.hxfs_errortag.hxfs_error.hxfs_btree.hxfs_alloc.h
Detected Declarations
function xfs_metadir_set_xnamefunction xfs_metadir_lookupfunction xfs_metadir_loadfunction committingfunction xfs_metadir_start_createfunction xfs_metadir_createfunction xfs_metadir_start_linkfunction pathfunction xfs_metadir_commitfunction xfs_metadir_cancelfunction xfs_metadir_mkdir
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) 2018-2024 Oracle. All Rights Reserved.
* Author: Darrick J. Wong <djwong@kernel.org>
*/
#include "xfs_platform.h"
#include "xfs_fs.h"
#include "xfs_shared.h"
#include "xfs_format.h"
#include "xfs_log_format.h"
#include "xfs_trans_resv.h"
#include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_mount.h"
#include "xfs_defer.h"
#include "xfs_trans.h"
#include "xfs_metafile.h"
#include "xfs_metadir.h"
#include "xfs_trace.h"
#include "xfs_inode.h"
#include "xfs_quota.h"
#include "xfs_ialloc.h"
#include "xfs_bmap_btree.h"
#include "xfs_da_format.h"
#include "xfs_da_btree.h"
#include "xfs_trans_space.h"
#include "xfs_ag.h"
#include "xfs_dir2.h"
#include "xfs_dir2_priv.h"
#include "xfs_parent.h"
#include "xfs_health.h"
#include "xfs_errortag.h"
#include "xfs_error.h"
#include "xfs_btree.h"
#include "xfs_alloc.h"
/*
* Metadata Directory Tree
* =======================
*
* These functions provide an abstraction layer for looking up, creating, and
* deleting metadata inodes that live within a special metadata directory tree.
*
* This code does not manage the five existing metadata inodes: real time
* bitmap & summary; and the user, group, and quotas. All other metadata
* inodes must use only the xfs_meta{dir,file}_* functions.
*
* Callers wishing to create or hardlink a metadata inode must create an
* xfs_metadir_update structure, call the appropriate xfs_metadir* function,
* and then call xfs_metadir_commit or xfs_metadir_cancel to commit or cancel
* the update. Files in the metadata directory tree currently cannot be
* unlinked.
*
* When the metadir feature is enabled, all metadata inodes must have the
* "metadata" inode flag set to prevent them from being exposed to the outside
* world.
*
* Callers must take the ILOCK of any inode in the metadata directory tree to
* synchronize access to that inode. It is never necessary to take the IOLOCK
* or the MMAPLOCK since metadata inodes must not be exposed to user space.
*/
static inline void
xfs_metadir_set_xname(
struct xfs_name *xname,
const char *path,
unsigned char ftype)
{
xname->name = (const unsigned char *)path;
xname->len = strlen(path);
xname->type = ftype;
}
/*
* Given a parent directory @dp and a metadata inode path component @xname,
* Look up the inode number in the directory, returning it in @ino.
* @xname.type must match the directory entry's ftype.
*
* Caller must hold ILOCK_EXCL.
*/
static inline int
xfs_metadir_lookup(
struct xfs_trans *tp,
struct xfs_inode *dp,
struct xfs_name *xname,
xfs_ino_t *ino)
{
struct xfs_mount *mp = dp->i_mount;
struct xfs_da_args args = {
.trans = tp,
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_bit.h`, `xfs_sb.h`.
- Detected declarations: `function xfs_metadir_set_xname`, `function xfs_metadir_lookup`, `function xfs_metadir_load`, `function committing`, `function xfs_metadir_start_create`, `function xfs_metadir_create`, `function xfs_metadir_start_link`, `function path`, `function xfs_metadir_commit`, `function xfs_metadir_cancel`.
- 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.