drivers/md/dm-zoned-reclaim.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-zoned-reclaim.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-zoned-reclaim.c- Extension
.c- Size
- 15145 bytes
- Lines
- 641
- Domain
- Driver Families
- Bucket
- drivers/md
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- 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
dm-zoned.hlinux/module.h
Detected Declarations
struct dmz_reclaimfunction unmappedfunction dmz_reclaim_kcopy_endfunction dmz_reclaim_copyfunction dzonefunction dmz_reclaim_seq_datafunction dmz_reclaim_rnd_datafunction dmz_reclaim_emptyfunction dmz_target_idlefunction dmz_do_reclaimfunction dmz_reclaim_percentagefunction dmz_should_reclaimfunction dmz_reclaim_workfunction dmz_ctr_reclaimfunction dmz_dtr_reclaimfunction dmz_suspend_reclaimfunction dmz_resume_reclaimfunction dmz_reclaim_bio_accfunction dmz_schedule_reclaim
Annotated Snippet
struct dmz_reclaim {
struct dmz_metadata *metadata;
struct delayed_work work;
struct workqueue_struct *wq;
struct dm_kcopyd_client *kc;
struct dm_kcopyd_throttle kc_throttle;
int kc_err;
int dev_idx;
unsigned long flags;
/* Last target access time */
unsigned long atime;
};
/*
* Reclaim state flags.
*/
enum {
DMZ_RECLAIM_KCOPY,
};
/*
* Number of seconds of target BIO inactivity to consider the target idle.
*/
#define DMZ_IDLE_PERIOD (10UL * HZ)
/*
* Percentage of unmapped (free) random zones below which reclaim starts
* even if the target is busy.
*/
#define DMZ_RECLAIM_LOW_UNMAP_ZONES 30
/*
* Percentage of unmapped (free) random zones above which reclaim will
* stop if the target is busy.
*/
#define DMZ_RECLAIM_HIGH_UNMAP_ZONES 50
/*
* Align a sequential zone write pointer to chunk_block.
*/
static int dmz_reclaim_align_wp(struct dmz_reclaim *zrc, struct dm_zone *zone,
sector_t block)
{
struct dmz_metadata *zmd = zrc->metadata;
struct dmz_dev *dev = zone->dev;
sector_t wp_block = zone->wp_block;
unsigned int nr_blocks;
int ret;
if (wp_block == block)
return 0;
if (wp_block > block)
return -EIO;
/*
* Zeroout the space between the write
* pointer and the requested position.
*/
nr_blocks = block - wp_block;
ret = blk_zone_issue_zeroout(dev->bdev,
dmz_start_sect(zmd, zone) + dmz_blk2sect(wp_block),
dmz_blk2sect(nr_blocks), GFP_NOIO);
if (ret) {
dmz_dev_err(dev,
"Align zone %u wp %llu to %llu (wp+%u) blocks failed %d",
zone->id, (unsigned long long)wp_block,
(unsigned long long)block, nr_blocks, ret);
dmz_check_bdev(dev);
return ret;
}
zone->wp_block = block;
return 0;
}
/*
* dm_kcopyd_copy end notification.
*/
static void dmz_reclaim_kcopy_end(int read_err, unsigned long write_err,
void *context)
{
struct dmz_reclaim *zrc = context;
Annotation
- Immediate include surface: `dm-zoned.h`, `linux/module.h`.
- Detected declarations: `struct dmz_reclaim`, `function unmapped`, `function dmz_reclaim_kcopy_end`, `function dmz_reclaim_copy`, `function dzone`, `function dmz_reclaim_seq_data`, `function dmz_reclaim_rnd_data`, `function dmz_reclaim_empty`, `function dmz_target_idle`, `function dmz_do_reclaim`.
- Atlas domain: Driver Families / drivers/md.
- 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.