Add block device tracing facility
The implementation is in libblockdriver, and works transparently for all block drivers. The new btrace(8) tool can be used to control block tracing; see ``man btrace'' for details.
This commit is contained in:
@@ -6,6 +6,7 @@ INCS+= env.h fetch.h hgfs.h lib.h libutil.h timers.h
|
||||
|
||||
INCS+= minix/acpi.h minix/ansi.h minix/audio_fw.h minix/bitmap.h \
|
||||
minix/bdev.h minix/blockdriver.h minix/blockdriver_mt.h \
|
||||
minix/btrace.h \
|
||||
minix/callnr.h minix/chardriver.h minix/com.h minix/compiler.h \
|
||||
minix/config.h minix/const.h minix/cpufeature.h minix/crtso.h \
|
||||
minix/debug.h minix/devio.h minix/devman.h minix/dmap.h \
|
||||
|
||||
@@ -27,7 +27,7 @@ struct blockdriver {
|
||||
*/
|
||||
_PROTOTYPE( void blockdriver_announce, (void) );
|
||||
|
||||
#ifndef _DRIVER_MT_API
|
||||
#ifndef _BLOCKDRIVER_MT_API
|
||||
/* Additional functions for the singlethreaded version. These allow the driver
|
||||
* to either use the stock driver_task(), or implement its own message loop.
|
||||
* To avoid accidents, these functions are not exposed when minix/driver_mt.h
|
||||
@@ -39,7 +39,7 @@ _PROTOTYPE( void blockdriver_process, (struct blockdriver *dp, message *m_ptr,
|
||||
_PROTOTYPE( void blockdriver_terminate, (void) );
|
||||
_PROTOTYPE( void blockdriver_task, (struct blockdriver *bdp) );
|
||||
_PROTOTYPE( int blockdriver_mq_queue, (message *m_ptr, int status) );
|
||||
#endif /* !_DRIVER_MT_API */
|
||||
#endif /* !_BLOCKDRIVER_MT_API */
|
||||
|
||||
/* Parameters for the disk drive. */
|
||||
#define SECTOR_SIZE 512 /* physical sector size in bytes */
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef _MINIX_BLOCKDRIVER_MT_H
|
||||
#define _MINIX_BLOCKDRIVER_MT_H
|
||||
|
||||
#define DRIVER_MT_API 1 /* do not expose the singlethreaded API */
|
||||
#define BLOCKDRIVER_MT_API 1 /* do not expose the singlethreaded API */
|
||||
#include <minix/blockdriver.h>
|
||||
|
||||
/* The maximum number of worker threads. */
|
||||
#define DRIVER_MT_MAX_WORKERS 32
|
||||
#define BLOCKDRIVER_MT_MAX_WORKERS 32
|
||||
|
||||
_PROTOTYPE( void blockdriver_mt_task, (struct blockdriver *driver_tab) );
|
||||
_PROTOTYPE( void blockdriver_mt_sleep, (void) );
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef _MINIX_BTRACE_H
|
||||
#define _MINIX_BTRACE_H
|
||||
|
||||
/* Control directives. */
|
||||
enum {
|
||||
BTCTL_START,
|
||||
BTCTL_STOP
|
||||
};
|
||||
|
||||
/* Request codes. */
|
||||
enum {
|
||||
BTREQ_OPEN,
|
||||
BTREQ_CLOSE,
|
||||
BTREQ_READ,
|
||||
BTREQ_WRITE,
|
||||
BTREQ_GATHER,
|
||||
BTREQ_SCATTER,
|
||||
BTREQ_IOCTL
|
||||
};
|
||||
|
||||
/* Special result codes. */
|
||||
#define BTRES_INPROGRESS (-997)
|
||||
|
||||
/* Block trace entry. */
|
||||
typedef struct {
|
||||
u32_t request; /* request code; one of BTR_xxx */
|
||||
u32_t size; /* request size, ioctl request, or access */
|
||||
u64_t position; /* starting disk position */
|
||||
u32_t flags; /* transfer flags */
|
||||
i32_t result; /* request result; OK, bytes, or error */
|
||||
u32_t start_time; /* request service start time (us) */
|
||||
u32_t finish_time; /* request service completion time (us) */
|
||||
} btrace_entry; /* (32 bytes) */
|
||||
|
||||
/* This is the number of btrace_entry structures copied out at once using the
|
||||
* BIOCTRACEGET ioctl call.
|
||||
*/
|
||||
#define BTBUF_SIZE 1024
|
||||
|
||||
#endif /* _MINIX_BTRACE_H */
|
||||
@@ -3,7 +3,7 @@
|
||||
.PATH: ${MINIXSRCDIR}/common/include/sys
|
||||
|
||||
INCS+= elf32.h elf64.h elf_common.h elf_generic.h \
|
||||
ioc_file.h ioc_tape.h ioc_disk.h \
|
||||
ioc_block.h ioc_file.h ioc_tape.h ioc_disk.h \
|
||||
ioc_memory.h ioc_sound.h ioc_tty.h \
|
||||
kbdio.h mtio.h svrctl.h video.h vm.h procfs.h elf_core.h exec_elf.h
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/* sys/ioc_block.h - Block ioctl() command codes.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _S_I_BLOCK_H
|
||||
#define _S_I_BLOCK_H
|
||||
|
||||
#include <minix/ioctl.h>
|
||||
#include <minix/btrace.h>
|
||||
|
||||
#define BIOCTRACEBUF _IOW('b', 1, size_t)
|
||||
#define BIOCTRACECTL _IOW('b', 2, int)
|
||||
#define BIOCTRACEGET _IOR_BIG(3, btrace_entry[BTBUF_SIZE])
|
||||
|
||||
#endif /* _S_I_BLOCK_H */
|
||||
Reference in New Issue
Block a user