include/linux/blktrace_api.h
Source file repositories/reference/linux-study-clean/include/linux/blktrace_api.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/blktrace_api.h- Extension
.h- Size
- 3650 bytes
- Lines
- 133
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: implementation source
- Status
- source 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.
- 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/blk-mq.hlinux/relay.hlinux/compat.huapi/linux/blktrace_api.hlinux/list.hlinux/blk_types.hlinux/sysfs.h
Detected Declarations
struct blk_tracestruct compat_blk_user_trace_setupfunction blk_trace_note_message_enabledfunction blk_trace_removefunction blk_rq_trace_sectorfunction blk_rq_trace_nr_sectors
Annotated Snippet
struct blk_trace {
int version;
int trace_state;
struct rchan *rchan;
unsigned long __percpu *sequence;
unsigned char __percpu *msg_data;
u64 act_mask;
u64 start_lba;
u64 end_lba;
u32 pid;
u32 dev;
struct dentry *dir;
struct list_head running_list;
atomic_t dropped;
};
extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
extern void blk_trace_shutdown(struct request_queue *);
__printf(3, 4) void __blk_trace_note_message(struct blk_trace *bt,
struct cgroup_subsys_state *css, const char *fmt, ...);
/**
* blk_add_trace_msg - Add a (simple) message to the blktrace stream
* @q: queue the io is for
* @fmt: format to print message in
* args... Variable argument list for format
*
* Description:
* Records a (simple) message onto the blktrace stream.
*
* NOTE: BLK_TN_MAX_MSG characters are output at most.
* NOTE: Can not use 'static inline' due to presence of var args...
*
**/
#define blk_add_cgroup_trace_msg(q, css, fmt, ...) \
do { \
struct blk_trace *bt; \
\
rcu_read_lock(); \
bt = rcu_dereference((q)->blk_trace); \
if (unlikely(bt)) \
__blk_trace_note_message(bt, css, fmt, ##__VA_ARGS__);\
rcu_read_unlock(); \
} while (0)
#define blk_add_trace_msg(q, fmt, ...) \
blk_add_cgroup_trace_msg(q, NULL, fmt, ##__VA_ARGS__)
#define BLK_TN_MAX_MSG 128
static inline bool blk_trace_note_message_enabled(struct request_queue *q)
{
struct blk_trace *bt;
bool ret;
rcu_read_lock();
bt = rcu_dereference(q->blk_trace);
ret = bt && (bt->act_mask & BLK_TC_NOTIFY);
rcu_read_unlock();
return ret;
}
extern void blk_add_driver_data(struct request *rq, void *data, size_t len);
extern int blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
struct block_device *bdev,
char __user *arg);
extern int blk_trace_startstop(struct request_queue *q, int start);
extern int blk_trace_remove(struct request_queue *q);
#else /* !CONFIG_BLK_DEV_IO_TRACE */
# define blk_trace_ioctl(bdev, cmd, arg) (-ENOTTY)
# define blk_trace_shutdown(q) do { } while (0)
# define blk_add_driver_data(rq, data, len) do {} while (0)
# define blk_trace_setup(q, name, dev, bdev, arg) (-ENOTTY)
# define blk_trace_startstop(q, start) (-ENOTTY)
# define blk_add_trace_msg(q, fmt, ...) do { } while (0)
# define blk_add_cgroup_trace_msg(q, cg, fmt, ...) do { } while (0)
# define blk_trace_note_message_enabled(q) (false)
static inline int blk_trace_remove(struct request_queue *q)
{
return -ENOTTY;
}
#endif /* CONFIG_BLK_DEV_IO_TRACE */
#ifdef CONFIG_COMPAT
struct compat_blk_user_trace_setup {
char name[BLKTRACE_BDEV_SIZE];
u16 act_mask;
u32 buf_size;
u32 buf_nr;
Annotation
- Immediate include surface: `linux/blk-mq.h`, `linux/relay.h`, `linux/compat.h`, `uapi/linux/blktrace_api.h`, `linux/list.h`, `linux/blk_types.h`, `linux/sysfs.h`.
- Detected declarations: `struct blk_trace`, `struct compat_blk_user_trace_setup`, `function blk_trace_note_message_enabled`, `function blk_trace_remove`, `function blk_rq_trace_sector`, `function blk_rq_trace_nr_sectors`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- 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.