From patchwork Thu Dec 15 08:18:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ChenXiaoSong X-Patchwork-Id: 33536 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp196210wrn; Wed, 14 Dec 2022 23:26:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf6MdUXm6d3XXraC226dE8VtW5fMuNgZkbZ6sbUmlrYD+JUIi4UZ5qE1gOJp09IdvEJ+d9P8 X-Received: by 2002:a17:906:b14b:b0:78d:f459:719e with SMTP id bt11-20020a170906b14b00b0078df459719emr8970392ejb.73.1671089203027; Wed, 14 Dec 2022 23:26:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671089203; cv=none; d=google.com; s=arc-20160816; b=Wuxgr8tQrwyf5aes/KDCDUMXg/bOO40GjuDObfl0FmmXY3XZT0yZ0jI9LoNMrolWno x5ilY+4PqXRbskJgeRrhJaqiTOcWuuzMVFMtLJZyT+jB5Un6QHHYLMa/mKy4MZHj242P XXOK7bqAMuWtAcIVItEW21MalfTrfxRTiueVj8fcGnAu0RWtFZDwIUZzyhKcLhtdN/cE DrkmZaAABLXew92iRsnvdCmHaHuFFaaupwkZelM9/YCarX7oKRHUqMKivmQZ2VmnjfM5 ICX02iq/Zfpt2Rjlz2FdcUBBEPjRVEp9wvwdx/LnbFzkD8R1P0JcNh/Ln58GLXlugjQ6 ZNmg== 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=bvNRxhfdK1TBxOwDt5ixQiqAKmSL1k5lFLpg5h0ZvWk=; b=D0VvDSHWKhQNNxuQK5TxZaY5h4SUY/l3xlcW/3IaUaksks52n7cbMk6sorZaz68IKK +qks12XRhlJNk9Ow9P2K0yqR6mdxYh4600KCpujdxXjpEQhr5pxdZfN/HoDiqbCtdmF0 9EwwZFN1LAkrePZETO0CLO6EbdnjB3JCfaNPSnhcStG8mZmoH5cl5rxzIBs3jKaQ4u9l W5ocVxfI3KVwQ7tyvUQu3XzuLHXSLswo+kFKUc6xaeqgowuNMDyL40kSw/OJqvgUWA7e i4nPgaoMWrZnKgFu9jl3WFQ76iqLBmw6QPKEvvhL2HR6Y7uzqy1Ymj+pfQrxkeeZ6zQS IJ0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n17-20020a170906089100b007bded759a0bsi10422950eje.892.2022.12.14.23.26.20; Wed, 14 Dec 2022 23:26:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230096AbiLOHPV (ORCPT + 99 others); Thu, 15 Dec 2022 02:15:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229600AbiLOHOo (ORCPT ); Thu, 15 Dec 2022 02:14:44 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 969033134E; Wed, 14 Dec 2022 23:14:37 -0800 (PST) Received: from kwepemm600015.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NXjzq0bNbzgZ2b; Thu, 15 Dec 2022 15:10:15 +0800 (CST) Received: from huawei.com (10.175.101.6) by kwepemm600015.china.huawei.com (7.193.23.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 15 Dec 2022 15:14:32 +0800 From: ChenXiaoSong To: , , , , , , , , , , , CC: , Subject: [PATCH v2 1/2] hfsplus: introduce hfsplus_init_inode() helper Date: Thu, 15 Dec 2022 16:18:19 +0800 Message-ID: <20221215081820.948990-2-chenxiaosong2@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221215081820.948990-1-chenxiaosong2@huawei.com> References: <20221215081820.948990-1-chenxiaosong2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600015.china.huawei.com (7.193.23.52) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752264032179438235?= X-GMAIL-MSGID: =?utf-8?q?1752264032179438235?= Factor out hfsplus_init_inode(), No functional change. Signed-off-by: ChenXiaoSong --- fs/hfsplus/hfsplus_fs.h | 1 + fs/hfsplus/inode.c | 35 ++++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h index 6aa919e59483..2aa719e00ae5 100644 --- a/fs/hfsplus/hfsplus_fs.h +++ b/fs/hfsplus/hfsplus_fs.h @@ -472,6 +472,7 @@ extern const struct dentry_operations hfsplus_dentry_operations; int hfsplus_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, struct page **pagep, void **fsdata); +void hfsplus_init_inode(struct hfsplus_inode_info *hip); struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir, umode_t mode); void hfsplus_delete_inode(struct inode *inode); diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c index 840577a0c1e7..d921b32d292e 100644 --- a/fs/hfsplus/inode.c +++ b/fs/hfsplus/inode.c @@ -379,22 +379,8 @@ static const struct file_operations hfsplus_file_operations = { .unlocked_ioctl = hfsplus_ioctl, }; -struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir, - umode_t mode) +void hfsplus_init_inode(struct hfsplus_inode_info *hip) { - struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); - struct inode *inode = new_inode(sb); - struct hfsplus_inode_info *hip; - - if (!inode) - return NULL; - - inode->i_ino = sbi->next_cnid++; - inode_init_owner(&init_user_ns, inode, dir, mode); - set_nlink(inode, 1); - inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); - - hip = HFSPLUS_I(inode); INIT_LIST_HEAD(&hip->open_dir_list); spin_lock_init(&hip->open_dir_lock); mutex_init(&hip->extents_lock); @@ -412,6 +398,25 @@ struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir, hip->phys_size = 0; hip->fs_blocks = 0; hip->rsrc_inode = NULL; +} + +struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir, + umode_t mode) +{ + struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); + struct inode *inode = new_inode(sb); + struct hfsplus_inode_info *hip; + + if (!inode) + return NULL; + + inode->i_ino = sbi->next_cnid++; + inode_init_owner(&init_user_ns, inode, dir, mode); + set_nlink(inode, 1); + inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); + + hip = HFSPLUS_I(inode); + hfsplus_init_inode(hip); if (S_ISDIR(inode->i_mode)) { inode->i_size = 2; sbi->folder_count++;