fs/xfs/xfs_itable.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_itable.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_itable.c- Extension
.c- Size
- 13494 bytes
- Lines
- 485
- 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.hxfs_log_format.hxfs_trans_resv.hxfs_mount.hxfs_inode.hxfs_btree.hxfs_ialloc.hxfs_ialloc_btree.hxfs_iwalk.hxfs_itable.hxfs_error.hxfs_icache.hxfs_health.hxfs_trans.h
Detected Declarations
struct xfs_bstat_chunkstruct xfs_inumbers_chunkfunction want_metadir_filefunction xfs_bulkstat_one_intfunction xfs_bulkstat_onefunction xfs_bulkstat_iwalkfunction xfs_bulkstat_already_donefunction xfs_bulkstatfunction xfs_bulkstat_to_bstatfunction xfs_inumbers_walkfunction xfs_inumbersfunction xfs_inumbers_to_inogrp
Annotated Snippet
struct xfs_bstat_chunk {
bulkstat_one_fmt_pf formatter;
struct xfs_ibulk *breq;
struct xfs_bulkstat *buf;
};
static inline bool
want_metadir_file(
struct xfs_inode *ip,
struct xfs_ibulk *breq)
{
return xfs_is_metadir_inode(ip) && (breq->flags & XFS_IBULK_METADIR);
}
/*
* Fill out the bulkstat info for a single inode and report it somewhere.
*
* bc->breq->lastino is effectively the inode cursor as we walk through the
* filesystem. Therefore, we update it any time we need to move the cursor
* forward, regardless of whether or not we're sending any bstat information
* back to userspace. If the inode is internal metadata or, has been freed
* out from under us, we just simply keep going.
*
* However, if any other type of error happens we want to stop right where we
* are so that userspace will call back with exact number of the bad inode and
* we can send back an error code.
*
* Note that if the formatter tells us there's no space left in the buffer we
* move the cursor forward and abort the walk.
*/
STATIC int
xfs_bulkstat_one_int(
struct xfs_mount *mp,
struct mnt_idmap *idmap,
struct xfs_trans *tp,
xfs_ino_t ino,
struct xfs_bstat_chunk *bc)
{
struct user_namespace *sb_userns = mp->m_super->s_user_ns;
struct xfs_inode *ip; /* incore inode pointer */
struct inode *inode;
struct xfs_bulkstat *buf = bc->buf;
xfs_extnum_t nextents;
int error = -EINVAL;
vfsuid_t vfsuid;
vfsgid_t vfsgid;
error = xfs_iget(mp, tp, ino,
(XFS_IGET_DONTCACHE | XFS_IGET_UNTRUSTED),
XFS_ILOCK_SHARED, &ip);
if (error == -ENOENT || error == -EINVAL)
goto out_advance;
if (error)
goto out;
/* Reload the incore unlinked list to avoid failure in inodegc. */
if (xfs_inode_unlinked_incomplete(ip)) {
error = xfs_inode_reload_unlinked_bucket(tp, ip);
if (error) {
xfs_iunlock(ip, XFS_ILOCK_SHARED);
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
xfs_irele(ip);
return error;
}
}
ASSERT(ip != NULL);
ASSERT(ip->i_imap.im_agbno != 0);
inode = VFS_I(ip);
vfsuid = i_uid_into_vfsuid(idmap, inode);
vfsgid = i_gid_into_vfsgid(idmap, inode);
/*
* If caller wants files from the metadata directories, push out the
* bare minimum information for enabling scrub.
*/
if (want_metadir_file(ip, bc->breq)) {
memset(buf, 0, sizeof(*buf));
buf->bs_ino = ino;
buf->bs_gen = inode->i_generation;
buf->bs_mode = inode->i_mode & S_IFMT;
xfs_bulkstat_health(ip, buf);
buf->bs_version = XFS_BULKSTAT_VERSION_V5;
xfs_iunlock(ip, XFS_ILOCK_SHARED);
xfs_irele(ip);
error = bc->formatter(bc->breq, buf);
if (!error || error == -ECANCELED)
goto out_advance;
goto out;
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_mount.h`, `xfs_inode.h`.
- Detected declarations: `struct xfs_bstat_chunk`, `struct xfs_inumbers_chunk`, `function want_metadir_file`, `function xfs_bulkstat_one_int`, `function xfs_bulkstat_one`, `function xfs_bulkstat_iwalk`, `function xfs_bulkstat_already_done`, `function xfs_bulkstat`, `function xfs_bulkstat_to_bstat`, `function xfs_inumbers_walk`.
- 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.