fs/btrfs/messages.c
Source file repositories/reference/linux-study-clean/fs/btrfs/messages.c
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/messages.c- Extension
.c- Size
- 8610 bytes
- Lines
- 302
- 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
fs.hmessages.hdiscard.hsuper.h
Detected Declarations
function btrfs_state_to_stringfunction for_each_set_bitfunction btrfs_decode_errorfunction __btrfs_handle_fs_errorfunction _btrfs_printkfunction btrfs_warn_32bit_limitfunction btrfs_err_32bit_limitfunction __btrfs_panic
Annotated Snippet
if ((bit < BTRFS_FS_STATE_COUNT) && fs_state_chars[bit]) {
*curr++ = fs_state_chars[bit];
states_printed = true;
}
}
/* If no states were printed, reset the buffer */
if (!states_printed)
curr = buf;
*curr++ = 0;
}
#endif
/*
* Generally the error codes correspond to their respective errors, but there
* are a few special cases.
*
* EUCLEAN: Any sort of corruption that we encounter. The tree-checker for
* instance will return EUCLEAN if any of the blocks are corrupted in
* a way that is problematic. We want to reserve EUCLEAN for these
* sort of corruptions.
*
* EROFS: If we check BTRFS_FS_STATE_ERROR and fail out with a return error, we
* need to use EROFS for this case. We will have no idea of the
* original failure, that will have been reported at the time we tripped
* over the error. Each subsequent error that doesn't have any context
* of the original error should use EROFS when handling BTRFS_FS_STATE_ERROR.
*/
const char * __attribute_const__ btrfs_decode_error(int error)
{
char *errstr = "unknown";
switch (error) {
case -ENOENT: /* -2 */
errstr = "No such entry";
break;
case -EIO: /* -5 */
errstr = "IO failure";
break;
case -ENOMEM: /* -12*/
errstr = "Out of memory";
break;
case -EEXIST: /* -17 */
errstr = "Object already exists";
break;
case -ENOSPC: /* -28 */
errstr = "No space left";
break;
case -EROFS: /* -30 */
errstr = "Readonly filesystem";
break;
case -EOPNOTSUPP: /* -95 */
errstr = "Operation not supported";
break;
case -EUCLEAN: /* -117 */
errstr = "Filesystem corrupted";
break;
case -EDQUOT: /* -122 */
errstr = "Quota exceeded";
break;
}
return errstr;
}
/*
* Decodes expected errors from the caller and invokes the appropriate error
* response.
*/
__cold
void __btrfs_handle_fs_error(struct btrfs_fs_info *fs_info, const char *function,
unsigned int line, int error, const char *fmt, ...)
{
struct super_block *sb = fs_info->sb;
#ifdef CONFIG_PRINTK
char statestr[STATE_STRING_BUF_LEN];
const char *errstr;
#endif
#ifdef CONFIG_PRINTK_INDEX
printk_index_subsys_emit(
"BTRFS: error (device %s%s) in %s:%d: errno=%d %s", KERN_CRIT, fmt);
#endif
/*
* Special case: if the error is EROFS, and we're already under
* SB_RDONLY, then it is safe here.
*/
if (error == -EROFS && sb_rdonly(sb))
Annotation
- Immediate include surface: `fs.h`, `messages.h`, `discard.h`, `super.h`.
- Detected declarations: `function btrfs_state_to_string`, `function for_each_set_bit`, `function btrfs_decode_error`, `function __btrfs_handle_fs_error`, `function _btrfs_printk`, `function btrfs_warn_32bit_limit`, `function btrfs_err_32bit_limit`, `function __btrfs_panic`.
- 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.