From: Bart Van Assche <bart.vanassche@sandisk.com>
To: device-mapper development <dm-devel@redhat.com>,
<linux-fsdevel@vger.kernel.org>, <linux-raid@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-scsi@vger.kernel.org>,
<drbd-dev@lists.linbit.com>
Cc: Mike Christie <mchristi@redhat.com>
Subject: Re: [Drbd-dev] [dm-devel] [PATCH 19/32] block: add helper to get data dir from op
Date: Wed, 4 Nov 2015 14:44:03 -0800 [thread overview]
Message-ID: <563A8A33.3000002@sandisk.com> (raw)
In-Reply-To: <1446674909-5371-20-git-send-email-mchristi@redhat.com>
On 11/04/2015 02:08 PM, mchristi@redhat.com wrote:
> 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))
>
> /*
>
How about introducing two functions - op_is_write() and op_is_read() ? I
think that approach will result in shorter and easier to read code in
the contexts where these functions are used.
Bart.
next parent reply other threads:[~2015-11-04 22:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1446674909-5371-1-git-send-email-mchristi@redhat.com>
[not found] ` <1446674909-5371-20-git-send-email-mchristi@redhat.com>
2015-11-04 22:44 ` Bart Van Assche [this message]
[not found] ` <563B930F.7040705@redhat.com>
2015-11-07 10:19 ` [Drbd-dev] [dm-devel] [PATCH 19/32] block: add helper to get data dir from op Christoph Hellwig
2015-11-07 10:10 ` [Drbd-dev] [RESEND RFC PATCH 00/32] separate operations from flags in the bio/request structs Christoph Hellwig
[not found] ` <1446674909-5371-7-git-send-email-mchristi@redhat.com>
2015-11-07 10:17 ` [Drbd-dev] [PATCH 06/32] xen blkback: prepare for bi_rw split Christoph Hellwig
[not found] ` <1446674909-5371-33-git-send-email-mchristi@redhat.com>
2015-11-07 10:21 ` [Drbd-dev] [PATCH 32/32] block: remove __REQ op defs and reduce bi_op/bi_rw sizes Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=563A8A33.3000002@sandisk.com \
--to=bart.vanassche@sandisk.com \
--cc=dm-devel@redhat.com \
--cc=drbd-dev@lists.linbit.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mchristi@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox