Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1707869imm; Tue, 22 May 2018 08:09:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq9esMYQKjEXAw1pO6vw0Kr/VIMyv4gwS2YnyHwVr3dipiow8HDgKPiyEOkMCaQCMDlpZ+b X-Received: by 2002:a63:ba0b:: with SMTP id k11-v6mr2337337pgf.178.1527001742190; Tue, 22 May 2018 08:09:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527001742; cv=none; d=google.com; s=arc-20160816; b=cZjxuIb2myKcA+zRWOSiKItzF9/Cu1UYTUxBlDko5W0P2B1RhFepXkL8+CPV4xyVGU kOp/NgnbMdiCqkyUr31nzUZox2uN72yXdcpAJmORQsr1EVz4sM8lsSwidM2P9vEBMksy krzjQdhaJQR7yoZBFcixTZlpuz+Zip4U9voM9PNZFt+DuUDSUOkBxrjaGimAs7SD10MM RQELgPK5pDMOUC+TbLXzc5wOpQ5kweMaZsIqbeVeOU8zdTfOftJd3g6DC4f4AcMGongl nVjMN4uQuY8GkpHDi8vte89Y03CnGEDjsC4AJdMP8BiLfHhcEDONKGbOoccNeGeZVo+X bx6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=/slQY2z3EC7WcnAmc3S/ngYis5az+/ct16JJlbp/7K8=; b=JGjbO1Gl0jhj1uk76zI53/OaFSLmEimAsqMiz7FnYF9jpkcFwD51hh2vm5WVudWXSz OWiaqCUN5nrlVM7fZt4Mhi6g+JrvbMoo94bvQyUkRhiFCgj83BKO1Q13MPU4Miv5pQDk kkRc7E+rJsyRNaHvKyyPFVVpPzhDp8kpv2EFI3SJNvHJ7lwJLavQBe/AzTumXq8DEZ9e 1EOGXCh1xQzCdToCM4lU+rTIVvq/2ZayxPTpRWy70XeEf5LLmnptpAEGicUm1PZxaSzI TCviUuLRzCYwF2lIK3uW0dfoj0fDToqAnvimzMm++eQLm1Oh3FMlV0gnQhIvnGcRtt2R VEAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=UxZ4/yGF; 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 w6-v6si4183767pgb.11.2018.05.22.08.08.35; Tue, 22 May 2018 08:09:02 -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=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=UxZ4/yGF; 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 S1752517AbeEVPIF (ORCPT + 99 others); Tue, 22 May 2018 11:08:05 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:23233 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752121AbeEVPH4 (ORCPT ); Tue, 22 May 2018 11:07:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1527001676; x=1558537676; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=QkbbaTtF/4GjhDorHS6YlH0NKECbrSYVX5YmwbTCIPc=; b=UxZ4/yGFRp/wD0xXHp2/g5PJ3ueq4aDqzaR0G1IJV7xzE2sPtZ4bOfiL 7nVSpzdSgRD0mhWDSGXkNfVxhB/AZB8FnLHTvrud1WT+7L39ObihMJW3W Kp33ZjKmCaDg/wEQWcQJNzqfpqTTfK+wBNGvxDGP96IKcQTfE/wd8XYe4 zvkhwtsUcwbZPaK/6DTbK6bix0LYPGTfXfCSaYSxuwnyzvDFcpadTuPhL bLGEFkRcuibc+ArqNwcsxZlldKfchAnGcaiJvaAdmJABHfqATeSrQqJp4 SBBoTmCoQmw05sLbFBT/JPTlE4AQ8XgDrKTQ4w9Z0ZTdedYDL0T3p0aiY w==; X-IronPort-AV: E=Sophos;i="5.49,430,1520870400"; d="scan'208";a="79548766" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 May 2018 23:07:54 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 22 May 2018 07:58:49 -0700 Received: from penguito-adamm.sdcorp.global.sandisk.com ([10.11.47.13]) by uls-op-cesaip02.wdc.com with ESMTP; 22 May 2018 08:07:54 -0700 From: adam.manzanares@wdc.com To: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, axboe@kernel.dk, 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, Adam Manzanares Subject: [PATCH v6 2/5] fs: Convert kiocb rw_hint from enum to u16 Date: Tue, 22 May 2018 08:07:34 -0700 Message-Id: <20180522150737.9893-3-adam.manzanares@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180522150737.9893-1-adam.manzanares@wdc.com> References: <20180522150737.9893-1-adam.manzanares@wdc.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 */ + #define IOCB_EVENTFD (1 << 0) #define IOCB_APPEND (1 << 1) #define IOCB_DIRECT (1 << 2) @@ -299,7 +301,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 +1929,19 @@ 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) +{ + if (hint > MAX_KI_HINT) + return 0; + return hint; +} + 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)), }; } -- 2.15.1