fs/xfs/libxfs/xfs_zones.c
Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_zones.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/libxfs/xfs_zones.c- Extension
.c- Size
- 2875 bytes
- Lines
- 117
- 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_mount.hxfs_inode.hxfs_rtgroup.hxfs_zones.h
Detected Declarations
function Copyrightfunction xfs_validate_blk_zone_convfunction xfs_validate_blk_zone
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2023-2025 Christoph Hellwig.
* Copyright (c) 2024-2025, Western Digital Corporation or its affiliates.
*/
#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_mount.h"
#include "xfs_inode.h"
#include "xfs_rtgroup.h"
#include "xfs_zones.h"
static bool
xfs_validate_blk_zone_seq(
struct xfs_mount *mp,
struct blk_zone *zone,
unsigned int zone_no,
xfs_rgblock_t *write_pointer)
{
switch (zone->cond) {
case BLK_ZONE_COND_EMPTY:
*write_pointer = 0;
return true;
case BLK_ZONE_COND_IMP_OPEN:
case BLK_ZONE_COND_EXP_OPEN:
case BLK_ZONE_COND_CLOSED:
case BLK_ZONE_COND_ACTIVE:
if (zone->wp < zone->start ||
zone->wp >= zone->start + zone->capacity) {
xfs_warn(mp,
"zone %u write pointer (%llu) outside of zone.",
zone_no, zone->wp);
return false;
}
*write_pointer = XFS_BB_TO_FSB(mp, zone->wp - zone->start);
return true;
case BLK_ZONE_COND_FULL:
*write_pointer = XFS_BB_TO_FSB(mp, zone->capacity);
return true;
case BLK_ZONE_COND_NOT_WP:
case BLK_ZONE_COND_OFFLINE:
case BLK_ZONE_COND_READONLY:
xfs_warn(mp, "zone %u has unsupported zone condition 0x%x.",
zone_no, zone->cond);
return false;
default:
xfs_warn(mp, "zone %u has unknown zone condition 0x%x.",
zone_no, zone->cond);
return false;
}
}
static bool
xfs_validate_blk_zone_conv(
struct xfs_mount *mp,
struct blk_zone *zone,
unsigned int zone_no)
{
switch (zone->cond) {
case BLK_ZONE_COND_NOT_WP:
return true;
default:
xfs_warn(mp,
"conventional zone %u has unsupported zone condition 0x%x.",
zone_no, zone->cond);
return false;
}
}
bool
xfs_validate_blk_zone(
struct xfs_mount *mp,
struct blk_zone *zone,
unsigned int zone_no,
uint32_t expected_size,
uint32_t expected_capacity,
xfs_rgblock_t *write_pointer)
{
/*
* Check that the zone capacity matches the rtgroup size stored in the
* superblock. Note that all zones including the last one must have a
* uniform capacity.
*/
if (XFS_BB_TO_FSB(mp, zone->capacity) != expected_capacity) {
xfs_warn(mp,
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: `function Copyright`, `function xfs_validate_blk_zone_conv`, `function xfs_validate_blk_zone`.
- 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.