From patchwork Fri Jun 16 17:24:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9792297 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 744EC60231 for ; Fri, 16 Jun 2017 17:24:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 594FF200E7 for ; Fri, 16 Jun 2017 17:24:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C3E42866E; Fri, 16 Jun 2017 17:24:56 +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 4CE7D2866C for ; Fri, 16 Jun 2017 17:24:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752171AbdFPRYx (ORCPT ); Fri, 16 Jun 2017 13:24:53 -0400 Received: from mail-io0-f179.google.com ([209.85.223.179]:33982 "EHLO mail-io0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750893AbdFPRYu (ORCPT ); Fri, 16 Jun 2017 13:24:50 -0400 Received: by mail-io0-f179.google.com with SMTP id i7so34255801ioe.1 for ; Fri, 16 Jun 2017 10:24:49 -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=xhUEqdKrCjG3OPxfHWBI4S4ju74DsVCueFoMTA9MxUM=; b=xxpSt/DVT2FyzCa/PvSjVbT9kGzvJ9pn1UdbDgiRARySVc5JzJ7I+YnF4Yi+d1w07M zHFO7bjoYrrjRc5FU8sviywVdshbnoSmurVFJ80m1WD9a8Z9L/ltyldrhIYdbYJ77HDp 2MXGLd8s/50AJPPb4J+f34354BB0HUzLBX9SmjwFnyH/vyZfy6kieEHTlGPtw/BVJqnr 8r/3BTS1TO9aPja2w9+F6yJZUw1kjRA/TizeSld8gchnyDhq4Xstp1KZE5d8QfQ7w1UT RAPZ26RvxiReY1xjxfuxJ1gHOqDIE8XUtpI4CBtLSIItRQDCQLRW7RCZiK4km82QYYK3 B8sQ== 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=xhUEqdKrCjG3OPxfHWBI4S4ju74DsVCueFoMTA9MxUM=; b=Jqd+l3aBxWjdEe0MCmnXiNp5Ul6B2pWkUoxL124THFffiASx6OebBdwDGwRoyUTDT2 Vc6UOInLtKTEhY66GcumwMlV+2agdfJoWcjTqSujfPkkZ9S1tliHBwHscKZG+nUrEW3a uKtL2rdSdCtPcdhMlBhZmSdusctnXeEhWa6zrt/RtfauqhCc/5zQNoK28lRKJFO3Nuv1 VXp1kq/M3AdCm/uFSokezmPN6OpMkexuMIjXQ0+1h2RQLXGJzBZo+unENHcOThpllTs4 qUFF9WFNVfwdUDBp20QD55gS/7evMSFmhULSwmyv9HnYHXQWyV4EHRh8lHu6+SRIC6HJ j7lw== X-Gm-Message-State: AKS2vOw0JXJ+35KIqgboSYmeeCz9v9qn2CrUqVt7SwvD/UF5v9NoKspS lbkKTgf7r7QnqVoBHyKjPw== X-Received: by 10.107.9.93 with SMTP id j90mr11586896ioi.172.1497633889033; Fri, 16 Jun 2017 10:24:49 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id e31sm1661101ioi.51.2017.06.16.10.24.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jun 2017 10:24:48 -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 02/11] block: add support for write hints in a bio Date: Fri, 16 Jun 2017 11:24:34 -0600 Message-Id: <1497633883-21230-3-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497633883-21230-1-git-send-email-axboe@kernel.dk> References: <1497633883-21230-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 set aside 3 bits in the bio/request flags, which can be used to hold a WRITE_HINT_* life time hint. Ensure that we don't merge requests that have different life time hints assigned to them. Signed-off-by: Jens Axboe --- block/blk-merge.c | 16 ++++++++++++++++ include/linux/blk_types.h | 15 +++++++++++++++ 2 files changed, 31 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..0dd8d569d52f 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -7,6 +7,7 @@ #include #include +#include struct bio_set; struct bio; @@ -201,6 +202,9 @@ enum req_flag_bits { __REQ_PREFLUSH, /* request for cache flush */ __REQ_RAHEAD, /* read ahead, can fail anytime */ __REQ_BACKGROUND, /* background IO */ + __REQ_WRITE_HINT_SHIFT, /* 3 bits for life time hint */ + __REQ_WRITE_HINT_PAD1, + __REQ_WRITE_HINT_PAD2, /* command specific flags for REQ_OP_WRITE_ZEROES: */ __REQ_NOUNMAP, /* do not free blocks when zeroing */ @@ -221,6 +225,12 @@ 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 (WRITE_LIFE_SHORT << __REQ_WRITE_HINT_SHIFT) +#define REQ_WRITE_MEDIUM (WRITE_LIFE_MEDIUM << __REQ_WRITE_HINT_SHIFT) +#define REQ_WRITE_LONG (WRITE_LIFE_LONG << __REQ_WRITE_HINT_SHIFT) +#define REQ_WRITE_EXTREME (WRITE_LIFE_EXTREME << __REQ_WRITE_HINT_SHIFT) + +#define REQ_WRITE_LIFE_MASK (0x7 << __REQ_WRITE_HINT_SHIFT) #define REQ_NOUNMAP (1ULL << __REQ_NOUNMAP) @@ -312,4 +322,9 @@ struct blk_rq_stat { u64 batch; }; +static inline unsigned int write_hint_to_opf(enum rw_hint hint) +{ + return hint << __REQ_WRITE_HINT_SHIFT; +} + #endif /* __LINUX_BLK_TYPES_H */