Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031350AbbKDWRU (ORCPT ); Wed, 4 Nov 2015 17:17:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59336 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031118AbbKDWI7 (ORCPT ); Wed, 4 Nov 2015 17:08:59 -0500 From: mchristi@redhat.com To: linux-fsdevel@vger.kernel.org, dm-devel@redhat.com, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, drbd-dev@lists.linbit.com Cc: Mike Christie Subject: [PATCH 19/32] block: add helper to get data dir from op Date: Wed, 4 Nov 2015 16:08:16 -0600 Message-Id: <1446674909-5371-20-git-send-email-mchristi@redhat.com> In-Reply-To: <1446674909-5371-1-git-send-email-mchristi@redhat.com> References: <1446674909-5371-1-git-send-email-mchristi@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1314 Lines: 44 From: Mike Christie 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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/