tools/testing/selftests/ublk/kublk.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/ublk/kublk.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/ublk/kublk.h- Extension
.h- Size
- 15873 bytes
- Lines
- 629
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
unistd.hstdlib.hassert.hstdio.hstdarg.hstring.hpthread.hgetopt.hlimits.hpoll.hfcntl.hsys/syscall.hsys/mman.hsys/ioctl.hsys/inotify.hsys/wait.hsys/eventfd.hsys/ipc.hsys/shm.hlinux/io_uring.hliburing.hsemaphore.hublk_dep.hlinux/ublk_cmd.hutils.h
Detected Declarations
struct ublk_devstruct ublk_queuestruct ublk_threadstruct stripe_ctxstruct fault_inject_ctxstruct dev_ctxstruct ublk_ctrl_cmd_datastruct ublk_iostruct ublk_tgt_opsstruct ublk_tgtstruct ublk_queuestruct ublk_batch_elemstruct batch_commit_bufstruct batch_fetch_bufstruct ublk_threadstruct ublk_devstruct ublk_shmem_entryfunction __ublk_use_batch_iofunction ublk_queue_batch_iofunction ublk_dev_batch_iofunction ublk_thread_batch_iofunction ublk_set_integrity_paramsfunction ublk_integrity_lenfunction ublk_integrity_data_lenfunction ublk_io_auto_zc_fallbackfunction ublk_user_copy_offsetfunction is_target_iofunction build_user_datafunction user_data_to_tagfunction user_data_to_opfunction user_data_to_tgt_datafunction user_data_to_q_idfunction ublk_cmd_op_nrfunction ublk_io_alloc_sqesfunction ublk_get_registered_fdfunction __io_uring_prep_buf_reg_unregfunction io_uring_prep_buf_registerfunction io_uring_prep_buf_unregisterfunction ublk_set_io_resfunction ublk_get_io_resfunction ublk_mark_io_donefunction ublk_set_sqe_cmd_opfunction ublk_io_buf_idxfunction ublk_completed_tgt_iofunction ublk_queue_use_zcfunction ublk_queue_use_auto_zcfunction ublk_queue_auto_zc_fallbackfunction ublk_queue_use_user_copy
Annotated Snippet
struct stripe_ctx {
/* stripe */
unsigned int chunk_size;
};
struct fault_inject_ctx {
/* fault_inject */
unsigned long delay_us;
bool die_during_fetch;
};
struct dev_ctx {
char tgt_type[16];
unsigned long flags;
unsigned nr_hw_queues;
unsigned short nthreads;
unsigned queue_depth;
int dev_id;
int nr_files;
char *files[MAX_BACK_FILES];
unsigned int logging:1;
unsigned int all:1;
unsigned int fg:1;
unsigned int recovery:1;
unsigned int auto_zc_fallback:1;
unsigned int per_io_tasks:1;
unsigned int no_ublk_fixed_fd:1;
unsigned int safe_stop:1;
unsigned int no_auto_part_scan:1;
unsigned int rdonly_shmem_buf:1;
__u32 integrity_flags;
__u8 metadata_size;
__u8 pi_offset;
__u8 csum_type;
__u8 tag_size;
int _evtfd;
int _shmid;
/* built from shmem, only for ublk_dump_dev() */
struct ublk_dev *shadow_dev;
/* for 'update_size' command */
unsigned long long size;
char *htlb_path;
union {
struct stripe_ctx stripe;
struct fault_inject_ctx fault_inject;
};
};
struct ublk_ctrl_cmd_data {
__u32 cmd_op;
#define CTRL_CMD_HAS_DATA 1
#define CTRL_CMD_HAS_BUF 2
__u32 flags;
__u64 data[2];
__u64 addr;
__u32 len;
};
struct ublk_io {
char *buf_addr;
void *integrity_buf;
#define UBLKS_IO_NEED_FETCH_RQ (1UL << 0)
#define UBLKS_IO_NEED_COMMIT_RQ_COMP (1UL << 1)
#define UBLKS_IO_FREE (1UL << 2)
#define UBLKS_IO_NEED_GET_DATA (1UL << 3)
#define UBLKS_IO_NEED_REG_BUF (1UL << 4)
unsigned short flags;
unsigned short refs; /* used by target code only */
int tag;
int result;
unsigned short buf_index;
unsigned short tgt_ios;
void *private_data;
};
struct ublk_tgt_ops {
const char *name;
int (*init_tgt)(const struct dev_ctx *ctx, struct ublk_dev *);
void (*deinit_tgt)(struct ublk_dev *);
Annotation
- Immediate include surface: `unistd.h`, `stdlib.h`, `assert.h`, `stdio.h`, `stdarg.h`, `string.h`, `pthread.h`, `getopt.h`.
- Detected declarations: `struct ublk_dev`, `struct ublk_queue`, `struct ublk_thread`, `struct stripe_ctx`, `struct fault_inject_ctx`, `struct dev_ctx`, `struct ublk_ctrl_cmd_data`, `struct ublk_io`, `struct ublk_tgt_ops`, `struct ublk_tgt`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.