linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][trace-cmd] blk plugin: replace BLK_TC_BARRIER with BLK_TC_FLUSH/BLK_TC_FUA
@ 2012-01-08 13:19 Stefan Hajnoczi
  2012-01-08 16:27 ` Namhyung Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Hajnoczi @ 2012-01-08 13:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Steven Rostedt, 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.  The drawback is that this breaks the
build for pre-c09c47caedc kernel headers.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
There is an alternative version of this patch with a build test in the Makefile
so that we know whether to use BLK_TC_BARRIER or BLK_TC_FLUSH/BLK_TC_FUA.  That
would support both old and new kernel headers using a HAVE_BLK_TC_FLUSH #ifdef.

I wasn't able to find the right makefile shell escaping magic to get the
build-test function to work.  If anyone knows how to test a snippet like the
following, then that would be nicer:

  #include <linux/blktrace_api.h>
  int main(void) { return BLK_TC_FLUSH; }

 plugin_blk.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/plugin_blk.c b/plugin_blk.c
index 9327b17..4352cb7 100644
--- a/plugin_blk.c
+++ b/plugin_blk.c
@@ -54,6 +54,9 @@ static void fill_rwbs(char *rwbs, int action, unsigned int bytes)
 		goto out;
 	}
 
+	if (tc & BLK_TC_FLUSH)
+		rwbs[i++] = 'F';
+
 	if (tc & BLK_TC_DISCARD)
 		rwbs[i++] = 'D';
 	else if (tc & BLK_TC_WRITE)
@@ -63,10 +66,10 @@ static void fill_rwbs(char *rwbs, int action, unsigned int bytes)
 	else
 		rwbs[i++] = 'N';
 
+	if (tc & BLK_TC_FUA)
+		rwbs[i++] = 'F';
 	if (tc & BLK_TC_AHEAD)
 		rwbs[i++] = 'A';
-	if (tc & BLK_TC_BARRIER)
-		rwbs[i++] = 'B';
 	if (tc & BLK_TC_SYNC)
 		rwbs[i++] = 'S';
 	if (tc & BLK_TC_META)
-- 
1.7.7.3


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

* Re: [PATCH][trace-cmd] blk plugin: replace BLK_TC_BARRIER with BLK_TC_FLUSH/BLK_TC_FUA
  2012-01-08 13:19 [PATCH][trace-cmd] blk plugin: replace BLK_TC_BARRIER with BLK_TC_FLUSH/BLK_TC_FUA Stefan Hajnoczi
@ 2012-01-08 16:27 ` Namhyung Kim
  2012-01-09 11:11   ` Stefan Hajnoczi
  0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2012-01-08 16:27 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: linux-kernel, Steven Rostedt

Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> 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.  The drawback is that this breaks the
> build for pre-c09c47caedc kernel headers.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> ---
> There is an alternative version of this patch with a build test in the Makefile
> so that we know whether to use BLK_TC_BARRIER or BLK_TC_FLUSH/BLK_TC_FUA.  That
> would support both old and new kernel headers using a HAVE_BLK_TC_FLUSH #ifdef.
>
> I wasn't able to find the right makefile shell escaping magic to get the
> build-test function to work.  If anyone knows how to test a snippet like the
> following, then that would be nicer:
>
>   #include <linux/blktrace_api.h>
>   int main(void) { return BLK_TC_FLUSH; }
>

Hi,

The perf uses following code for that:

# try-cc
# Usage: option = $(call try-cc, source-to-build, cc-options)
try-cc = $(shell sh -c						  \
	'TMP="$(OUTPUT)$(TMPOUT).$$$$";				  \
	 echo "$(1)" |						  \
	 $(CC) -x c - $(2) -o "$$TMP" > /dev/null 2>&1 && echo y; \
	 rm -f "$$TMP"')

Thanks,
Namhyung Kim

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

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

On Mon, Jan 09, 2012 at 01:27:12AM +0900, Namhyung Kim wrote:
> Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> 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.  The drawback is that this breaks the
> > build for pre-c09c47caedc kernel headers.
> >
> > Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> > ---
> > There is an alternative version of this patch with a build test in the Makefile
> > so that we know whether to use BLK_TC_BARRIER or BLK_TC_FLUSH/BLK_TC_FUA.  That
> > would support both old and new kernel headers using a HAVE_BLK_TC_FLUSH #ifdef.
> >
> > I wasn't able to find the right makefile shell escaping magic to get the
> > build-test function to work.  If anyone knows how to test a snippet like the
> > following, then that would be nicer:
> >
> >   #include <linux/blktrace_api.h>
> >   int main(void) { return BLK_TC_FLUSH; }
> >
> 
> Hi,
> 
> The perf uses following code for that:
> 
> # try-cc
> # Usage: option = $(call try-cc, source-to-build, cc-options)
> try-cc = $(shell sh -c						  \
> 	'TMP="$(OUTPUT)$(TMPOUT).$$$$";				  \
> 	 echo "$(1)" |						  \
> 	 $(CC) -x c - $(2) -o "$$TMP" > /dev/null 2>&1 && echo y; \
> 	 rm -f "$$TMP"')

Looks perfect, thanks!

Stefan


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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-08 13:19 [PATCH][trace-cmd] blk plugin: replace BLK_TC_BARRIER with BLK_TC_FLUSH/BLK_TC_FUA Stefan Hajnoczi
2012-01-08 16:27 ` Namhyung Kim
2012-01-09 11:11   ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).