Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4314653pxj; Wed, 12 May 2021 02:54:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIH44m051NZMPc0B0mIc6Ni9OW3PUD92EMNPxgsgNKzG6RH7OYs2c2RvsWu2l/NB19NeqO X-Received: by 2002:a05:6638:3814:: with SMTP id i20mr28752267jav.85.1620813286730; Wed, 12 May 2021 02:54:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620813286; cv=none; d=google.com; s=arc-20160816; b=E6GIC1enN11Iq35rDozF0HFAXM1EPuCFMYPqM6Q+uilZY6OicaNlyCFUnjYv8mBBgs Rjc1QDUmU9PMnq6S63AW+FHxr30Td4WSiAFNOV1aqktFOcLtbZmJDQU1UPqu2ngyAe44 45KD6RaafdZiOX8wtTMmtHxobUkyWbhZyUXN8zDPB4a8vEIOLxPcyIGR244odsp3i1IK Wc6lARSPS8tcv9z4vvgRMozRugrY+udLG6BpMCayK+EbKA4PcqfsZ0LnGfJ8wYT3xCZu S4NYNCH4OvM+rpJLLRPXit+H3l2clsV8zMLqc5d5/FYwYG/iVrWWyq0OWJ0SPtv3zJ93 lAHA== 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=xSNHWFHaDPvKcOBXzDZgmP5NxxBOq0ecReOdawmsSjc=; b=QBHptHDhaEg9/heuht+U4vB9BD7QLpAffNiUtZKuPuEZgHqY97Jq66Y8PgXbsuZXYZ cMc1dhMaQR0PiDDn9E5aOB1qkSDCpo5olN/JI/Ajk8Jz9OF+GrT1RcgwFgVFcIlzbja/ 6ljbWjgQSMahqxGNJWa9S614HTg8xvEVjMumFqu7qAmcQUzXLW4+TJh2vOUj1iYH3jCn //42H/Org5lGy2FxqatyCvLgzSG7hu6zW45BNxgrFwPIZowLJybt4cAzRDpN69JVNb/e Zf64zW6UYP89EzBjMgOlsCK3lmVzmOyUNRHVKRfd/nlbSO36R3erlZHPCqlC35Z7fJ+W 9omQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 b23si24971917jav.29.2021.05.12.02.54.34; Wed, 12 May 2021 02:54:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S230268AbhELJyb (ORCPT + 99 others); Wed, 12 May 2021 05:54:31 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3733 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230166AbhELJyX (ORCPT ); Wed, 12 May 2021 05:54:23 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Fg94Y191RzqTV6; Wed, 12 May 2021 17:49:49 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.498.0; Wed, 12 May 2021 17:53:04 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH 2/3] f2fs: compress: clean up parameter of __f2fs_cluster_blocks() Date: Wed, 12 May 2021 17:52:57 +0800 Message-ID: <20210512095258.96918-2-yuchao0@huawei.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210512095258.96918-1-yuchao0@huawei.com> References: <20210512095258.96918-1-yuchao0@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Previously, in order to reuse __f2fs_cluster_blocks(), f2fs_is_compressed_cluster() assigned a compress_ctx type variable, which is used to pass few parameters (cc.inode, cc.cluster_size, cc.cluster_idx), it's wasteful to allocate such large space in stack. Let's clean up parameters of __f2fs_cluster_blocks() to avoid that. Signed-off-by: Chao Yu --- fs/f2fs/compress.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index 8bb9e57a6db8..b6bd6862eef2 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -898,14 +898,17 @@ static bool cluster_has_invalid_data(struct compress_ctx *cc) return false; } -static int __f2fs_cluster_blocks(struct compress_ctx *cc, bool compr) +static int __f2fs_cluster_blocks(struct inode *inode, + unsigned int cluster_idx, bool compr) { struct dnode_of_data dn; + unsigned int cluster_size = F2FS_I(inode)->i_cluster_size; + unsigned int start_idx = cluster_idx << + F2FS_I(inode)->i_log_cluster_size; int ret; - set_new_dnode(&dn, cc->inode, NULL, NULL, 0); - ret = f2fs_get_dnode_of_data(&dn, start_idx_of_cluster(cc), - LOOKUP_NODE); + set_new_dnode(&dn, inode, NULL, NULL, 0); + ret = f2fs_get_dnode_of_data(&dn, start_idx, LOOKUP_NODE); if (ret) { if (ret == -ENOENT) ret = 0; @@ -916,7 +919,7 @@ static int __f2fs_cluster_blocks(struct compress_ctx *cc, bool compr) int i; ret = 1; - for (i = 1; i < cc->cluster_size; i++) { + for (i = 1; i < cluster_size; i++) { block_t blkaddr; blkaddr = data_blkaddr(dn.inode, @@ -938,25 +941,15 @@ static int __f2fs_cluster_blocks(struct compress_ctx *cc, bool compr) /* return # of compressed blocks in compressed cluster */ static int f2fs_compressed_blocks(struct compress_ctx *cc) { - return __f2fs_cluster_blocks(cc, true); + return __f2fs_cluster_blocks(cc->inode, cc->cluster_idx, true); } /* return # of valid blocks in compressed cluster */ -static int f2fs_cluster_blocks(struct compress_ctx *cc) -{ - return __f2fs_cluster_blocks(cc, false); -} - int f2fs_is_compressed_cluster(struct inode *inode, pgoff_t index) { - struct compress_ctx cc = { - .inode = inode, - .log_cluster_size = F2FS_I(inode)->i_log_cluster_size, - .cluster_size = F2FS_I(inode)->i_cluster_size, - .cluster_idx = index >> F2FS_I(inode)->i_log_cluster_size, - }; - - return f2fs_cluster_blocks(&cc); + return __f2fs_cluster_blocks(inode, + index >> F2FS_I(inode)->i_log_cluster_size, + false); } static bool cluster_may_compress(struct compress_ctx *cc) @@ -1007,7 +1000,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc, bool prealloc; retry: - ret = f2fs_cluster_blocks(cc); + ret = f2fs_is_compressed_cluster(cc->inode, start_idx); if (ret <= 0) return ret; -- 2.29.2