lkml.org 
[lkml]   [2015]   [Nov]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 19/32] block: add helper to get data dir from op
Date
From: Mike Christie <mchristi@redhat.com>

In later patches the op will no longer be a bitmap, so we will
not have REQ_WRITE set for all non reads like discard, flush,
and write same. Drivers will still want to treat them as writes
for accounting reasons, so this patch adds a helper to translate
a op to a data direction.

Signed-off-by: Mike Christie <mchristi@redhat.com>
---
include/linux/blkdev.h | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 19c2e94..cf5f518 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -586,6 +586,18 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)

#define list_entry_rq(ptr) list_entry((ptr), struct request, queuelist)

+/*
+ * Non REQ_OP_WRITE requests like discard, write same, etc, are
+ * considered WRITEs.
+ */
+static inline int op_to_data_dir(int op)
+{
+ if (op == REQ_OP_READ)
+ return READ;
+ else
+ return WRITE;
+}
+
#define rq_data_dir(rq) ((int)((rq)->cmd_flags & 1))

/*
--
1.8.3.1


\
 
 \ /
  Last update: 2015-11-04 23:41    [W:1.647 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site