drivers/md/bcache/bcache.h
Source file repositories/reference/linux-study-clean/drivers/md/bcache/bcache.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/bcache/bcache.h- Extension
.h- Size
- 33258 bytes
- Lines
- 1060
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bio.hlinux/closure.hlinux/kobject.hlinux/list.hlinux/mutex.hlinux/rbtree.hlinux/rwsem.hlinux/refcount.hlinux/types.hlinux/workqueue.hlinux/kthread.hbcache_ondisk.hbset.hutil.hjournal.hstats.h
Detected Declarations
struct bucketstruct searchstruct btreestruct keybufstruct keybuf_keystruct keybufstruct bcache_devicestruct iostruct cached_devstruct cachestruct gc_statstruct cache_setstruct bbiostruct detached_dev_io_privateenum stop_on_failureenum alloc_reservefunction meta_bucket_pagesfunction meta_bucket_bytesfunction bucket_to_sectorfunction bucket_remainderfunction PTR_BUCKET_NRfunction gen_afterfunction ptr_stalefunction ptr_availablefunction cached_dev_putfunction cached_dev_getfunction bucket_gc_genfunction __ATTRfunction closure_bio_submitfunction wait_for_kthread_stop
Annotated Snippet
struct bucket {
atomic_t pin;
uint16_t prio;
uint8_t gen;
uint8_t last_gc; /* Most out of date gen in the btree */
uint16_t gc_mark; /* Bitfield used by GC. See below for field */
uint16_t reclaimable_in_gc:1;
};
/*
* I'd use bitfields for these, but I don't trust the compiler not to screw me
* as multiple threads touch struct bucket without locking
*/
BITMASK(GC_MARK, struct bucket, gc_mark, 0, 2);
#define GC_MARK_RECLAIMABLE 1
#define GC_MARK_DIRTY 2
#define GC_MARK_METADATA 3
#define GC_SECTORS_USED_SIZE 13
#define MAX_GC_SECTORS_USED (~(~0ULL << GC_SECTORS_USED_SIZE))
BITMASK(GC_SECTORS_USED, struct bucket, gc_mark, 2, GC_SECTORS_USED_SIZE);
BITMASK(GC_MOVE, struct bucket, gc_mark, 15, 1);
#include "journal.h"
#include "stats.h"
struct search;
struct btree;
struct keybuf;
struct keybuf_key {
struct rb_node node;
BKEY_PADDED(key);
void *private;
};
struct keybuf {
struct bkey last_scanned;
spinlock_t lock;
/*
* Beginning and end of range in rb tree - so that we can skip taking
* lock and checking the rb tree when we need to check for overlapping
* keys.
*/
struct bkey start;
struct bkey end;
struct rb_root keys;
#define KEYBUF_NR 500
DECLARE_ARRAY_ALLOCATOR(struct keybuf_key, freelist, KEYBUF_NR);
};
struct bcache_device {
struct closure cl;
struct kobject kobj;
struct cache_set *c;
unsigned int id;
#define BCACHEDEVNAME_SIZE 12
char name[BCACHEDEVNAME_SIZE];
struct gendisk *disk;
unsigned long flags;
#define BCACHE_DEV_CLOSING 0
#define BCACHE_DEV_DETACHING 1
#define BCACHE_DEV_UNLINK_DONE 2
#define BCACHE_DEV_WB_RUNNING 3
#define BCACHE_DEV_RATE_DW_RUNNING 4
int nr_stripes;
#define BCH_MIN_STRIPE_SZ ((4 << 20) >> SECTOR_SHIFT)
unsigned int stripe_size;
atomic_t *stripe_sectors_dirty;
unsigned long *full_dirty_stripes;
struct bio_set bio_split;
struct bio_set bio_detached;
unsigned int data_csum:1;
int (*cache_miss)(struct btree *b, struct search *s,
struct bio *bio, unsigned int sectors);
int (*ioctl)(struct bcache_device *d, blk_mode_t mode,
unsigned int cmd, unsigned long arg);
};
struct io {
Annotation
- Immediate include surface: `linux/bio.h`, `linux/closure.h`, `linux/kobject.h`, `linux/list.h`, `linux/mutex.h`, `linux/rbtree.h`, `linux/rwsem.h`, `linux/refcount.h`.
- Detected declarations: `struct bucket`, `struct search`, `struct btree`, `struct keybuf`, `struct keybuf_key`, `struct keybuf`, `struct bcache_device`, `struct io`, `struct cached_dev`, `struct cache`.
- Atlas domain: Driver Families / drivers/md.
- Implementation status: source 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.