aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2012-01-09 06:30:39 -0500
committerSteven Rostedt <rostedt@goodmis.org>2012-01-09 16:03:37 -0500
commit699f544895cbd3154e83a48392ce655bb3412b34 (patch)
tree7aea8affd070a921ae1cf47480e0a73f7dd12c7a
parent1f05953c2745ee02878a062b84e606926a779f6a (diff)
blk plugin: replace BLK_TC_BARRIER with BLK_TC_FLUSH/BLK_TC_FUA
The BLK_TC_BARRIER flag was dropped in Linux commit c09c47caedc in August 2011. The blk plugin fails to build against recent kernel headers. Since no flag bits were left, the new BLK_TC_FLUSH flag reused the BLK_TC_BARRIER bit. The new BLK_TC_FUA flag was also added. This patch updates fill_rwbs() to reflect the new BLK_TC_FLUSH/BLK_TC_FUA flags. This allows plugin_blk.c to build successfully on recent kernels. Most of the patch deals with detecting old vs new kernel headers so we can build successfully on both. (Namhyung Kim recommended using the makefile check used by perf and other tools) Link: http://lkml.kernel.org/r/1326108639-13904-1-git-send-email-stefanha@linux.vnet.ibm.com Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Cc: Namhyung Kim <namhyung@gmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--Makefile14
-rw-r--r--plugin_blk.c11
2 files changed, 22 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index c839653..edf3402 100644
--- a/Makefile
+++ b/Makefile
@@ -89,12 +89,20 @@ endif
89 89
90# $(call test-build, snippet, ret) -> ret if snippet compiles 90# $(call test-build, snippet, ret) -> ret if snippet compiles
91# -> empty otherwise 91# -> empty otherwise
92test-build = $(if $(shell $(CC) -o /dev/null -c -x c - > /dev/null 2>&1 \ 92test-build = $(if $(shell sh -c 'echo "$(1)" | \
93 <<<'$1' && echo y), $2) 93 $(CC) -o /dev/null -c -x c - > /dev/null 2>&1 && echo y'), $2)
94 94
95# have udis86 disassembler library? 95# have udis86 disassembler library?
96udis86-flags := $(call test-build,\#include <udis86.h>,-DHAVE_UDIS86 -ludis86) 96udis86-flags := $(call test-build,\#include <udis86.h>,-DHAVE_UDIS86 -ludis86)
97 97
98define BLK_TC_FLUSH_SOURCE
99#include <linux/blktrace_api.h>
100int main(void) { return BLK_TC_FLUSH; }
101endef
102
103# have flush/fua block layer instead of barriers?
104blk-flags := $(call test-build,$(BLK_TC_FLUSH_SOURCE),-DHAVE_BLK_TC_FLUSH)
105
98ifeq ("$(origin O)", "command line") 106ifeq ("$(origin O)", "command line")
99 BUILD_OUTPUT := $(O) 107 BUILD_OUTPUT := $(O)
100endif 108endif
@@ -223,7 +231,7 @@ endif
223 231
224# Append required CFLAGS 232# Append required CFLAGS
225override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ) 233override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ)
226override CFLAGS += $(udis86-flags) 234override CFLAGS += $(udis86-flags) $(blk-flags)
227 235
228ifeq ($(VERBOSE),1) 236ifeq ($(VERBOSE),1)
229 Q = 237 Q =
diff --git a/plugin_blk.c b/plugin_blk.c
index 9327b17..c0ecef9 100644
--- a/plugin_blk.c
+++ b/plugin_blk.c
@@ -54,6 +54,11 @@ static void fill_rwbs(char *rwbs, int action, unsigned int bytes)
54 goto out; 54 goto out;
55 } 55 }
56 56
57#if defined(HAVE_BLK_TC_FLUSH)
58 if (tc & BLK_TC_FLUSH)
59 rwbs[i++] = 'F';
60#endif
61
57 if (tc & BLK_TC_DISCARD) 62 if (tc & BLK_TC_DISCARD)
58 rwbs[i++] = 'D'; 63 rwbs[i++] = 'D';
59 else if (tc & BLK_TC_WRITE) 64 else if (tc & BLK_TC_WRITE)
@@ -63,10 +68,16 @@ static void fill_rwbs(char *rwbs, int action, unsigned int bytes)
63 else 68 else
64 rwbs[i++] = 'N'; 69 rwbs[i++] = 'N';
65 70
71#if defined(HAVE_BLK_TC_FLUSH)
72 if (tc & BLK_TC_FUA)
73 rwbs[i++] = 'F';
74#endif
66 if (tc & BLK_TC_AHEAD) 75 if (tc & BLK_TC_AHEAD)
67 rwbs[i++] = 'A'; 76 rwbs[i++] = 'A';
77#if !defined(HAVE_BLK_TC_FLUSH)
68 if (tc & BLK_TC_BARRIER) 78 if (tc & BLK_TC_BARRIER)
69 rwbs[i++] = 'B'; 79 rwbs[i++] = 'B';
80#endif
70 if (tc & BLK_TC_SYNC) 81 if (tc & BLK_TC_SYNC)
71 rwbs[i++] = 'S'; 82 rwbs[i++] = 'S';
72 if (tc & BLK_TC_META) 83 if (tc & BLK_TC_META)