fs/xfs/xfs_error.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_error.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_error.c- Extension
.c- Size
- 8546 bytes
- Lines
- 386
- 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_shared.hxfs_format.hxfs_fs.hxfs_log_format.hxfs_trans_resv.hxfs_mount.hxfs_error.hxfs_sysfs.hxfs_inode.hxfs_errortag.h
Detected Declarations
struct xfs_errortag_attrfunction to_attrfunction to_mpfunction xfs_errortag_attr_storefunction xfs_errortag_attr_showfunction xfs_errortag_initfunction xfs_errortag_delfunction xfs_errortag_testfunction xfs_errortag_delayfunction xfs_errortag_addfunction xfs_errortag_add_namefunction xfs_errortag_copyfunction xfs_errortag_clearallfunction xfs_error_reportfunction xfs_corruption_errorfunction xfs_buf_corruption_errorfunction xfs_buf_verifier_errorfunction xfs_verifier_errorfunction xfs_inode_verifier_error
Annotated Snippet
struct xfs_errortag_attr {
struct attribute attr;
unsigned int tag;
};
static inline struct xfs_errortag_attr *
to_attr(struct attribute *attr)
{
return container_of(attr, struct xfs_errortag_attr, attr);
}
static inline struct xfs_mount *
to_mp(struct kobject *kobject)
{
struct xfs_kobj *kobj = to_kobj(kobject);
return container_of(kobj, struct xfs_mount, m_errortag_kobj);
}
STATIC ssize_t
xfs_errortag_attr_store(
struct kobject *kobject,
struct attribute *attr,
const char *buf,
size_t count)
{
struct xfs_mount *mp = to_mp(kobject);
unsigned int error_tag = to_attr(attr)->tag;
unsigned int val;
int ret;
if (strcmp(buf, "default") == 0) {
val = xfs_errortag_random_default[error_tag];
} else {
ret = kstrtouint(buf, 0, &val);
if (ret)
return ret;
}
WRITE_ONCE(mp->m_errortag[error_tag], val);
return count;
}
STATIC ssize_t
xfs_errortag_attr_show(
struct kobject *kobject,
struct attribute *attr,
char *buf)
{
struct xfs_mount *mp = to_mp(kobject);
return snprintf(buf, PAGE_SIZE, "%u\n",
READ_ONCE(mp->m_errortag[to_attr(attr)->tag]));
}
static const struct sysfs_ops xfs_errortag_sysfs_ops = {
.show = xfs_errortag_attr_show,
.store = xfs_errortag_attr_store,
};
#define XFS_ERRTAG(_tag, _name, _default) \
static struct xfs_errortag_attr xfs_errortag_attr_##_name = { \
.attr = {.name = __stringify(_name), \
.mode = VERIFY_OCTAL_PERMISSIONS(S_IWUSR | S_IRUGO) }, \
.tag = XFS_ERRTAG_##_tag, \
};
#include "xfs_errortag.h"
XFS_ERRTAGS
#undef XFS_ERRTAG
#define XFS_ERRTAG(_tag, _name, _default) \
&xfs_errortag_attr_##_name.attr,
#include "xfs_errortag.h"
static struct attribute *xfs_errortag_attrs[] = {
XFS_ERRTAGS
NULL
};
ATTRIBUTE_GROUPS(xfs_errortag);
#undef XFS_ERRTAG
/* -1 because XFS_ERRTAG_DROP_WRITES got removed, + 1 for NULL termination */
static_assert(ARRAY_SIZE(xfs_errortag_attrs) == XFS_ERRTAG_MAX);
static const struct kobj_type xfs_errortag_ktype = {
.release = xfs_sysfs_release,
.sysfs_ops = &xfs_errortag_sysfs_ops,
.default_groups = xfs_errortag_groups,
};
int
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_fs.h`, `xfs_log_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_error.h`.
- Detected declarations: `struct xfs_errortag_attr`, `function to_attr`, `function to_mp`, `function xfs_errortag_attr_store`, `function xfs_errortag_attr_show`, `function xfs_errortag_init`, `function xfs_errortag_del`, `function xfs_errortag_test`, `function xfs_errortag_delay`, `function xfs_errortag_add`.
- 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.