linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org
Cc: adilger@dilger.ca, hch@infradead.org, martin.petersen@oracle.com,
	Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 01/12] block: add support for carrying stream information in a bio
Date: Thu, 15 Jun 2017 10:41:59 -0600	[thread overview]
Message-ID: <1497544930-19174-2-git-send-email-axboe@kernel.dk> (raw)
In-Reply-To: <1497544930-19174-1-git-send-email-axboe@kernel.dk>

No functional changes in this patch, we just add four flags
that will be used to denote a stream type, and ensure that we
don't merge across different stream types.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/blk-merge.c         | 16 ++++++++++++++++
 include/linux/blk_types.h | 11 +++++++++++
 2 files changed, 27 insertions(+)

diff --git a/block/blk-merge.c b/block/blk-merge.c
index 3990ae406341..7d299df3b12b 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -693,6 +693,14 @@ static struct request *attempt_merge(struct request_queue *q,
 		return NULL;
 
 	/*
+	 * Don't allow merge of different streams, or for a stream with
+	 * non-stream IO.
+	 */
+	if ((req->cmd_flags & REQ_WRITE_LIFE_MASK) !=
+	    (next->cmd_flags & REQ_WRITE_LIFE_MASK))
+		return NULL;
+
+	/*
 	 * If we are allowed to merge, then append bio list
 	 * from next to rq and release next. merge_requests_fn
 	 * will have updated segment counts, update sector
@@ -811,6 +819,14 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio)
 	    !blk_write_same_mergeable(rq->bio, bio))
 		return false;
 
+	/*
+	 * Don't allow merge of different streams, or for a stream with
+	 * non-stream IO.
+	 */
+	if ((rq->cmd_flags & REQ_WRITE_LIFE_MASK) !=
+	    (bio->bi_opf & REQ_WRITE_LIFE_MASK))
+		return false;
+
 	return true;
 }
 
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 61339bc44400..57d1eb530799 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -201,6 +201,10 @@ enum req_flag_bits {
 	__REQ_PREFLUSH,		/* request for cache flush */
 	__REQ_RAHEAD,		/* read ahead, can fail anytime */
 	__REQ_BACKGROUND,	/* background IO */
+	__REQ_WRITE_SHORT,	/* short life time write */
+	__REQ_WRITE_MEDIUM,	/* medium life time write */
+	__REQ_WRITE_LONG,	/* long life time write */
+	__REQ_WRITE_EXTREME,	/* extremely long life time write */
 
 	/* command specific flags for REQ_OP_WRITE_ZEROES: */
 	__REQ_NOUNMAP,		/* do not free blocks when zeroing */
@@ -221,6 +225,13 @@ enum req_flag_bits {
 #define REQ_PREFLUSH		(1ULL << __REQ_PREFLUSH)
 #define REQ_RAHEAD		(1ULL << __REQ_RAHEAD)
 #define REQ_BACKGROUND		(1ULL << __REQ_BACKGROUND)
+#define REQ_WRITE_SHORT		(1ULL << __REQ_WRITE_SHORT)
+#define REQ_WRITE_MEDIUM	(1ULL << __REQ_WRITE_MEDIUM)
+#define REQ_WRITE_LONG		(1ULL << __REQ_WRITE_LONG)
+#define REQ_WRITE_EXTREME	(1ULL << __REQ_WRITE_EXTREME)
+
+#define REQ_WRITE_LIFE_MASK	(REQ_WRITE_SHORT | REQ_WRITE_MEDIUM | \
+					REQ_WRITE_LONG | REQ_WRITE_EXTREME)
 
 #define REQ_NOUNMAP		(1ULL << __REQ_NOUNMAP)
 
-- 
2.7.4

  reply	other threads:[~2017-06-15 16:42 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-15 16:41 [PATCHSET v5] Add support for write life time hints Jens Axboe
2017-06-15 16:41 ` Jens Axboe [this message]
2017-06-16 16:39   ` [PATCH 01/12] block: add support for carrying stream information in a bio Martin K. Petersen
2017-06-16 16:42     ` Jens Axboe
2017-06-15 16:42 ` [PATCH 02/12] blk-mq: expose stream write stats through debugfs Jens Axboe
2017-06-16 16:38   ` Martin K. Petersen
2017-06-16 16:41     ` Jens Axboe
2017-06-15 16:42 ` [PATCH 03/12] fs: add support for an inode to carry write hint related data Jens Axboe
2017-06-15 16:42 ` [PATCH 04/12] fs: add support for allowing applications to pass in write life time hints Jens Axboe
2017-06-15 16:42 ` [PATCH 05/12] fs: add fcntl() interface for setting/getting " Jens Axboe
2017-06-16 16:44   ` Martin K. Petersen
2017-06-16 16:55     ` Jens Axboe
2017-06-16 17:59     ` Christoph Hellwig
2017-06-15 16:42 ` [PATCH 06/12] block: add helpers for setting/checking write hint validity Jens Axboe
2017-06-16 16:47   ` Martin K. Petersen
2017-06-16 16:53     ` Jens Axboe
2017-06-15 16:42 ` [PATCH 07/12] fs: add O_DIRECT support for sending down bio stream information Jens Axboe
2017-06-15 16:42 ` [PATCH 08/12] fs: add support for buffered writeback to pass down write hints Jens Axboe
2017-06-15 16:42 ` [PATCH 09/12] ext4: add support for passing in write hints for buffered writes Jens Axboe
2017-06-15 16:42 ` [PATCH 10/12] xfs: " Jens Axboe
2017-06-15 16:42 ` [PATCH 11/12] btrfs: " Jens Axboe
2017-06-15 16:42 ` [PATCH 12/12] nvme: add support for streams and directives Jens Axboe

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=1497544930-19174-2-git-send-email-axboe@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=adilger@dilger.ca \
    --cc=hch@infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=martin.petersen@oracle.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;
as well as URLs for NNTP newsgroup(s).