Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3724905imm; Thu, 17 May 2018 13:38:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoScx0/XgvxXdClDecSbfKJaCIS3HKX5qig3BP8MvfealrmWR9E/ObmmvP9QqlnbQIBjLtY X-Received: by 2002:a62:3085:: with SMTP id w127-v6mr6522942pfw.224.1526589538860; Thu, 17 May 2018 13:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526589538; cv=none; d=google.com; s=arc-20160816; b=Xm16ZEpIuozrr2rIFB15wrYT4O3pLHN7H7FOoDAm7DSPVihcLM78OI3ORVXzUo/v8A f1R1hY1NEr81CRhiQpOLfpj1UPFrjMzx/hkwwQhB4Cz+tS4Tvxvo+DQUWhg71EE3YnJ8 fWq/pIA6tIJ7HaYDrrAC60oi3158ZB8KbZub6l8Ag+Xwnx8EdeY+xRsCbaoayo7kkHhQ WRsIDwnSeXd786zrTO4e7WuQOmzEwM+3fl/ICQr9Dn4/+b8NAgH43Ogx4z3jr8boQcGj Pyzs3K2ijqBVVr78b2DFhbEsw86r4v1Bqo7VRRz2E21ivoZJeohXNawY1or6sVv1g91K UBVQ== 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=KqY773fHWAeryR7nbtMFz5XuhflTLoZE9mIikv0fZJlz1vXq3qekdJdHvoegBtlDTR ovFNTuGtHw6E/2PQAslr25LeGrLRtt2d0pDoEtogHftSuGnKTybbZrM9fv2qZY2kF1rj s4I/zOsHihKpfwPWobDZ+flyTUFT2pioQHQj1K1W3EI4jO0SgZSai+M/f3XNeu8LtypG FqUFHsCxUyGc6FU81a/oluZ3e0/CMEc8DGBVpu0Mldxqp+bXcoZS1w2Ky84Y5Vojyd0f TdNCfUF43UI/mzYlckejJsm5u8ujHQpzv3vm+GX/cSHHdaojvlfTn/k4Rre1OWGF/V1J F6Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=nVWpbAhc; 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 v17-v6si4709968pgb.380.2018.05.17.13.38.43; Thu, 17 May 2018 13:38:58 -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=nVWpbAhc; 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 S1752189AbeEQUic (ORCPT + 99 others); Thu, 17 May 2018 16:38:32 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:60847 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751671AbeEQUi0 (ORCPT ); Thu, 17 May 2018 16:38:26 -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=1526589507; x=1558125507; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=i82MndxTm0efG1CPwBlX1LKDvjnBR09ii9ulhiFveRc=; b=nVWpbAhcq9eBk1F+ykxy1C6BzrmCjA7EJVZGn5EqTPFH30AgHcZBWAjM Ca7l0J5Nmbdk0MDEebgrjgsM6aeR/uS+r4C4E2hJ214QIUSK+bL3IjR3K ScOFmblmSfQ1ndX+epHeMU9sCZCc7x/QQ/YDBHdiMdoGEqOu6Gljny65u cxJZV17LiRCC0ZatHfEgJODAvoZrCbMaYhCofTfBqTdHJlNA8fVO+RxCt U3l7Z5xfOrm05Ck3xlr7J3bfCkuvpUAM8uZe/mQWxQ+BTYXUUoR52aPTM vWeSTroc+jefzReFN8yLKeHOqpCWzII5eEuHVdtuDARqCunHIpziqQcWi w==; X-IronPort-AV: E=Sophos;i="5.49,412,1520870400"; d="scan'208";a="78199745" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 18 May 2018 04:38:26 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 17 May 2018 13:29:28 -0700 Received: from penguito-adamm.sdcorp.global.sandisk.com ([10.11.47.13]) by uls-op-cesaip02.wdc.com with ESMTP; 17 May 2018 13:38:25 -0700 From: adam.manzanares@wdc.com To: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, axboe@kernel.dk, bcrl@kvack.org Cc: mingo@kernel.org, peterz@infradead.org, pombredanne@nexb.com, gregkh@linuxfoundation.org, bigeasy@linutronix.de, rgoldwyn@suse.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org, linux-api@vger.kernel.org, Adam Manzanares Subject: [PATCH v4 2/3] fs: Convert kiocb rw_hint from enum to u16 Date: Thu, 17 May 2018 13:38:02 -0700 Message-Id: <20180517203803.2664-3-adam.manzanares@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180517203803.2664-1-adam.manzanares@wdc.com> References: <20180517203803.2664-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