From patchwork Thu Jun 15 16:41:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9789265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9465460384 for ; Thu, 15 Jun 2017 16:42:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 860B0284F5 for ; Thu, 15 Jun 2017 16:42:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B214286BF; Thu, 15 Jun 2017 16:42:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D88A286CF for ; Thu, 15 Jun 2017 16:42:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751888AbdFOQmV (ORCPT ); Thu, 15 Jun 2017 12:42:21 -0400 Received: from mail-io0-f175.google.com ([209.85.223.175]:33676 "EHLO mail-io0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750980AbdFOQmP (ORCPT ); Thu, 15 Jun 2017 12:42:15 -0400 Received: by mail-io0-f175.google.com with SMTP id t87so15457230ioe.0 for ; Thu, 15 Jun 2017 09:42:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bsEMtqA2qQbrAlhuOVWQn43NYd0PNY8vtDTlD2jb4wg=; b=fihvP4VUKZEwyh4JmX21taHAp2w34z8YB3/z0jpqFkbQUT0GS/4o71cU5HSQmC2c0d bTiMcbvAVwowkP7Nog0LA7dUoyWERwitgZ+4P2RX/TGxnhER6eSyyHh7+0UlNjovJV83 NhWKrNk+9QBgE4aFBhUrNNqYDtyljyS7ACXvRp5h4T9Z3zJy3htkR2yn4Vp5wMbRU8m4 RByqPSaLthZUrm0nyHBRNkaXpuZGDR5wrAiEX6D7tNzRn8AJcfVnIRG110aCVcN0VeOT DUsrVt6h/6tKiqZs+4s9C71yEup8fTZpCAaH3wg6v4DD+9TJCX1YDX984ObGyocn4Mgo rT9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bsEMtqA2qQbrAlhuOVWQn43NYd0PNY8vtDTlD2jb4wg=; b=dypQtT6rCZ/ckLaSMupHwrvM8vEkj++0OoZ+djV+A3b84XwFaAio0x1wVBMQdacQH0 rJegt7TtLwD4ULLirr+XVtearXlKppPnWJK3CKbgNsmxM3kBKka/yY5iBr+8GUzNQRW+ BMx7k51uT0tE/r1cQrRdWf4P5EEouF040oz+B05i4kKMLlQYNDjH3WvIDWCDgopdirVE 0oxZsvLyoDDdmYX+Wt4aaCYsPGg1BpOzF4nIuo4KDt1fzCUa+le+J5Dn/Nv2wHkdJIhj 6cRwohlMu7UBuT0GgXTztROwbJpOtDMu1wEoQ9MLyu9rOYIi3Tn3CvJzfWDaaHB7XMlN tG1w== X-Gm-Message-State: AKS2vOz8NC/2ORe+z3Fp7ZbRvihs9lvxiGb7nD6z8jzXrll7eAuwrmv7 5z4X3PgR6IaLxcymOUYmvQ== X-Received: by 10.107.135.224 with SMTP id r93mr6199225ioi.36.1497544934429; Thu, 15 Jun 2017 09:42:14 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id 97sm313476iot.25.2017.06.15.09.42.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Jun 2017 09:42:13 -0700 (PDT) From: Jens Axboe To: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org Cc: adilger@dilger.ca, hch@infradead.org, martin.petersen@oracle.com, Jens Axboe Subject: [PATCH 01/12] block: add support for carrying stream information in a bio Date: Thu, 15 Jun 2017 10:41:59 -0600 Message-Id: <1497544930-19174-2-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497544930-19174-1-git-send-email-axboe@kernel.dk> References: <1497544930-19174-1-git-send-email-axboe@kernel.dk> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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)