fs/zonefs/super.c
Source file repositories/reference/linux-study-clean/fs/zonefs/super.c
File Facts
- System
- Linux kernel
- Corpus path
fs/zonefs/super.c- Extension
.c- Size
- 38406 bytes
- Lines
- 1477
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
linux/module.hlinux/pagemap.hlinux/magic.hlinux/iomap.hlinux/init.hlinux/slab.hlinux/blkdev.hlinux/statfs.hlinux/writeback.hlinux/quotaops.hlinux/seq_file.hlinux/uio.hlinux/mman.hlinux/sched/mm.hlinux/crc32.hlinux/task_io_accounting_ops.hlinux/fs_parser.hlinux/fs_context.hzonefs.htrace.h
Detected Declarations
struct zonefs_contextstruct zonefs_zone_datafunction Copyrightfunction zonefs_account_activefunction zonefs_inode_account_activefunction zonefs_zone_mgmtfunction zonefs_inode_zone_mgmtfunction zonefs_i_size_writefunction zonefs_update_statsfunction zonefs_check_zone_conditionfunction zonefs_inode_update_modefunction zonefs_io_error_cbfunction zonefs_handle_io_errorfunction conditionfunction zonefs_handle_io_errorfunction zonefs_free_inodefunction zonefs_statfsfunction zonefs_parse_paramfunction zonefs_show_optionsfunction zonefs_inode_setattrfunction zonefs_fname_to_fnofunction zonefs_readdir_rootfunction zonefs_readdir_zgroupfunction zonefs_readdirfunction zonefs_get_zone_info_cbfunction zonefs_get_zone_infofunction zonefs_free_zone_infofunction zonefs_init_zgroupfunction zonefs_free_zgroupsfunction zonefs_init_zgroupsfunction zonefs_read_superfunction zonefs_get_zgroup_inodesfunction zonefs_release_zgroup_inodesfunction zonefs_fill_superfunction zonefs_kill_superfunction zonefs_free_fcfunction zonefs_get_treefunction zonefs_reconfigurefunction zonefs_init_fs_contextfunction zonefs_init_inodecachefunction zonefs_destroy_inodecachefunction zonefs_initfunction zonefs_exitmodule init zonefs_init
Annotated Snippet
const struct file_operations zonefs_dir_operations = {
.llseek = generic_file_llseek,
.read = generic_read_dir,
.iterate_shared = zonefs_readdir,
};
struct zonefs_zone_data {
struct super_block *sb;
unsigned int nr_zones[ZONEFS_ZTYPE_MAX];
sector_t cnv_zone_start;
struct blk_zone *zones;
};
static int zonefs_get_zone_info_cb(struct blk_zone *zone, unsigned int idx,
void *data)
{
struct zonefs_zone_data *zd = data;
struct super_block *sb = zd->sb;
struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
/*
* We do not care about the first zone: it contains the super block
* and not exposed as a file.
*/
if (!idx)
return 0;
/*
* Count the number of zones that will be exposed as files.
* For sequential zones, we always have as many files as zones.
* FOr conventional zones, the number of files depends on if we have
* conventional zones aggregation enabled.
*/
switch (zone->type) {
case BLK_ZONE_TYPE_CONVENTIONAL:
if (sbi->s_features & ZONEFS_F_AGGRCNV) {
/* One file per set of contiguous conventional zones */
if (!(sbi->s_zgroup[ZONEFS_ZTYPE_CNV].g_nr_zones) ||
zone->start != zd->cnv_zone_start)
sbi->s_zgroup[ZONEFS_ZTYPE_CNV].g_nr_zones++;
zd->cnv_zone_start = zone->start + zone->len;
} else {
/* One file per zone */
sbi->s_zgroup[ZONEFS_ZTYPE_CNV].g_nr_zones++;
}
break;
case BLK_ZONE_TYPE_SEQWRITE_REQ:
case BLK_ZONE_TYPE_SEQWRITE_PREF:
sbi->s_zgroup[ZONEFS_ZTYPE_SEQ].g_nr_zones++;
break;
default:
zonefs_err(zd->sb, "Unsupported zone type 0x%x\n",
zone->type);
return -EIO;
}
memcpy(&zd->zones[idx], zone, sizeof(struct blk_zone));
return 0;
}
static int zonefs_get_zone_info(struct zonefs_zone_data *zd)
{
struct block_device *bdev = zd->sb->s_bdev;
int ret;
zd->zones = kvzalloc_objs(struct blk_zone, bdev_nr_zones(bdev));
if (!zd->zones)
return -ENOMEM;
/* Get zones information from the device */
ret = blkdev_report_zones(bdev, 0, BLK_ALL_ZONES,
zonefs_get_zone_info_cb, zd);
if (ret < 0) {
zonefs_err(zd->sb, "Zone report failed %d\n", ret);
return ret;
}
if (ret != bdev_nr_zones(bdev)) {
zonefs_err(zd->sb, "Invalid zone report (%d/%u zones)\n",
ret, bdev_nr_zones(bdev));
return -EIO;
}
return 0;
}
static inline void zonefs_free_zone_info(struct zonefs_zone_data *zd)
{
kvfree(zd->zones);
Annotation
- Immediate include surface: `linux/module.h`, `linux/pagemap.h`, `linux/magic.h`, `linux/iomap.h`, `linux/init.h`, `linux/slab.h`, `linux/blkdev.h`, `linux/statfs.h`.
- Detected declarations: `struct zonefs_context`, `struct zonefs_zone_data`, `function Copyright`, `function zonefs_account_active`, `function zonefs_inode_account_active`, `function zonefs_zone_mgmt`, `function zonefs_inode_zone_mgmt`, `function zonefs_i_size_write`, `function zonefs_update_stats`, `function zonefs_check_zone_condition`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.