mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2][trace-cmd] blk plugin: replace BLK_TC_BARRIER with BLK_TC_FLUSH/BLK_TC_FUA
@ 2012-01-09 11:30 Stefan Hajnoczi
  2012-01-09 21:03 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Hajnoczi @ 2012-01-09 11:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: Steven Rostedt, Namhyung Kim, Stefan Hajnoczi

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.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 Makefile     |   14 +++++++++++---
 plugin_blk.c |   11 +++++++++++
 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
 
 # $(call test-build, snippet, ret) -> ret if snippet compiles
 #                                  -> empty otherwise
-test-build = $(if $(shell $(CC) -o /dev/null -c -x c - > /dev/null 2>&1 \
-	                  <<<'$1' && echo y), $2)
+test-build = $(if $(shell sh -c 'echo "$(1)" | \
+	$(CC) -o /dev/null -c -x c - > /dev/null 2>&1 && echo y'), $2)
 
 # have udis86 disassembler library?
 udis86-flags := $(call test-build,\#include <udis86.h>,-DHAVE_UDIS86 -ludis86)
 
+define BLK_TC_FLUSH_SOURCE
+#include <linux/blktrace_api.h>
+int main(void) { return BLK_TC_FLUSH; }
+endef
+
+# have flush/fua block layer instead of barriers?
+blk-flags := $(call test-build,$(BLK_TC_FLUSH_SOURCE),-DHAVE_BLK_TC_FLUSH)
+
 ifeq ("$(origin O)", "command line")
   BUILD_OUTPUT := $(O)
 endif
@@ -223,7 +231,7 @@ endif
 
 # Append required CFLAGS
 override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ)
-override CFLAGS += $(udis86-flags)
+override CFLAGS += $(udis86-flags) $(blk-flags)
 
 ifeq ($(VERBOSE),1)
   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)
 		goto out;
 	}
 
+#if defined(HAVE_BLK_TC_FLUSH)
+	if (tc & BLK_TC_FLUSH)
+		rwbs[i++] = 'F';
+#endif
+
 	if (tc & BLK_TC_DISCARD)
 		rwbs[i++] = 'D';
 	else if (tc & BLK_TC_WRITE)
@@ -63,10 +68,16 @@ static void fill_rwbs(char *rwbs, int action, unsigned int bytes)
 	else
 		rwbs[i++] = 'N';
 
+#if defined(HAVE_BLK_TC_FLUSH)
+	if (tc & BLK_TC_FUA)
+		rwbs[i++] = 'F';
+#endif
 	if (tc & BLK_TC_AHEAD)
 		rwbs[i++] = 'A';
+#if !defined(HAVE_BLK_TC_FLUSH)
 	if (tc & BLK_TC_BARRIER)
 		rwbs[i++] = 'B';
+#endif
 	if (tc & BLK_TC_SYNC)
 		rwbs[i++] = 'S';
 	if (tc & BLK_TC_META)
-- 
1.7.7.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2][trace-cmd] blk plugin: replace BLK_TC_BARRIER with BLK_TC_FLUSH/BLK_TC_FUA
  2012-01-09 11:30 [PATCH v2][trace-cmd] blk plugin: replace BLK_TC_BARRIER with BLK_TC_FLUSH/BLK_TC_FUA Stefan Hajnoczi
@ 2012-01-09 21:03 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2012-01-09 21:03 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: linux-kernel, Namhyung Kim

On Mon, 2012-01-09 at 11:30 +0000, Stefan Hajnoczi wrote:
> 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.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>



Thanks, applied!

-- Steve



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-09 21:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-09 11:30 [PATCH v2][trace-cmd] blk plugin: replace BLK_TC_BARRIER with BLK_TC_FLUSH/BLK_TC_FUA Stefan Hajnoczi
2012-01-09 21:03 ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®