Received: by 10.192.165.148 with SMTP id m20csp4584503imm; Tue, 8 May 2018 10:43:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpHoQBo0qZ95yM18IUiWtSt7qqwT7SGB2c66wmPKYZoR9kS3tJHmgauQMrBMVa/WTzFZtBf X-Received: by 2002:a17:902:b942:: with SMTP id h2-v6mr43542321pls.312.1525801391892; Tue, 08 May 2018 10:43:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525801391; cv=none; d=google.com; s=arc-20160816; b=EXMxNB+gLmdE2hh/O9cnZ9/FR0cDPBeNXviacBlxoM4N7lRK6N557EvuSN/DwZ8A5i /haaLbAQQQ571Fr+tnyrN4xpnXZVc80hI7+WPAGXVOqqaaskatEtlRyHxaB6hIFzvYMS r7fyZdEbTAabUAho987FLiqM6EdL/8c1KZEup/0oYr86/l6Plv3HsYd4ZccQBNtqBQ62 gCduXZeEPMe5zFePQDRY7BfnoMDls1mnljOgbwtKJ+AkPKokPBb8kEVyR5kTR020iC72 ubATjVjbouMy5C3zVONTdx3AFleLcfSwzwJroVAl6jEgSrcx+aBgLSJ1nwhISef7SwM2 g5Cw== 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=hm8JT10WVlqmqjQCRW1dCMF/Elvi4e58B7oHihJX6kI=; b=xS8twGHZo/RaYOnshFr2cLRVy5YOplXzZB4XeGdIdgTQGSWAH3K4gt4I4L1XhOfldH wvJRStkujmi+KdnE6ew4ZABxE+YRgVD0SiTacV3PhtAaFauCZskXCaQ9YKMuCtiltbuH TnmBbHUqvdWo60gReqhir9w2lZEHs6nA8mzo4uOZydTSd0+oin3kpfVr25kuELVk3PDJ 05iMPgVp1k/3yUWp3IUJ1Ip7joy0ovvENMy9vruj0pBswZ0xpFSyFX9M87zqIAJ4oqZI G4gFygURqEmC13XsSwyHP8N4aZgf0JIEW3SrvuAgmM1HK1j4GcQ3j7d4N8Q2ygODQxmx PrhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=NtzTE9hU; 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 c41-v6si24942013plj.503.2018.05.08.10.42.56; Tue, 08 May 2018 10:43:11 -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=NtzTE9hU; 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 S1755488AbeEHRmk (ORCPT + 99 others); Tue, 8 May 2018 13:42:40 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:39537 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754370AbeEHRmg (ORCPT ); Tue, 8 May 2018 13:42:36 -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=1525801356; x=1557337356; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=i82MndxTm0efG1CPwBlX1LKDvjnBR09ii9ulhiFveRc=; b=NtzTE9hUQRvcEnDU2Jldvvn1Cu7UqCfRbPc1SfayF1ye0PX//lqVo5GM QGRPCCgU43eBQsdkIiU1zP9WRZzrUAkO62qgNsVUUcXQZVCbmD0Qs9kqv HaczT7mYfq4K7aZVcvLo+ZrGH9vL7wHOXk1M42nvfOZX7D0NHf6ZPobRA TvC+Zoon4VN8/OoLHpibk7380qDbM6vES+JZ7A0MR1SxSxvAjTGsXOTx/ A/H5u82zmIgw0T4V7hxalRNoLKnNjRT16UNJhLq5BFHfz0v+ypb17j0yd PgbkB0FrFZMN5q6C+8sro7ypvsGCNFHhQcxvtjVzMUnB+lqRazm0kuTgD g==; X-IronPort-AV: E=Sophos;i="5.49,379,1520870400"; d="scan'208";a="180732632" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 09 May 2018 01:42:35 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 08 May 2018 10:34:15 -0700 Received: from penguito-adamm.sdcorp.global.sandisk.com ([10.11.47.13]) by uls-op-cesaip02.wdc.com with ESMTP; 08 May 2018 10:42:35 -0700 From: adam.manzanares@wdc.com To: viro@zeniv.linux.org.uk, bcrl@kvack.org Cc: linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, linux-api@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Adam Manzanares Subject: [PATCH v3 2/3] fs: Convert kiocb rw_hint from enum to u16 Date: Tue, 8 May 2018 10:42:01 -0700 Message-Id: <20180508174202.2537-3-adam.manzanares@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180508174202.2537-1-adam.manzanares@wdc.com> References: <20180508174202.2537-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 assigment. Signed-off-by: Adam Manzanares --- include/linux/fs.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 760d8da1b6c7..7a90ce387e00 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,21 @@ static inline enum rw_hint file_write_hint(struct file *file) static inline int iocb_flags(struct file *file); +/* ki_hint changed from enum to u16, make sure rw_hint fits into u16 */ +static inline u16 ki_hint_valid(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_valid(file_write_hint(filp)), }; } -- 2.15.1