From patchwork Thu Jun 15 03:45:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9787993 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 510E860231 for ; Thu, 15 Jun 2017 03:45:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4750727C2D for ; Thu, 15 Jun 2017 03:45:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3768923F88; Thu, 15 Jun 2017 03:45:24 +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 D951223F88 for ; Thu, 15 Jun 2017 03:45:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752031AbdFODpV (ORCPT ); Wed, 14 Jun 2017 23:45:21 -0400 Received: from mail-pg0-f46.google.com ([74.125.83.46]:36083 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751711AbdFODpT (ORCPT ); Wed, 14 Jun 2017 23:45:19 -0400 Received: by mail-pg0-f46.google.com with SMTP id a70so1620229pge.3 for ; Wed, 14 Jun 2017 20:45:19 -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=n2EHcy/fAxHUuhkmK9sBu176R3+9KzCRFFFKzC/GEV3+Zpzx6tabXZ1I9Kf2XI1xLR kjCHJXcnMD0LSwZLG3f86Frh8rwpeYncbBr6Vyg6vR3skWCPqZO3OWqUezXipLHT4FtY eQUegwnAUTw9f7d5ajDQdNpkiCWmBtCAR/wiHHlY7vlL9E2m74Gku1LNQPz3/fSZHDhG FlDEBAXwlwHqKlKBAQhpJdJeFdgTQgBsXSi1yhyvbl2PWaUV2T9OGeD3IJTGH1RamrNM LfYsiK8aUBBYd6GK9q4WXqnsm0gF4s4k8dLmI/O3I0yWct0MTBtb7cJ4DFraak1OuEWn g62w== 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=dfXJNh+4tNxybdTXMbS7QZ1L2xgF2E64cNz2LyPU4Ww0974oL02DFJDg+w4XwYt6uy 67bWIF5BpKZUN2H1GbLNa+wkX/tHZEKKvWIXM73S3fphtJB/292Iu5Y0Smt1USXXXKWo 16TboldOCc7J4ctjvIAuIQZ+cJ3k+9hAnomsJRBhYzpfcsrkDkDQAekI4qdUAi/OqKAT z9R9LlyJY3zNMKMgk9og73pQq5axozbPqFOgsCIu7kvjyeFxQpfagf8u+tnJJZv6ZLz1 UeJivgxURp/mx5f1yOw79yj6WZcyVOXrJt3EXACFacOoT5iVT/xdSdgcaGdppkLPKDHx wsBQ== X-Gm-Message-State: AKS2vOyva+zOAJDWXSFxKxm8EbORe2GBAOCvmAJOWOWvUmZK9lx7Qi0i 2jaljmnWE7Ca2y2yFFWvHQ== X-Received: by 10.84.231.15 with SMTP id f15mr3807153plk.131.1497498318967; Wed, 14 Jun 2017 20:45:18 -0700 (PDT) Received: from localhost.localdomain (66.29.164.166.static.utbb.net. [66.29.164.166]) by smtp.gmail.com with ESMTPSA id f71sm2532627pfd.98.2017.06.14.20.45.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Jun 2017 20:45:18 -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/11] block: add support for carrying stream information in a bio Date: Wed, 14 Jun 2017 21:45:02 -0600 Message-Id: <1497498312-17704-2-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497498312-17704-1-git-send-email-axboe@kernel.dk> References: <1497498312-17704-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)