From patchwork Wed Jun 14 19:05:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9787255 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 252C860325 for ; Wed, 14 Jun 2017 19:05:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 178E624B44 for ; Wed, 14 Jun 2017 19:05:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BC0925E13; Wed, 14 Jun 2017 19:05:42 +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 89A1A24B44 for ; Wed, 14 Jun 2017 19:05:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751635AbdFNTFk (ORCPT ); Wed, 14 Jun 2017 15:05:40 -0400 Received: from mail-io0-f177.google.com ([209.85.223.177]:36336 "EHLO mail-io0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750768AbdFNTFj (ORCPT ); Wed, 14 Jun 2017 15:05:39 -0400 Received: by mail-io0-f177.google.com with SMTP id y77so6266551ioe.3 for ; Wed, 14 Jun 2017 12:05:39 -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=19if4OMuxrqOd4CFyYqZePFWNJmM4YXcNmfPJ2fmttEo/qprqXiU6sns3saMaVJ3+d mRkQGv3niKKUUMla8Tmx6HCZyyFAqbHMSkae1+BikhWuNHlw8aHmparaUl3UXmDY6Zgx nzPrq8Gea5Fnwk/CIFMITn+X0NgGizZzT/KEgx8MqFjgj1xnWqZ8OCgdFjce7H5IWDcf dZNIzvAlBVZMoQcPury86hbuQeiW+jnku9x4UG443GT5nOu+XhdZZ3D3ld5iHBffrGWP a8pgwZw9K8xVOz2hArZ1ybinQlCNJs1ZVbkSLik5/QKBJ81eBwkO/yCm+J4/Wp0VEkq0 jZdg== 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=M9jn9zCUyJ+JMhZPXedF9eYY/MpYm0hqTja0d/6NiXZRRGKofOym3lkBCgg9TO2SVe z/vJ4Jm5RFWVJszSXZFO6Zm8FFYosdolqisqxLigt3bZUGMfjW02NWETds7maas4BTs5 YlfLb0UeoFykofntB1kNYtxznIJPhG41q42BlDuVGTNh0n/4d1yA5Wl4uABy5lsei6kN YCcLL+ULep1k8c5kR29aH2LgzwiFnWkwxkB+2uC18QXmayTu3B0gP2b+Bx9jg98hpRT9 ncoWtF1DYBqtI+GcwhEYTfDxgaXxIZJPOna8oU3HJDn2I6AVWD5EirhmFYkEMjW/kkkX p8Rw== X-Gm-Message-State: AKS2vOzqJFNPBdEzv5j2rVWp+mIeJGePwvOPUokhmbLLuq40+arXBa9S EXkN1rY7Yjewufgf X-Received: by 10.107.164.219 with SMTP id d88mr1696107ioj.157.1497467138672; Wed, 14 Jun 2017 12:05:38 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id h67sm380361itb.19.2017.06.14.12.05.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Jun 2017 12:05:38 -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 13:05:24 -0600 Message-Id: <1497467134-6323-2-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497467134-6323-1-git-send-email-axboe@kernel.dk> References: <1497467134-6323-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)