Skip to content

Commit

Permalink
Merge pull request iovisor#1615 from palmtenor/lua_biosnoop
Browse files Browse the repository at this point in the history
Port fixes of biosnoop from Python to Lua
  • Loading branch information
yonghong-song committed Mar 1, 2018
2 parents bfec33a + 1469877 commit b700963
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions tools/biosnoop.lua
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,21 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
req->rq_disk->disk_name);
}
if (req->cmd_flags & REQ_WRITE) {
data.rwflag=1;
} else {
data.rwflag=0;
}
/*
* 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
data.rwflag = !!(req->cmd_flags & REQ_WRITE);
#elif defined(REQ_OP_SHIFT)
data.rwflag = !!((req->cmd_flags >> REQ_OP_SHIFT) == REQ_OP_WRITE);
#else
data.rwflag = !!((req->cmd_flags & REQ_OP_MASK) == REQ_OP_WRITE);
#endif
events.perf_submit(ctx,&data,sizeof(data));
start.delete(&req);
infobyreq.delete(&req);
Expand Down

0 comments on commit b700963

Please sign in to comment.