block/blk-ia-ranges.c
Source file repositories/reference/linux-study-clean/block/blk-ia-ranges.c
File Facts
- System
- Linux kernel
- Corpus path
block/blk-ia-ranges.c- Extension
.c- Size
- 8525 bytes
- Lines
- 315
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/kernel.hlinux/blkdev.hlinux/slab.hlinux/init.hblk.h
Detected Declarations
struct blk_ia_range_sysfs_entryfunction Copyrightfunction blk_ia_range_nr_sectors_showfunction blk_ia_range_sysfs_showfunction kobject_addfunction kobject_delfunction disk_register_independent_access_rangesfunction disk_unregister_independent_access_rangesfunction disk_find_ia_rangefunction disk_check_ia_rangesfunction disk_ia_ranges_changedfunction disk_alloc_independent_access_rangesfunction disk_set_independent_access_rangesexport disk_alloc_independent_access_rangesexport disk_set_independent_access_ranges
Annotated Snippet
struct blk_ia_range_sysfs_entry {
struct attribute attr;
ssize_t (*show)(struct blk_independent_access_range *iar, char *buf);
};
static const struct blk_ia_range_sysfs_entry blk_ia_range_sector_entry = {
.attr = { .name = "sector", .mode = 0444 },
.show = blk_ia_range_sector_show,
};
static const struct blk_ia_range_sysfs_entry blk_ia_range_nr_sectors_entry = {
.attr = { .name = "nr_sectors", .mode = 0444 },
.show = blk_ia_range_nr_sectors_show,
};
static const struct attribute *const blk_ia_range_attrs[] = {
&blk_ia_range_sector_entry.attr,
&blk_ia_range_nr_sectors_entry.attr,
NULL,
};
ATTRIBUTE_GROUPS(blk_ia_range);
static ssize_t blk_ia_range_sysfs_show(struct kobject *kobj,
struct attribute *attr, char *buf)
{
struct blk_ia_range_sysfs_entry *entry =
container_of(attr, struct blk_ia_range_sysfs_entry, attr);
struct blk_independent_access_range *iar =
container_of(kobj, struct blk_independent_access_range, kobj);
return entry->show(iar, buf);
}
static const struct sysfs_ops blk_ia_range_sysfs_ops = {
.show = blk_ia_range_sysfs_show,
};
/*
* Independent access range entries are not freed individually, but alltogether
* with struct blk_independent_access_ranges and its array of ranges. Since
* kobject_add() takes a reference on the parent kobject contained in
* struct blk_independent_access_ranges, the array of independent access range
* entries cannot be freed until kobject_del() is called for all entries.
* So we do not need to do anything here, but still need this no-op release
* operation to avoid complaints from the kobject code.
*/
static void blk_ia_range_sysfs_nop_release(struct kobject *kobj)
{
}
static const struct kobj_type blk_ia_range_ktype = {
.sysfs_ops = &blk_ia_range_sysfs_ops,
.default_groups = blk_ia_range_groups,
.release = blk_ia_range_sysfs_nop_release,
};
/*
* This will be executed only after all independent access range entries are
* removed with kobject_del(), at which point, it is safe to free everything,
* including the array of ranges.
*/
static void blk_ia_ranges_sysfs_release(struct kobject *kobj)
{
struct blk_independent_access_ranges *iars =
container_of(kobj, struct blk_independent_access_ranges, kobj);
kfree(iars);
}
static const struct kobj_type blk_ia_ranges_ktype = {
.release = blk_ia_ranges_sysfs_release,
};
/**
* disk_register_independent_access_ranges - register with sysfs a set of
* independent access ranges
* @disk: Target disk
*
* Register with sysfs a set of independent access ranges for @disk.
*/
int disk_register_independent_access_ranges(struct gendisk *disk)
{
struct blk_independent_access_ranges *iars = disk->ia_ranges;
struct request_queue *q = disk->queue;
int i, ret;
lockdep_assert_held(&q->sysfs_lock);
if (!iars)
return 0;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/blkdev.h`, `linux/slab.h`, `linux/init.h`, `blk.h`.
- Detected declarations: `struct blk_ia_range_sysfs_entry`, `function Copyright`, `function blk_ia_range_nr_sectors_show`, `function blk_ia_range_sysfs_show`, `function kobject_add`, `function kobject_del`, `function disk_register_independent_access_ranges`, `function disk_unregister_independent_access_ranges`, `function disk_find_ia_range`, `function disk_check_ia_ranges`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: integration 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.