From patchwork Thu May 17 20:38:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Manzanares X-Patchwork-Id: 10407713 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 12E9D60247 for ; Thu, 17 May 2018 20:38:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 044152873F for ; Thu, 17 May 2018 20:38:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC8FD2873E; Thu, 17 May 2018 20:38:55 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 95E482873F for ; Thu, 17 May 2018 20:38:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752054AbeEQUi3 (ORCPT ); Thu, 17 May 2018 16:38:29 -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-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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)), }; }