File tree 1 file changed +15
-5
lines changed
1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -94,11 +94,21 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
94
94
req->rq_disk->disk_name);
95
95
}
96
96
97
- if (req->cmd_flags & REQ_WRITE) {
98
- data.rwflag=1;
99
- } else {
100
- data.rwflag=0;
101
- }
97
+ /*
98
+ * The following deals with a kernel version change (in mainline 4.7, although
99
+ * it may be backported to earlier kernels) with how block request write flags
100
+ * are tested. We handle both pre- and post-change versions here. Please avoid
101
+ * kernel version tests like this as much as possible: they inflate the code,
102
+ * test, and maintenance burden.
103
+ */
104
+ #ifdef REQ_WRITE
105
+ data.rwflag = !!(req->cmd_flags & REQ_WRITE);
106
+ #elif defined(REQ_OP_SHIFT)
107
+ data.rwflag = !!((req->cmd_flags >> REQ_OP_SHIFT) == REQ_OP_WRITE);
108
+ #else
109
+ data.rwflag = !!((req->cmd_flags & REQ_OP_MASK) == REQ_OP_WRITE);
110
+ #endif
111
+
102
112
events.perf_submit(ctx,&data,sizeof(data));
103
113
start.delete(&req);
104
114
infobyreq.delete(&req);
You can’t perform that action at this time.
0 commit comments