From patchwork Wed Jun 14 19:05:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9787269 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 4418360325 for ; Wed, 14 Jun 2017 19:05:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3731824B44 for ; Wed, 14 Jun 2017 19:05:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C2572625B; Wed, 14 Jun 2017 19:05:54 +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 229D024B44 for ; Wed, 14 Jun 2017 19:05:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752080AbdFNTFv (ORCPT ); Wed, 14 Jun 2017 15:05:51 -0400 Received: from mail-io0-f171.google.com ([209.85.223.171]:34574 "EHLO mail-io0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751976AbdFNTFp (ORCPT ); Wed, 14 Jun 2017 15:05:45 -0400 Received: by mail-io0-f171.google.com with SMTP id i7so6312811ioe.1 for ; Wed, 14 Jun 2017 12:05:45 -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=8wevmODjzZTflimxJfsdYSmjcyp6tyRJZ7XkbMiEpsA=; b=xCJc9tblv8vBg9EhQXZievS92mmTrzFIqYvv3I1fjzvtrcNPeELZnw3EmoBBqcddRQ nRStSvKHHcHnUxbMqYhFBfscU8jrYOQUYMdVbXMe2WYaEZb2mpv447T6ySwYDRyJRl8L sgVJSfNPB5LLbpBRe2zVPSskVfgDHH3e7d77Ei290wa6vmEpfYGqjjI5DLUs4ElchTAW hiE+Tpp+2PB285mm4EAWGuBjem0hPmVXIQBAeToG5iRVP6t/kwV4I237TXG6q6jH2tG8 kkvGKSthzd4nDCFUWY5ibfqFvO34ZjgCVWn9PbmEh5sggUANlIlt+gqP1NOfQNJPbvvp HfJg== 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=8wevmODjzZTflimxJfsdYSmjcyp6tyRJZ7XkbMiEpsA=; b=IPlkzfp1Yrt55Z9PoTMALxkk1PpVZ6Ce3yHwi5eteSh4FivrFFlPiEOVnxZIVVguRC vIRvgaVz/Y55onRaIo3xKK1+Jnug1P1q1KdX58MBqEkCjN55VDFbBZabqWr9uLm7lVRW 64jxdMIp1AQfW1MJU/GNtteZj3oafBdk/VpcAqR/3HHaAPP+WjjIa0H5KK4412j+6Wr2 FwAdIRHYLJ5SzyhV2KZOw+Tzy1Z04KODTcQcuPcLWXrUvId2pG34cgb7r9nEI/68fcSM BfO09pv9IDK0CC7akjmkhVEhsAWyTXeYtY+23b9YfDTNKfxBffsgBrZ6YP3XsSOfxVkn dmsA== X-Gm-Message-State: AKS2vOwptu5c01FFFiuUWYq4FcXHX7CWbNHeuqBWbQ1QEx0577iZTTuY 7Kxs+uOlis/Cv9CEiLO9Aw== X-Received: by 10.107.183.133 with SMTP id h127mr1714370iof.29.1497467144564; Wed, 14 Jun 2017 12:05:44 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id h67sm380361itb.19.2017.06.14.12.05.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Jun 2017 12:05:44 -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 05/11] block: add helpers for setting/checking stream validity Date: Wed, 14 Jun 2017 13:05:28 -0600 Message-Id: <1497467134-6323-6-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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We map the RWF_WRITE_* life time flags to the internal flags. Drivers can then, in turn, map those flags to a suitable stream type. Signed-off-by: Jens Axboe --- block/bio.c | 16 ++++++++++++++++ include/linux/bio.h | 1 + include/linux/blk_types.h | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/block/bio.c b/block/bio.c index 888e7801c638..25ea7c365aac 100644 --- a/block/bio.c +++ b/block/bio.c @@ -2082,6 +2082,22 @@ void bio_clone_blkcg_association(struct bio *dst, struct bio *src) #endif /* CONFIG_BLK_CGROUP */ +static const unsigned int rwf_write_to_opf_flag[] = { + 0, REQ_WRITE_SHORT, REQ_WRITE_MEDIUM, REQ_WRITE_LONG, REQ_WRITE_EXTREME +}; + +/* + * 'stream_flags' is one of RWF_WRITE_LIFE_* values + */ +void bio_set_streamid(struct bio *bio, unsigned int rwf_flags) +{ + if (WARN_ON_ONCE(rwf_flags >= ARRAY_SIZE(rwf_write_to_opf_flag))) + return; + + bio->bi_opf |= rwf_write_to_opf_flag[rwf_flags]; +} +EXPORT_SYMBOL_GPL(bio_set_streamid); + static void __init biovec_init_slabs(void) { int i; diff --git a/include/linux/bio.h b/include/linux/bio.h index d1b04b0e99cf..a1b3145020ad 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -443,6 +443,7 @@ extern struct bio *bio_copy_kern(struct request_queue *, void *, unsigned int, gfp_t, int); extern void bio_set_pages_dirty(struct bio *bio); extern void bio_check_pages_dirty(struct bio *bio); +extern void bio_set_streamid(struct bio *bio, unsigned int rwf_flags); void generic_start_io_acct(int rw, unsigned long sectors, struct hd_struct *part); diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 57d1eb530799..06c8c35f0288 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -323,4 +323,9 @@ struct blk_rq_stat { u64 batch; }; +static inline bool blk_stream_valid(unsigned int opf) +{ + return (opf & REQ_WRITE_LIFE_MASK) != 0; +} + #endif /* __LINUX_BLK_TYPES_H */