Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp397762pxb; Thu, 26 Aug 2021 05:54:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnerHwnELRTuXBMPBCXOqPP/6+9EYLlgt5iV9t+/9nPBaNiOXX4wIKYIsRkc4QqpCmhwKk X-Received: by 2002:a5d:935a:: with SMTP id i26mr2901558ioo.79.1629982486279; Thu, 26 Aug 2021 05:54:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629982486; cv=none; d=google.com; s=arc-20160816; b=qOOotmo5YKpZzM/pHECA3IGy8Oufg/X++A99DKl6Yf0UZ8sqXMSyq41aS8Swh2+sxA m8YAGXFP170V43U1DR85bM5QXF6QPSWsmbxcSWhqp4cYdKtSwpbsdtTg+a6BSGeDq6oG 4/4KPb4U9nFAOejcWXXgDoh2QTiqm55CmFXzCOLeJFHqfS+F+qTo9pMy+RPH11iactIB +pNrA+dYMX5QzMpqkwKZ8+weGr03mhqYPv60vctXKCAO1yaqeftQiTiJARF+dXN5pgrj VTmRKQqgLZwigBZBNIhLbU/hkU8JIpRG9YEdnwGM3gWLL1lyJbTKD/oqojI54uP1srS8 hHrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=7Eb4u1JsNNvDi/AJg8zt90ql2eKpeHCd7ibBECubY2Q=; b=Ylil/IQ4Twcq3nJh4wB1pYJWmvkLoCtZdntscWQFkmbJtBRqtlBi3s+j1GKW8uXWzH XvxE0QrwXS5pmnXfshfyO0E+kzUtZBMhjT2c2/zT62LzrdPVR1uPPQ/Xt/30gsEg6Bhr jL9U/jGJ1OZi2sRZorRRwGUoljTfutAiVaLf7SzlIJafJXzLfl7rk7kxJYM4O1PAK9GZ PYdhcinabR6sIzWtck6e5adakaZYCQP/5WmDc+NEU+m+rgL0TSLWVlulPsFmv368PhJa ppM5rziI40886jUH+liZ1uy2saruo2vmVJaGZ50dGuhL7sF+8wfoHcL2ZTMwK+L0Eoaa gxaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k1si2734682ilo.14.2021.08.26.05.54.32; Thu, 26 Aug 2021 05:54:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242587AbhHZMy5 (ORCPT + 99 others); Thu, 26 Aug 2021 08:54:57 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:18043 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242577AbhHZMys (ORCPT ); Thu, 26 Aug 2021 08:54:48 -0400 Received: from dggeme752-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GwN3j4nWgzbj1J; Thu, 26 Aug 2021 20:50:09 +0800 (CST) Received: from huawei.com (10.175.127.227) by dggeme752-chm.china.huawei.com (10.3.19.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Thu, 26 Aug 2021 20:53:59 +0800 From: Zhang Yi To: CC: , , , , Subject: [PATCH v4 4/6] ext4: factor out ext4_fill_raw_inode() Date: Thu, 26 Aug 2021 21:04:10 +0800 Message-ID: <20210826130412.3921207-5-yi.zhang@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210826130412.3921207-1-yi.zhang@huawei.com> References: <20210826130412.3921207-1-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggeme752-chm.china.huawei.com (10.3.19.98) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Factor out ext4_fill_raw_inode() from ext4_do_update_inode(), which is use to fill the in-mem inode contents into the inode table buffer, in preparation for initializing the exclusive inode buffer without reading the block in __ext4_get_inode_loc(). Signed-off-by: Zhang Yi --- fs/ext4/inode.c | 85 +++++++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 38 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 8323d3e8f393..c7186460c14d 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4902,9 +4902,8 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino, return ERR_PTR(ret); } -static int ext4_inode_blocks_set(handle_t *handle, - struct ext4_inode *raw_inode, - struct ext4_inode_info *ei) +static int ext4_inode_blocks_set(struct ext4_inode *raw_inode, + struct ext4_inode_info *ei) { struct inode *inode = &(ei->vfs_inode); u64 i_blocks = READ_ONCE(inode->i_blocks); @@ -5007,37 +5006,16 @@ static void ext4_update_other_inodes_time(struct super_block *sb, rcu_read_unlock(); } -/* - * Post the struct inode info into an on-disk inode location in the - * buffer-cache. This gobbles the caller's reference to the - * buffer_head in the inode location struct. - * - * The caller must have write access to iloc->bh. - */ -static int ext4_do_update_inode(handle_t *handle, - struct inode *inode, - struct ext4_iloc *iloc) +static int ext4_fill_raw_inode(struct inode *inode, struct ext4_inode *raw_inode) { - struct ext4_inode *raw_inode = ext4_raw_inode(iloc); struct ext4_inode_info *ei = EXT4_I(inode); - struct buffer_head *bh = iloc->bh; - struct super_block *sb = inode->i_sb; - int err = 0, block; - int need_datasync = 0, set_large_file = 0; uid_t i_uid; gid_t i_gid; projid_t i_projid; + int block; + int err; - spin_lock(&ei->i_raw_lock); - - /* - * For fields not tracked in the in-memory inode, initialise them - * to zero for new inodes. - */ - if (ext4_test_inode_state(inode, EXT4_STATE_NEW)) - memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size); - - err = ext4_inode_blocks_set(handle, raw_inode, ei); + err = ext4_inode_blocks_set(raw_inode, ei); raw_inode->i_mode = cpu_to_le16(inode->i_mode); i_uid = i_uid_read(inode); @@ -5079,16 +5057,8 @@ static int ext4_do_update_inode(handle_t *handle, raw_inode->i_file_acl_high = cpu_to_le16(ei->i_file_acl >> 32); raw_inode->i_file_acl_lo = cpu_to_le32(ei->i_file_acl); - if (READ_ONCE(ei->i_disksize) != ext4_isize(inode->i_sb, raw_inode)) { - ext4_isize_set(raw_inode, ei->i_disksize); - need_datasync = 1; - } - if (ei->i_disksize > 0x7fffffffULL) { - if (!ext4_has_feature_large_file(sb) || - EXT4_SB(sb)->s_es->s_rev_level == - cpu_to_le32(EXT4_GOOD_OLD_REV)) - set_large_file = 1; - } + ext4_isize_set(raw_inode, ei->i_disksize); + raw_inode->i_generation = cpu_to_le32(inode->i_generation); if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { if (old_valid_dev(inode->i_rdev)) { @@ -5128,6 +5098,45 @@ static int ext4_do_update_inode(handle_t *handle, raw_inode->i_projid = cpu_to_le32(i_projid); ext4_inode_csum_set(inode, raw_inode, ei); + return err; +} + +/* + * Post the struct inode info into an on-disk inode location in the + * buffer-cache. This gobbles the caller's reference to the + * buffer_head in the inode location struct. + * + * The caller must have write access to iloc->bh. + */ +static int ext4_do_update_inode(handle_t *handle, + struct inode *inode, + struct ext4_iloc *iloc) +{ + struct ext4_inode *raw_inode = ext4_raw_inode(iloc); + struct ext4_inode_info *ei = EXT4_I(inode); + struct buffer_head *bh = iloc->bh; + struct super_block *sb = inode->i_sb; + int err; + int need_datasync = 0, set_large_file = 0; + + spin_lock(&ei->i_raw_lock); + + /* + * For fields not tracked in the in-memory inode, initialise them + * to zero for new inodes. + */ + if (ext4_test_inode_state(inode, EXT4_STATE_NEW)) + memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size); + + if (READ_ONCE(ei->i_disksize) != ext4_isize(inode->i_sb, raw_inode)) + need_datasync = 1; + if (ei->i_disksize > 0x7fffffffULL) { + if (!ext4_has_feature_large_file(sb) || + EXT4_SB(sb)->s_es->s_rev_level == cpu_to_le32(EXT4_GOOD_OLD_REV)) + set_large_file = 1; + } + + err = ext4_fill_raw_inode(inode, raw_inode); spin_unlock(&ei->i_raw_lock); if (err) { EXT4_ERROR_INODE(inode, "corrupted inode contents"); -- 2.31.1