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: 9789259 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 861746038E for ; Thu, 15 Jun 2017 16:42:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 789AD284F5 for ; Thu, 15 Jun 2017 16:42:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C6A628552; Thu, 15 Jun 2017 16:42:19 +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=ham 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 F01F5284F5 for ; Thu, 15 Jun 2017 16:42:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750803AbdFOQmQ (ORCPT ); Thu, 15 Jun 2017 12:42:16 -0400 Received: from mail-io0-f175.google.com ([209.85.223.175]:33675 "EHLO mail-io0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750961AbdFOQmP (ORCPT ); Thu, 15 Jun 2017 12:42:15 -0400 Received: by mail-io0-f175.google.com with SMTP id t87so15457176ioe.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=aayRwD3r538cGbvISsPIFAhADQv0/3IT9FFSLUZZHrx+6kOTH1taKPKpI/NvRtDGXU gmPNLuFtsQrRV+4nMEaeYtK/Fk4+YGtBb3e75JkT2foCCTC3BIYX2FtZAmDW0KayfC93 n/vN1s6Jz57Qq6Q04T7SWVUtSYzu8VPm/GU6dwMDU4dtB0fH+/CRKW6TGzCG9VVi1oJv bEzr/h+oNx6U6zrwzipcXYVSi9oSqCoxpsz2D1mRI2L3JqSKDI1+jXqd95lKDBGVzh27 LWJGMUlbWUyE77lw2VsQ2owEN8ic8w39+abG1xdtKAuA7dvCAzj0PII4z9EAZ5/RWLyO bArA== X-Gm-Message-State: AKS2vOz1pzmPAP/ZT3b1C9KRcj8BnB91R5fqprxmd/d0tl87k9XEIusB nzsyn9EeqxRsolpZ 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-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@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)