Commit 8ff670d9 authored by 4ast's avatar 4ast Committed by GitHub

Merge pull request #825 from brendangregg/master

biotop.py: fix compiler error on newer kernels
parents ae6d979b 51add789
......@@ -65,7 +65,7 @@ Cached process name, if present. This usually (but isn't guaranteed) to identify
the responsible process for the I/O.
.TP
D
Direction: R == read, W == write.
Direction: R == read, W == write. This is a simplification.
.TP
MAJ
Major device number.
......
......@@ -68,7 +68,7 @@ struct who_t {
// the key for the output summary
struct info_t {
u32 pid;
int type;
int rwflag;
int major;
int minor;
char name[TASK_COMM_LEN];
......@@ -128,7 +128,19 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
struct info_t info = {};
info.major = req->rq_disk->major;
info.minor = req->rq_disk->first_minor;
info.type = req->cmd_flags & REQ_WRITE;
/*
* The following deals with a kernel version change (in mainline 4.7, although
* it may be backported to earlier kernels) with how block request write flags
* are tested. We handle both pre- and post-change versions here. Please avoid
* kernel version tests like this as much as possible: they inflate the code,
* test, and maintenance burden.
*/
#ifdef REQ_WRITE
info.rwflag = !!(req->cmd_flags & REQ_WRITE);
#else
info.rwflag = !!((req->cmd_flags >> REQ_OP_SHIFT) == REQ_OP_WRITE);
#endif
whop = whobyreq.lookup(&req);
if (whop == 0) {
// missed pid who, save stats as pid 0
......@@ -199,7 +211,7 @@ while 1:
# print line
avg_ms = (float(v.us) / 1000) / v.io
print("%-6d %-16s %1s %-3d %-3d %-8s %5s %7s %6.2f" % (k.pid, k.name,
"W" if k.type else "R", k.major, k.minor, diskname, v.io,
"W" if k.rwflag else "R", k.major, k.minor, diskname, v.io,
v.bytes / 1024, avg_ms))
line += 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment