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: 9787273 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 2ED2660325 for ; Wed, 14 Jun 2017 19:05:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21F5223D5E for ; Wed, 14 Jun 2017 19:05:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16CF727853; Wed, 14 Jun 2017 19:05:57 +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 C45CE23D5E for ; Wed, 14 Jun 2017 19:05:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752075AbdFNTFu (ORCPT ); Wed, 14 Jun 2017 15:05:50 -0400 Received: from mail-io0-f170.google.com ([209.85.223.170]:32998 "EHLO mail-io0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751907AbdFNTFp (ORCPT ); Wed, 14 Jun 2017 15:05:45 -0400 Received: by mail-io0-f170.google.com with SMTP id t87so6316300ioe.0 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=GPjFIPzECY4b5Ss56Bgm0a6o6cbNEwfvuiJGAFIZpn7J47pSwEXZ4akSOXu7BMVe1/ RAt0d1nPF0UmOfjz0fwmrnCF1IV01gO2kk0UCQOFLAQ+Dg3Ag9OdiUTsWKjcUb96tEpc HeT7R5GdKc8aIVI0PqI57xPC0ea9GRZQLWf2gzmHLRFreZDmGSaEjjWYRKjObu2oiCl2 cVvY25YHcnXzmYRZE+ySjYAujnXHC0A4m7eFvESQvFfxLqFL83osYfQnJiaG7nACBCuK yXK4XMZmz1EE234TnWgYhq6NC6qts8OaVq3ZJ13cfoI5wseE7KTFC7CuYByPJBRELF38 zVBg== X-Gm-Message-State: AKS2vOzS2XJvQOwrpdTBrW9VSM/splWTRh17wAeGh0AxOUupd1uxICFg I85YHIh8O2hkRJQC 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-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@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 */