From patchwork Sat Jun 17 19:59:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9794363 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 DEEE2600F6 for ; Sat, 17 Jun 2017 20:00:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D33952841D for ; Sat, 17 Jun 2017 20:00:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C80C72843F; Sat, 17 Jun 2017 20:00:11 +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 29DD2283FF for ; Sat, 17 Jun 2017 20:00:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752699AbdFQUAH (ORCPT ); Sat, 17 Jun 2017 16:00:07 -0400 Received: from mail-it0-f46.google.com ([209.85.214.46]:37880 "EHLO mail-it0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752426AbdFQUAG (ORCPT ); Sat, 17 Jun 2017 16:00:06 -0400 Received: by mail-it0-f46.google.com with SMTP id m47so41603349iti.0 for ; Sat, 17 Jun 2017 13:00:05 -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=N5UM+Eauho9XQAKgfcxJa8JKaFnA7NGQFdsI9Aj0l2noNBC0CfIiGPQKxHVk+eFTq/ 403LfBnLqm1sUsZOEQlLwMK6LYlrzpYCmWqC33w4gL2C4RVZuqPyC/WDIAl/KBVgYqOC PhtbDvYGDy8F9HCPC/KHODmG8W5Tgazg0HPOiQW3jjwWh8vNb+Y6efp7uCRsW8kTxlOp 25hHCfTgsuAs/7M7hOG3ed2hLVnKTSmIW3igkRaorUp+VFX9zLrZxX+mXm3s3ybr7uYt r8atkEiTEXkmWHvtZhHk1j0JzydnKUNXxxHs+UOGogmlGuCHuEhU/ROwxth7XRpL7ZIc X/VA== 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=C3BULlrA9AUO98+/GkyUQtjlt8EKVdp7FzJpAShejvJqsG3VGbgANatJfVvp5tDWFR uJxlwowm0nBMHn05RBeCMg8p86PZfAMVcOG+5W/RsPiQ+XD57XjRUS1mQsaP1vlzJLoN SXCLdTRCjavBVBfuClYVJmK7Udmr1pW9lwiWRt8z4IVovs/a9eCADJGlSPi8lKrke71l GjRohiVpTJKKQ7sfG8Z80sU3c/elvH4hKIkfZ895QVQZAiZIWl/wJZh/seUN16kGAxQD OqNE8E40C2P54l30WCFmN6ZjUvxMKarrpZVCALgXq8oGa0iDQkhLG4GIww9Hi5/9m+MT T5uw== X-Gm-Message-State: AKS2vOyz+by4g5Ya2Z0+1J3LR80nLMYRVZMWAoNCpjVCqicVyi4pwwIg J91chiCYhaHaGt+E X-Received: by 10.36.94.134 with SMTP id h128mr15657787itb.92.1497729605459; Sat, 17 Jun 2017 13:00:05 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id w199sm537049iod.15.2017.06.17.13.00.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 17 Jun 2017 13:00:04 -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: Sat, 17 Jun 2017 13:59:45 -0600 Message-Id: <1497729594-4707-3-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497729594-4707-1-git-send-email-axboe@kernel.dk> References: <1497729594-4707-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 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 */