From patchwork Tue May 22 15:32:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10418983 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 371836032A for ; Tue, 22 May 2018 15:33:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18D3828E2D for ; Tue, 22 May 2018 15:33:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F24AB28E3B; Tue, 22 May 2018 15:33:52 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, 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 773FE28E7A for ; Tue, 22 May 2018 15:32:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751236AbeEVPcc (ORCPT ); Tue, 22 May 2018 11:32:32 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:38745 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751304AbeEVPca (ORCPT ); Tue, 22 May 2018 11:32:30 -0400 Received: by mail-io0-f195.google.com with SMTP id z4-v6so18983602iof.5 for ; Tue, 22 May 2018 08:32:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=H0IQjpuDyldvsQ3yARE/165kjMhL66C2vJ5KzCBMi3k=; b=Xail6v6HeKNeDMEjW2bRxIarGJlYBW3LW0/dMgsjHCNKvNOQyu5Dsp6mj7onIhwLBg nlshmPbt6a2hCzlGIWpORNe/rWceui3+aPMYhZCZ6LsK8TVnJG8dJJ4YlLktZDDOgCWy kQZXlyhLPyV7Q/PETTytN6HxW+Csf6mpMKk1jncldRA7vGp7zFdGXGC00AyUSLqL/7WQ CZv1qoodlDgj1M+BAnQoi46sIzEH+xYyfMPFlUVCIvM3K/sClOi7X9+62JdDRtA7FUlN KNoCxkex68xvA9bPxng9NP5zOjEPyvYPoPvk8jpqp/HQY85rqLe3LJoa/6OGJPp63jhj k6Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=H0IQjpuDyldvsQ3yARE/165kjMhL66C2vJ5KzCBMi3k=; b=rXD+Kf7JagbU+ivJciwkUgzFQlajmpTCRgEZimVDiPikgZFy0GXGtppxWgZNtogWj2 2OY7FW0j8giGp7Q6c3853hwdICb14TY00yZ8jsFpTKmVqQJ8f3M3j55bFrF/jA4nhWJJ lDG0WKxAUZuJLjPyXkJvU/GY0zoxN4uEGxiN2EBUXolRRCwV0ZJmJtKe+kWR0jMHXNzj NenQXBa8Hlto6jsYZbCLBOiVBM6sTNXq3/aV6Pn7Xpqmk5xC7vSjGgC6j3x38db96QhK flKXto6vHoBads1QkfRW+Elm8eKiwUaM5NZXdvfPcNBZjyF2AFYs69Gck3s78+/MPvn6 lt0Q== X-Gm-Message-State: ALKqPwerH2sqsGEAIaGITtLHZBatPvLNtArnlZNeis6G7mCkyLQxxVXH MJoFh6bMbnqYygIcTyMxyZio0A== X-Google-Smtp-Source: AB8JxZoRc4lssU9Ca8zZRuMfbh3bVOrm8gOw63J+k6gge5qUtR0CyabIWw49obeH3peyDq5ZUtqUdA== X-Received: by 2002:a6b:2b10:: with SMTP id r16-v6mr25420133ior.204.1527003149527; Tue, 22 May 2018 08:32:29 -0700 (PDT) Received: from [192.168.1.167] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id x137-v6sm93245ite.5.2018.05.22.08.32.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 08:32:28 -0700 (PDT) Subject: Re: [PATCH v6 2/5] fs: Convert kiocb rw_hint from enum to u16 To: adam.manzanares@wdc.com, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, bcrl@kvack.org Cc: tglx@linutronix.de, mingo@kernel.org, pombredanne@nexb.com, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, bigeasy@linutronix.de, jack@suse.cz, darrick.wong@oracle.com, rgoldwyn@suse.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org, linux-api@vger.kernel.org, hch@infradread.org, jmoyer@redhat.com References: <20180522150737.9893-1-adam.manzanares@wdc.com> <20180522150737.9893-3-adam.manzanares@wdc.com> From: Jens Axboe Message-ID: <11fb2ee5-8352-2d35-3154-68637d99b096@kernel.dk> Date: Tue, 22 May 2018 09:32:26 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20180522150737.9893-3-adam.manzanares@wdc.com> 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 5/22/18 9:07 AM, adam.manzanares@wdc.com wrote: > From: Adam Manzanares > > In order to avoid kiocb bloat for per command iopriority support, rw_hint > is converted from enum to a u16. Added a guard around ki_hint assignment. > > Signed-off-by: Adam Manzanares > Reviewed-by: Christoph Hellwig > --- > include/linux/fs.h | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 7f07977bdfd7..50de40dbbb85 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -284,6 +284,8 @@ enum rw_hint { > WRITE_LIFE_EXTREME = RWH_WRITE_LIFE_EXTREME, > }; > > +#define MAX_KI_HINT ((1 << 16) - 1) /* ki_hint type is u16 */ Instead of having to do this and now rely on those now being synced, how about something like the below. diff --git a/include/linux/fs.h b/include/linux/fs.h index 760d8da1b6c7..070438d0b62d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -299,7 +299,7 @@ struct kiocb { void (*ki_complete)(struct kiocb *iocb, long ret, long ret2); void *private; int ki_flags; - enum rw_hint ki_hint; + u16 ki_hint; } __randomize_layout; static inline bool is_sync_kiocb(struct kiocb *kiocb) @@ -1927,12 +1927,22 @@ static inline enum rw_hint file_write_hint(struct file *file) static inline int iocb_flags(struct file *file); +static inline u16 ki_hint_validate(enum rw_hint hint) +{ + typeof(((struct kiocb *)0)->ki_hint) max_hint = -1; + + if (hint <= max_hint) + return hint; + + return 0; +} + static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp) { *kiocb = (struct kiocb) { .ki_filp = filp, .ki_flags = iocb_flags(filp), - .ki_hint = file_write_hint(filp), + .ki_hint = ki_hint_validate(file_write_hint(filp)), }; }