From patchwork Wed Dec 12 09:50:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Rajendra X-Patchwork-Id: 10725887 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 25BDD112E for ; Wed, 12 Dec 2018 09:51:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 167E52AEC3 for ; Wed, 12 Dec 2018 09:51:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 079BC2AEDE; Wed, 12 Dec 2018 09:51:31 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham 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 804812AEC3 for ; Wed, 12 Dec 2018 09:51:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726964AbeLLJv3 (ORCPT ); Wed, 12 Dec 2018 04:51:29 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:43234 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726962AbeLLJv3 (ORCPT ); Wed, 12 Dec 2018 04:51:29 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wBC9nUHG048522 for ; Wed, 12 Dec 2018 04:51:28 -0500 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0b-001b2d01.pphosted.com with ESMTP id 2payvp0m0j-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 Dec 2018 04:51:28 -0500 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Dec 2018 09:51:27 -0000 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 12 Dec 2018 09:51:21 -0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wBC9pI8b26673242 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Dec 2018 09:51:18 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7CAED6A04D; Wed, 12 Dec 2018 09:51:18 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C847E6A051; Wed, 12 Dec 2018 09:51:09 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.69.92]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 12 Dec 2018 09:51:09 +0000 (GMT) From: Chandan Rajendra To: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-doc@vger.kernel.org, linux-mips@linux-mips.org, linux-s390@vger.kernel.org, linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org Cc: Chandan Rajendra , tytso@mit.edu, adilger.kernel@dilger.ca, ebiggers@kernel.org, jaegeuk@kernel.org, yuchao0@huawei.com, corbet@lwn.net, ralf@linux-mips.org, paul.burton@mips.com, jhogan@kernel.org, green.hu@gmail.com, deanbo422@gmail.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, richard@nod.at, dedekind1@gmail.com, adrian.hunter@intel.com, viro@zeniv.linux.org.uk Subject: [PATCH V5 5/9] ext4: use IS_VERITY() to check inode's fsverity status Date: Wed, 12 Dec 2018 15:20:14 +0530 X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181212095018.12648-1-chandan@linux.vnet.ibm.com> References: <20181212095018.12648-1-chandan@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18121209-0020-0000-0000-00000E988D1F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010214; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000270; SDB=6.01130624; UDB=6.00587518; IPR=6.00910758; MB=3.00024664; MTD=3.00000008; XFM=3.00000015; UTC=2018-12-12 09:51:26 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18121209-0021-0000-0000-000064060A7B Message-Id: <20181212095018.12648-6-chandan@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-12-12_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812120087 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This commit removes the ext4 specific ext4_verity_inode() and makes use of the generic IS_ENCRYPTED() macro or ext4_test_inode_flag() to check for the encryption status of an inode. Reviewed-by: Eric Biggers Signed-off-by: Chandan Rajendra --- fs/ext4/ext4.h | 9 --------- fs/ext4/file.c | 2 +- fs/ext4/inode.c | 10 ++++++---- fs/ext4/readpage.c | 2 +- fs/ext4/super.c | 1 + 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index db21df885186..64bf9fb7ef18 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2296,15 +2296,6 @@ extern unsigned ext4_free_clusters_after_init(struct super_block *sb, struct ext4_group_desc *gdp); ext4_fsblk_t ext4_inode_to_goal_block(struct inode *); -static inline bool ext4_verity_inode(struct inode *inode) -{ -#ifdef CONFIG_EXT4_FS_VERITY - return ext4_test_inode_flag(inode, EXT4_INODE_VERITY); -#else - return false; -#endif -} - #ifdef CONFIG_FS_ENCRYPTION static inline int ext4_fname_setup_filename(struct inode *dir, const struct qstr *iname, diff --git a/fs/ext4/file.c b/fs/ext4/file.c index cb4b69ef01a2..30fbd663354f 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -444,7 +444,7 @@ static int ext4_file_open(struct inode * inode, struct file * filp) if (ret) return ret; - if (ext4_verity_inode(inode)) { + if (IS_VERITY(inode)) { ret = fsverity_file_open(inode, filp); if (ret) return ret; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 8a55255a6c32..703f55635824 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3883,7 +3883,7 @@ static ssize_t ext4_direct_IO(struct kiocb *iocb, struct iov_iter *iter) return 0; #endif - if (ext4_verity_inode(inode)) + if (IS_VERITY(inode)) return 0; /* @@ -4724,7 +4724,7 @@ static bool ext4_should_use_dax(struct inode *inode) return false; if (ext4_test_inode_flag(inode, EXT4_INODE_ENCRYPT)) return false; - if (ext4_verity_inode(inode)) + if (ext4_test_inode_flag(inode, EXT4_INODE_VERITY)) return false; return true; } @@ -4748,9 +4748,11 @@ void ext4_set_inode_flags(struct inode *inode) new_fl |= S_DAX; if (flags & EXT4_ENCRYPT_FL) new_fl |= S_ENCRYPTED; + if (flags & EXT4_VERITY_FL) + new_fl |= S_VERITY; inode_set_flags(inode, new_fl, S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_DAX| - S_ENCRYPTED); + S_ENCRYPTED|S_VERITY); } static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode, @@ -5508,7 +5510,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) if (error) return error; - if (ext4_verity_inode(inode)) { + if (IS_VERITY(inode)) { error = fsverity_prepare_setattr(dentry, attr); if (error) return error; diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c index 7252f0a60cdb..2c037df629dd 100644 --- a/fs/ext4/readpage.c +++ b/fs/ext4/readpage.c @@ -206,7 +206,7 @@ static void mpage_end_io(struct bio *bio) static inline loff_t ext4_readpage_limit(struct inode *inode) { #ifdef CONFIG_EXT4_FS_VERITY - if (ext4_verity_inode(inode)) { + if (IS_VERITY(inode)) { if (inode->i_verity_info) /* limit to end of metadata region */ return fsverity_full_i_size(inode); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 16fb483a6f4a..35ed3c48f8d2 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1344,6 +1344,7 @@ static int ext4_set_verity(struct inode *inode, loff_t data_i_size) err = ext4_reserve_inode_write(handle, inode, &iloc); if (err == 0) { ext4_set_inode_flag(inode, EXT4_INODE_VERITY); + ext4_set_inode_flags(inode); EXT4_I(inode)->i_disksize = data_i_size; err = ext4_mark_iloc_dirty(handle, inode, &iloc); }