From patchwork Thu Jun 15 03:45:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9788009 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 27C8960231 for ; Thu, 15 Jun 2017 03:45:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C4D923F88 for ; Thu, 15 Jun 2017 03:45:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 115B927C2D; Thu, 15 Jun 2017 03:45:34 +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 B97B423F88 for ; Thu, 15 Jun 2017 03:45:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752077AbdFODpb (ORCPT ); Wed, 14 Jun 2017 23:45:31 -0400 Received: from mail-pf0-f179.google.com ([209.85.192.179]:35039 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752064AbdFODpa (ORCPT ); Wed, 14 Jun 2017 23:45:30 -0400 Received: by mail-pf0-f179.google.com with SMTP id l89so1806060pfi.2 for ; Wed, 14 Jun 2017 20:45:29 -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=E1VUXX2C8iOJ/ZEgWC71j8MDhytm53elqYNjj4+aWZQ=; b=u3mo5am9ubr3RODUC3T/CdgnGQiFASWGFfNnCMZJKK7ZTf9YFflNR4D/GfpmAXcdX5 PulhqAXRyJslfUaf+7/5fSCqfqCQ1qgxLa7JWwkulTCRGX/vqwCbiF/lBR49/D/lf4qS 8AXxNGlhj5gmeLJJsqTfr5UCtjw4GFIXHpPaQC9f1RTFhWWqF9qjshDCdklU4QdM6KdI y4aK+yaHoYFgtpRIEy0AHywH2UyN+lPu/WQxkYUxppnK/l7BUSthzyvSIav1KZObBf0l +7qvkv57v8Fr+mM0R0FtZbVqxakMhJe4P0sSzwZ+4IRXoAhKzE416pBOihHVqYuEnQcP AHPg== 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=E1VUXX2C8iOJ/ZEgWC71j8MDhytm53elqYNjj4+aWZQ=; b=glskUS+MUb7ioUizvp6yKVg668JSG2wT1cmzdo4B4mgyABenRspxeUzZE5mRM3Mqee 31M32ZuRY+py7vNvUKclsl8oECmbVQOUFlu+fUSeDETasORUNV4H+x+pRWOXVx1FPssc Fn8Fxd79rTztaiyi8JWuqoBPuU4F2CfsG6CGz9zvzDa7lpKXjvBpzG1jGQZ2bkOdt+m/ rPL1qHv6pQ38ifeY/yewSgBzJ/UO9bavpReNlV2UkwyV5GQyMdmGKkkw3qL++FYbHu6X 3mkP4xBzffcjVm5H3No5opJ26sPJnHhm9wJvN1YxW8UwGPanZ33k9VMh1GGilE6rlKVi Ek2Q== X-Gm-Message-State: AKS2vOyBTptKbHgutxaC/xd3BamAXfUOWVZ22U0hU0IZa1cSZfARE+fA EUTPwEN6MpidUToF7lZ+Iw== X-Received: by 10.84.201.74 with SMTP id t10mr3768900plh.44.1497498329189; Wed, 14 Jun 2017 20:45:29 -0700 (PDT) Received: from localhost.localdomain (66.29.164.166.static.utbb.net. [66.29.164.166]) by smtp.gmail.com with ESMTPSA id f71sm2532627pfd.98.2017.06.14.20.45.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Jun 2017 20:45:28 -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 write hint validity Date: Wed, 14 Jun 2017 21:45:06 -0600 Message-Id: <1497498312-17704-6-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497498312-17704-1-git-send-email-axboe@kernel.dk> References: <1497498312-17704-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..8804439945b2 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 + */ +unsigned int bio_op_write_hint(unsigned int rwf_flags) +{ + if (WARN_ON_ONCE(rwf_flags >= ARRAY_SIZE(rwf_write_to_opf_flag))) + return 0; + + return rwf_write_to_opf_flag[rwf_flags]; +} +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..debd60d641dd 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(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..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 */