From patchwork Thu Jun 15 16:42:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9789307 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 86BBB60384 for ; Thu, 15 Jun 2017 16:42:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7992327F7F for ; Thu, 15 Jun 2017 16:42:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E9002852E; Thu, 15 Jun 2017 16:42:48 +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 28FB127F7F for ; Thu, 15 Jun 2017 16:42:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751901AbdFOQmp (ORCPT ); Thu, 15 Jun 2017 12:42:45 -0400 Received: from mail-io0-f176.google.com ([209.85.223.176]:34046 "EHLO mail-io0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751757AbdFOQmW (ORCPT ); Thu, 15 Jun 2017 12:42:22 -0400 Received: by mail-io0-f176.google.com with SMTP id i7so15438541ioe.1 for ; Thu, 15 Jun 2017 09:42:22 -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=I1CfxJ6Y5ML5PkH/qrpZxnxXEMyNcXUDy4/G/bfMwjk=; b=DQJmI/Ttf7ydanOjY0kOSKgV5T+Os6boPcJV5Z1edaJ0ztrw3tKBXlunDmgNjKLeNn xmsFhBuAaiqwbhWVDnKOOkJQRum5bun8GkTch53/VL/JZHFyjxylKImlUBIxr9+bawkC vFdHIShNZkZDqy3Uolv/rkqhQR3xmVar3sND6Vj6e6yw6EXexur8rrWPO3BICd0EXxnr xyYdZg0xLTgqjVNInzkrTrzYchWibKXy36FDzQy2nD3J6LQN/IFVf8oq7/9zTeqwiMZn XhBL9lVB2JeDk+hPC92f9k40l8SGn/mf2b6qQhV+98sMt/TAyPKx7/SrDJlKiCGmIAaC A3CQ== 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=I1CfxJ6Y5ML5PkH/qrpZxnxXEMyNcXUDy4/G/bfMwjk=; b=bUAkBW8FIUxVILvwBMm50RnhRR07OcN1dDa2qRKFMYGAufFRpISxQe5D6jiI1SPXlG kxVQiwirUdRBCMVHbifuNP+4dDzCn6kdKB+7OWMuNWbolFw9Rz7H8hiSubot53Xk5xs5 C8RVPv9y91UqGjPJuHg1VKOm4I3rU7NpMB+vcLJXt4ZDAVpVkCBpTLClO19Tsv0u+0tk PUoWadYs7OXER8M75S+OLWo1jxRCHl9SLLNiGHei3gC2+ID/Ik+mSto1XHf+hZN528SK 60ecNNHz+7/Q44Kg+i16c3+LLLukuUmC1bxaRhfuCgULdEp2uJaKrsY+Gbv2RSlsPsZE kucw== X-Gm-Message-State: AKS2vOy9ByvM3UlT0lnxKwLTyaPICK/qc9V/vjnWmER3zIY5leYTt79Z QYF1ARpHomgWgEbtugAmtg== X-Received: by 10.107.11.160 with SMTP id 32mr6474817iol.222.1497544941891; Thu, 15 Jun 2017 09:42:21 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id 97sm313476iot.25.2017.06.15.09.42.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Jun 2017 09:42:21 -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 06/12] block: add helpers for setting/checking write hint validity Date: Thu, 15 Jun 2017 10:42:04 -0600 Message-Id: <1497544930-19174-7-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497544930-19174-1-git-send-email-axboe@kernel.dk> References: <1497544930-19174-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 WRITE_HINT_* life time hints 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..758d83d91bb0 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 +}; + +/* + * Convert WRITE_LIFE_* hints into req/bio flags + */ +unsigned int bio_op_write_hint(enum write_hint hint) +{ + if (WARN_ON_ONCE(hint >= ARRAY_SIZE(rwf_write_to_opf_flag))) + return 0; + + return rwf_write_to_opf_flag[hint]; +} +EXPORT_SYMBOL_GPL(bio_op_write_hint); + static void __init biovec_init_slabs(void) { int i; diff --git a/include/linux/bio.h b/include/linux/bio.h index d1b04b0e99cf..e9360dc5ea07 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 unsigned int bio_op_write_hint(enum write_hint hint); 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..23646eb433e7 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 op_write_hint_valid(unsigned int opf) +{ + return (opf & REQ_WRITE_LIFE_MASK) != 0; +} + #endif /* __LINUX_BLK_TYPES_H */