Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1738528imm; Tue, 22 May 2018 08:34:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqR0WQIVGCfV10Ix2JxhOpeAwsiwZUodOUGrT2xYCZ91+LiBF2Z/YX6ARP3iaogBJaSpoYl X-Received: by 2002:a65:64d9:: with SMTP id t25-v6mr10873372pgv.148.1527003247482; Tue, 22 May 2018 08:34:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527003247; cv=none; d=google.com; s=arc-20160816; b=kobi0r/eXPtDnp5MxHxxgba+Sk4I0iJ1wtkl3VF1gGbLyeOM1XKgBWa9VWKFsvRhGS s/oRZt3M8NAWIDJ18B/D1BGmR7BuxJVJwv986Rj3D2ud+Fe/tcn6TGfuHJhoBl60LaM0 VL/lEE+56a+7T8pV+ZE2GpnZsEEmgmzERDJkstk+RgQHiOXFP3jJrMf7RH39j/AcnwrC x0kdjgxV280jk0uENno1jy67B5/2sYU6W8ncjEGMJ3+MT7urmpdrj+DsFtEIfeb+id8J enl7a5B6qSpLPmEHkqRp3HDOtUoIE46NzxErPt0NT+ulYZBMMWCjl+oR6hJMjONjQxSv 2lQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=H0IQjpuDyldvsQ3yARE/165kjMhL66C2vJ5KzCBMi3k=; b=MUkvsqTryVtuqsjmZeVsVI2Dhn8tiuxQ+0X4q2rSv6l+EtHvEEPrhtI+VK/HGKHqf2 YAFPAjrmCQEs+k/qDi7AVL/JwoNBM6tvvmMaGMNN+d9K1R3Q6XdUz8cUdtPpqx1wJxH+ 2HrGEWIMxbGVgCKs+PPxwVMYKSEmr0P6/piLpJXB32uCyWNa9plIA1HXSeyu1bB/ba4s /mMsfzVZifUKLSIXKusyyJqK2mQwYfsOCYV4glBmUTuoapoQdw56UMyZ0vSpijE3JrVh JbhN16gYKxQU1+jpxJzZwqgCnpdjCqCg29oWG2x3g+/gp5T445Wr2Joa/fQnDLjRs0fn OQsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=Xail6v6H; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t13-v6si17613651pfc.333.2018.05.22.08.33.52; Tue, 22 May 2018 08:34:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=Xail6v6H; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751445AbeEVPce (ORCPT + 99 others); Tue, 22 May 2018 11:32:34 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:32854 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751317AbeEVPca (ORCPT ); Tue, 22 May 2018 11:32:30 -0400 Received: by mail-io0-f196.google.com with SMTP id e78-v6so18971122iod.0 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=kv+XZLZ0zh92m3kAM6h+0ecHtZ33Sd4ZHm6uoI5A+wiwv19vR8EWF/e8NMvYfLK66L LMNqLF7vxflRw4cs4/f8Tnzd9+fS7n/Sqv32Rc3fO5/rLm2IJD7ToxOaJrHVcg4YqVmA A0AfgqsoNkqDxhYcNLqlRpDGhtmPoML7JC8Z/YAJD32S/r1wcp33MG2bcb5M2chrcPK/ ZAnZIArPXWf2wwXpLgMJSu6fzweCKgn3WDF7aZjs893W2/6yhuuoeldAFvyFKOV/Bxuu T3OnOfoBvPBkDeVlY4YZUTdbDXSLXuPGjBbl+YCMJRdE3ZhhldTY7+oB9t1iKMzBTqii 2OZg== X-Gm-Message-State: ALKqPwchUTLNZibIaMqJL2eznjP6RLk6becW6l5eeO3ShzTCMZYuKXrD xgVxoirf9SKO9m92c1iw/6Al8A== 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-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)), }; } -- Jens Axboe