Fixes bio{snoop,top} on 4.10.
authorRyan Leary <rleary@fitbit.com>
Sat, 7 Jan 2017 20:34:31 +0000 (15:34 -0500)
committerRyan Leary <rleary@fitbit.com>
Sun, 8 Jan 2017 20:33:07 +0000 (15:33 -0500)
This commit fixes #888.  The 2 scripts run the same check, and now run
basically the same code to do it.

Tested on 4.10-rc2.

tools/biosnoop.py
tools/biotop.py

index bed6ded..aa8a077 100755 (executable)
@@ -106,14 +106,12 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
  * test, and maintenance burden.
  */
 #ifdef REQ_WRITE
-if (req->cmd_flags & 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
-if ((req->cmd_flags >> REQ_OP_SHIFT) == REQ_OP_WRITE) {
+    data.rwflag = !!((req->cmd_flags & REQ_OP_MASK) == REQ_OP_WRITE);
 #endif
-        data.rwflag = 1;
-    } else {
-        data.rwflag = 0;
-    }
 
     events.perf_submit(ctx, &data, sizeof(data));
     start.delete(&req);
index a97a2d1..f827e62 100755 (executable)
@@ -137,8 +137,10 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
  */
 #ifdef REQ_WRITE
     info.rwflag = !!(req->cmd_flags & REQ_WRITE);
-#else
+#elif defined(REQ_OP_SHIFT)
     info.rwflag = !!((req->cmd_flags >> REQ_OP_SHIFT) == REQ_OP_WRITE);
+#else
+    info.rwflag = !!((req->cmd_flags & REQ_OP_MASK) == REQ_OP_WRITE);
 #endif
 
     whop = whobyreq.lookup(&req);