Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1887171imm; Tue, 22 May 2018 10:55:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoqfJmhZTa3zcVm73HGHs4nK01omN3YL/7hb+fN+H8liTRu9MkBfHowLgr0cUdpV03WrfEi X-Received: by 2002:a17:902:9f98:: with SMTP id g24-v6mr21873164plq.152.1527011738688; Tue, 22 May 2018 10:55:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527011738; cv=none; d=google.com; s=arc-20160816; b=0x+l1RPAd8EKg/8iOuI0NDKHPtBfTumJ2Ca4LFohxRW+Fmf2xVhWxGC2MitDU67mk8 um7iHZHRHoBzjm65YyoCX8E8uH6V9lWBPssGcSLu2jGKHgUhwlBgr2cDKjCLRlrgSKq1 YlWBYuJGlgliYR1CuE61I+rfXHmUz5PfeMOflZZ4lPfcYCcgKWXxm/y+jd15vmWAPvbq oqXP+3RlnbSsria84Kx/17i/vRRvcTWtPDvfRooPY+V/Gc83dg5poGIkChdTY5kdtpec CaYcM6GNJT6WC7YAbQA9zqrqwtGWH7l1gmAZcXh478ozX/2xRiD3+dSBsMz/+UzOVslu NOTA== 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=fVt7RU4oI/AEEFNZsSrJAwLTfaSdxwtgwTwsa3V4GYA=; b=X7D4cBarLDC6fR/L/h4geBuTTBs64YWlY1nJOuSgLLc+pQLJrsEFVn8TJPCjk8q/k1 5UuXODUmmDS9qHKAv6W8hQo/1ScLWtX6lPRPJ9mWSSmeIGk5i1iLfoN7x78VxEbNkv1P DVEvymACPyCSAXBO+va/jtF4bCk5n4vIF1vcK+lZ4ng/O1macr+bwFHI/7VgsjmFOpwS Fg5rqReE3vIlHUPfDZZAOixqQFc0tipkE+W7SkXd16k1MSH8oB6R+fGtfS8LLsjgXNdp CfCA8EBdcxUjMckAYDxToCzkPkqVaQN78xbtSi6AQfNiqZKo0r5uxEc0BNR5YJkY+89J TNRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=rZCOMHCH; 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 c2-v6si1004157pgf.52.2018.05.22.10.55.24; Tue, 22 May 2018 10:55:38 -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=rZCOMHCH; 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 S1752498AbeEVRwi (ORCPT + 99 others); Tue, 22 May 2018 13:52:38 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:36288 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751525AbeEVRwb (ORCPT ); Tue, 22 May 2018 13:52:31 -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=1527012188; x=1558548188; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=7W5ZRe36S6NkQtoynO+ik1vf4vwm11+CjIPSGIzs9Ac=; b=rZCOMHCHF+DL2szRCRATwrW2t016io3dNAY0uUlN85GqV2xsa/pDD8eb weW0qEUzfjgU8foQsPS38T0PGoxNfZGUH+q36yQVf0dHlm3yd4Ubhm+S+ aaYBGxJnaxexuRaJ7HI77ylH8LYXOM56aqLhCx0NUAEF0fFuYz/x64hol hbNEc8YMb/Jy8fnhvFjpnyXyACI9pFqsSXnBhM23bskeJ/9Ss4Cz2NWMu klNSdeF5ZRXMUIL+0vB3kmOj/Bulft4YN4w3iuC5z8R0dRd0r8yjYJF+k HiJAYP8FQYVbsGSdfmxT4LStWQ/BXIn8qdcDfi8mYFxKy0KyNfhTgYAAE g==; X-IronPort-AV: E=Sophos;i="5.49,430,1520870400"; d="scan'208";a="175448563" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 23 May 2018 02:03:07 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 22 May 2018 10:42:55 -0700 Received: from penguito-adamm.sdcorp.global.sandisk.com ([10.11.47.13]) by uls-op-cesaip02.wdc.com with ESMTP; 22 May 2018 10:52:32 -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, tglx@linutronix.de, kstewart@linuxfoundation.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, hch@infradread.org, jmoyer@redhat.com, Adam Manzanares Subject: [PATCH v7 2/5] fs: Convert kiocb rw_hint from enum to u16 Date: Tue, 22 May 2018 10:52:18 -0700 Message-Id: <20180522175221.2391-3-adam.manzanares@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180522175221.2391-1-adam.manzanares@wdc.com> References: <20180522175221.2391-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 --- fs/aio.c | 2 +- include/linux/fs.h | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 755d3f57bcc8..87d8939bb1e4 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1450,7 +1450,7 @@ static int aio_prep_rw(struct kiocb *req, struct iocb *iocb) req->ki_flags = iocb_flags(req->ki_filp); if (iocb->aio_flags & IOCB_FLAG_RESFD) req->ki_flags |= IOCB_EVENTFD; - req->ki_hint = file_write_hint(req->ki_filp); + req->ki_hint = ki_hint_validate(file_write_hint(req->ki_filp)); ret = kiocb_set_rw_flags(req, iocb->aio_rw_flags); if (unlikely(ret)) fput(req->ki_filp); diff --git a/include/linux/fs.h b/include/linux/fs.h index 7f07977bdfd7..9b76ee73af14 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,21 @@ 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)), }; } -- 2.15.1