From patchwork Fri Jun 16 16:14:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9792189 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 02C5860325 for ; Fri, 16 Jun 2017 16:14:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA48C28614 for ; Fri, 16 Jun 2017 16:14:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF24E28652; Fri, 16 Jun 2017 16:14:07 +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 74F1428614 for ; Fri, 16 Jun 2017 16:14:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751923AbdFPQOG (ORCPT ); Fri, 16 Jun 2017 12:14:06 -0400 Received: from mail-io0-f180.google.com ([209.85.223.180]:34751 "EHLO mail-io0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751922AbdFPQOD (ORCPT ); Fri, 16 Jun 2017 12:14:03 -0400 Received: by mail-io0-f180.google.com with SMTP id i7so33195063ioe.1 for ; Fri, 16 Jun 2017 09:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=GKJWoViLHMoJeuFZJ5vypMs85s5grqimtiPe+d1b1qU=; b=LFRxG/YXaIa1x7RhNh2WJy5+rzTRtLb34tFI4JA3ZgA2aV8Ht3yQaVl9v+vX5mhTcS PJli0OWmhHCGdqOEgRRN2xEmNHuL0wz8Z9qAtWUTiMfZgljEBfjHZyeAhicfJB4hD/nL 53yQSuElOJv+k/ClTFbHhY8bZDUVo1OBc0GtlSys+9dpvgMvcG0YPHadOU6J7/pGWINC Ahyah+J/0VxuHKqe3XvwCcvVoDiL2rf5tVqN6d4eIhy3UX/dYSwxHc1hCdKo3CZdWFlM E180V+zbFyLmR1iNvrl8tWeKhIpJB8EFOBnXGohxvXBKENcfpV7zg1aWH33DPdgDEhae D/vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=GKJWoViLHMoJeuFZJ5vypMs85s5grqimtiPe+d1b1qU=; b=bTBXUaF3SrqkX5yyw9zQrRpSFtANj0BuhbVgCbt3xAfCG8H20sVgoiK15PKEl5AksZ pK8WrI2omY40a63Fw2DoHVzFVAtkGkP6JRCq1/jPCsfhCQT0TkQEslFlJJQLA1voxeME sNf1mBu3gTTMyDBibcHNRXOfTBfeAI33CPFL680s+1d+/M/Icqy4f/uUMRFJTqu5lr0p FKsdopgV0F6tnL6qhJccdV1ggUc4eacAjHJsNEBl+jzNu0xYuHVtx08+rY3STkNUpZS9 VgNK/R5p6T9p3I/AYHu+AH1RUkwvK4Euff07AKX9YjdN4uiWB3q9J891T6Zv98ILunvb yqLg== X-Gm-Message-State: AKS2vOxRZSf2wCY3vt6Yv3TGYcdjE08qSixbwo5tFYIj62ygh6wuhj0d QNNb8DOjhK3OqzsB X-Received: by 10.107.144.86 with SMTP id s83mr12832107iod.22.1497629642699; Fri, 16 Jun 2017 09:14:02 -0700 (PDT) Received: from [192.168.1.154] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id e12sm2378827itd.0.2017.06.16.09.14.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jun 2017 09:14:02 -0700 (PDT) Subject: Re: [PATCH 04/11] fs: add support for allowing applications to pass in write life time hints From: Jens Axboe To: Christoph Hellwig Cc: "Darrick J. Wong" , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, adilger@dilger.ca, martin.petersen@oracle.com References: <1497498312-17704-1-git-send-email-axboe@kernel.dk> <1497498312-17704-5-git-send-email-axboe@kernel.dk> <20170615041503.GB4521@birch.djwong.org> <20170615081914.GD10599@infradead.org> <7f8e2e3c-fa15-6864-7afd-b82e5afb87b5@kernel.dk> <20170616073339.GC8682@infradead.org> <0ac0bb7e-ce8d-cb63-985c-ab2d1f3402f1@kernel.dk> <20170616155206.GB27209@infradead.org> Message-ID: <943e8057-bb9a-5c92-16cf-4d5ee6979586@kernel.dk> Date: Fri, 16 Jun 2017 10:14:01 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US 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 On 06/16/2017 09:59 AM, Jens Axboe wrote: > On 06/16/2017 09:52 AM, Christoph Hellwig wrote: >> On Fri, Jun 16, 2017 at 08:35:07AM -0600, Jens Axboe wrote: >>>> Agreed. In fact I'd go a little further: we should have a >>>> >>>> u16 hints; >>>> >>>> that goes all the way down from fcntl to the driver, right now >>>> we'll allocate the first 3 bits for the write lifetime hints (2.5, >>>> so we have one value spare, as they don't need to flags but can be >>>> enum values), leaving more space for other kinds of hints. >>> >>> Did you see v5? It adds enum write_hint and passes it all the way down, >>> until we transform them into rq/bio flags. >> >> Yes. But with all the way down I mean all the way down to the driver :) > > Only missing part is the request flags. And why make that any different > than the flags we already have now? It'd be trivial to pack the value > into the request flags as well, but I'm struggling to see the point of > that, honestly. > > Please expand on why you think changing the request flags to also > carry that value would be useful, as opposed to just mapping it when > we setup the request. If you have a valid concern I don't mind making > the change, but I just don't see one right now. So that would look like the below change on top of the current v5. I skipped the callers, since those are all easy s/bio_op_write_hint/write_hint_to_opf changes. diff --git a/block/bio.c b/block/bio.c index 758d83d91bb0..888e7801c638 100644 --- a/block/bio.c +++ b/block/bio.c @@ -2082,22 +2082,6 @@ 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 e9360dc5ea07..d1b04b0e99cf 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -443,7 +443,6 @@ 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 23646eb433e7..f4d348cd3a6b 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,10 +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_SHORT, /* short life time write */ - __REQ_WRITE_MEDIUM, /* medium life time write */ - __REQ_WRITE_LONG, /* long life time write */ - __REQ_WRITE_EXTREME, /* extremely long life time write */ + __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 */ @@ -225,13 +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 (1ULL << __REQ_WRITE_SHORT) -#define REQ_WRITE_MEDIUM (1ULL << __REQ_WRITE_MEDIUM) -#define REQ_WRITE_LONG (1ULL << __REQ_WRITE_LONG) -#define REQ_WRITE_EXTREME (1ULL << __REQ_WRITE_EXTREME) +#define REQ_WRITE_SHORT (WRITE_HINT_SHORT << __REQ_WRITE_HINT_SHIFT) +#define REQ_WRITE_MEDIUM (WRITE_HINT_MEDIUM << __REQ_WRITE_HINT_SHIFT) +#define REQ_WRITE_LONG (WRITE_HINT_LONG << __REQ_WRITE_HINT_SHIFT) +#define REQ_WRITE_EXTREME (WRITE_HINT_EXTREME << __REQ_WRITE_HINT_SHIFT) -#define REQ_WRITE_LIFE_MASK (REQ_WRITE_SHORT | REQ_WRITE_MEDIUM | \ - REQ_WRITE_LONG | REQ_WRITE_EXTREME) +#define REQ_WRITE_LIFE_MASK (0x7 << __REQ_WRITE_HINT_SHIFT) #define REQ_NOUNMAP (1ULL << __REQ_NOUNMAP) @@ -328,4 +327,9 @@ static inline bool op_write_hint_valid(unsigned int opf) return (opf & REQ_WRITE_LIFE_MASK) != 0; } +static inline unsigned int write_hint_to_opf(enum write_hint hint) +{ + return hint << __REQ_WRITE_HINT_SHIFT; +} + #endif /* __LINUX_BLK_TYPES_H */