From patchwork Thu Nov 30 09:23:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 171785 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp253255vqy; Thu, 30 Nov 2023 01:14:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuYmDW5O7cXNpFXwH974I7RRXWIIfGenh6LWuDpKhv5lYyfjfYnKCORiEbRiHH01tMpZ9z X-Received: by 2002:a05:6808:f94:b0:3ae:144f:f99b with SMTP id o20-20020a0568080f9400b003ae144ff99bmr25071112oiw.4.1701335640815; Thu, 30 Nov 2023 01:14:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701335640; cv=pass; d=google.com; s=arc-20160816; b=v25lUy9y5PnHBI1dWbfLoNOtsuBHkcgxDV5dfcP0RV7Ba/ZZ4UBXZNQlF1FiKHP1ky zW+InwF/UO+I9g/tbqaEglJaFDFqUT9vT2/1LE5x6Z/vLjf4S2nDAGTwzyr2UOCOP8Gn OISziO4ByA7wNrc+qUmtzlQOYlEQYVKvihZfBEhMp8RGuOT/PuiqiMf4Gk0L7RNkdrSN BijDUXXoSdy6i8TjrK8kQfJUcYs2fTwHCsfTryOxcxIJPwEHUobP1gmfcWTN+Yxx8jXf PTNW6HM86oo9mAvJNUufZOoOkvvEj+D0emY2SyxMN4sqQoh0SEtK6EDrwiqfE7IuIfYn /wAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=nBUMAl0H2V0yUdg27JTNo8RJJEBgbGxnRMuchy2OGi0=; fh=VNAMAEaYEFQ0TTFYWcnMZkT4/7JxlyRr09/ygjVrGqI=; b=d88m6IrZjkZbt31dXEqI0fBtmNTTxTRlE9aAkN0VwvdETkMpCeaJy4GKK4mZ8aK14A yHJ1RJWL1i3nAZtT1Hy9CKteTTW+yzAVHA1zPeyEMQpD0WEEvT/ov0j0dQlE+v4oD8OX wfeuqkbYSBttAk/tLQquUK2qrkYz607TJNvEx/Xa8y9RAqwAyxWqUn0nVMnwfQ6AeuwQ R+74I6I9YjLoDdRsEYoVVGG5wfa0mHpIekFK2o+ne3n+A2Dz6CDQHoWae9v/8zWgd/JU IPEcwDIqzpbexMtsDfXHD7/2b6fX0haOF5c1w7UNxKFPOIU8mZtpsmnjN7EUG6BQ25w0 tyvQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b="H/PKb5/q"; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id c7-20020a656747000000b005c603f06562si992551pgu.333.2023.11.30.01.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 01:14:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b="H/PKb5/q"; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 1D902802F954; Thu, 30 Nov 2023 01:13:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235043AbjK3JNr (ORCPT + 99 others); Thu, 30 Nov 2023 04:13:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235063AbjK3JNi (ORCPT ); Thu, 30 Nov 2023 04:13:38 -0500 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2097.outbound.protection.outlook.com [40.107.255.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C646170F for ; Thu, 30 Nov 2023 01:13:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mCS44CyhesNKcR2TwOdQBphoy7YuOXrmdilUfqeWrkpxGXiGKEQ1xEyMyQWHPHm78LSCBM/Go0RVRHV8WB+XKIXvMYT1pYUkx0aWxaziUuAUdWnyXTSjRl4fo5gxTyEscVF+K8pieVHNJR031ZvC3Cfi6Tm1wvBI6cDA8LLrdUudNljyHRldP/RaJJkF1oY/Sfmc8NXpDlDxQB6QT16yWsXbwfoienXi++oy+K9aY02HuKBFD6i9LRcyHOoqfrXZYibGU0LEN3uq7riwdq3aW3dDWdj8yBE1/As+6RQDGo5GO/nv5bXvN7Pb+2BKkpcdPp3ufF3HlQdyy/irSmUynA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nBUMAl0H2V0yUdg27JTNo8RJJEBgbGxnRMuchy2OGi0=; b=dxDBlNxbMnV/tLv9gSD3oGPcVWQtYyncsbRIhdtqvZ+iObOcXM+j4dUCUIGW2SWijQDMbWSd1zvm4SK/ZZowsMziu5h/+XDs0a95m2X2B5v+aqd3oG8Voln9402YrLHLk51qIfF7bON44NXa0/7nHzWdp9mJcCot7KB0UqFE9vEkk8x6Fryg16zFbKaxAfiKSSej2hSaq8+0LPd6UGq6lJL5md7xsqLMf8j17f44k3npDcuaTMLcq2T5cZYOYJKauh5Nj/y48CxCkQWUX6FGcfYLf1PlvyC+D9P4evVD65rJSYgPYUQypB6zMH/Uk3/iOyZzXVkrgfZPV5H5KhSGBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nBUMAl0H2V0yUdg27JTNo8RJJEBgbGxnRMuchy2OGi0=; b=H/PKb5/qKQ13V77R8YYMd3T8UTB56YNicLMkStYTIw59VOt1Sl0JaNCzwPU6V33m7Kdwmzcs7xsWZt0pGXA7OXCAi52Ed44TdIUHmqM3b+ZyR+KpyNuGa2VJoxm8Po3/X4Lt7EYQ0mjwKRyw7efo7E1YOSYfc2WT4wCLz11jfrn6l8flW+nrUuiEbBWCHQCL+4tYTnGry4x3jrUD2L0CpDDz206bYX9xdxqxRh56/zBEqvw4cnFmORDtUuPunWy82qpAaickMUPw0eLsz7+Ssa+WSCDbcSVXPgkOQOoMmU+2c3b/oeiAlQuO4VbRS1+rPQCokXv4jUNSXqJsehjXNQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by KL1PR0601MB4068.apcprd06.prod.outlook.com (2603:1096:820:2a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.27; Thu, 30 Nov 2023 09:13:37 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::8064:576b:554f:5246]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::8064:576b:554f:5246%3]) with mapi id 15.20.7046.015; Thu, 30 Nov 2023 09:13:37 +0000 From: Yangtao Li To: Jaegeuk Kim , Chao Yu Cc: Yangtao Li , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] f2fs: compress: do cleanup in f2fs_truncate_partial_cluster() Date: Thu, 30 Nov 2023 02:23:10 -0700 Message-Id: <20231130092310.1297336-1-frank.li@vivo.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: SI2PR02CA0033.apcprd02.prod.outlook.com (2603:1096:4:195::20) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|KL1PR0601MB4068:EE_ X-MS-Office365-Filtering-Correlation-Id: 154a4494-7a47-485f-42ba-08dbf184a2d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UxRUnMgUyPbV0KhAar9fDRMJDO04bruMkFIJTj+TaQwBjSy7PgDmAaLU/nvTw1Ih/BpVZtP/pl1moabwvbd8RzBA3fVqIUyC8N+DFWJQbHjd3rB//eL45F55Ktq0eZ8B7T84O//T4Eu5jpjiFd2S1Qo+GUkfCxwPANYbAMrXdFUcUSwUHU6BWm9pLm8j5c5Tzks/vI42fT1npBSwgAJK1ZU3CGa61QF/NgIFEXk54sJeJ/PsY+lXMCqZaPa52OcRinaernzcRuaNh+Vj9J/sknU4zoXCeIe015OD0Cj+b/KQM+mTYJo1SbVEosBtmdmmSEBTUaSJbXOCRIW3C/FPL3t7BxPSKVtA8aU6VdsoueQmA9QwWyNEpGskXCHT7Ry2qusEvDI5tURkzri+PJWad3vjrH8alpcYng6puKaXZbJ2YRgEj1iTSL6WiQPW0b3zAjxSFuJsfldIcRvnJyT9k9+tqfiibPx9C2T/6eZMjkZiG5KsfwW32au4YzoJMjWHcZsDuT1Y94KzezyVI+e+nOgJmrfy+HZ7WJeV2LDJ09CT8pNR9eu/2Z7H5uMc1wkSiaFoMgKwPdW7X9cn/egEmDEysCC5lxazSIp6qI/+bD1X1ri5A7TGLq/ejoBTM+kf1bxuy88AhbqZE/Kv2ERwp1FC8SNCSQ4DogL/sBm5ZV4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR06MB5269.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(39860400002)(396003)(346002)(136003)(376002)(230922051799003)(186009)(64100799003)(451199024)(1800799012)(1076003)(26005)(2616005)(202311291699003)(5660300002)(52116002)(6506007)(4326008)(6666004)(8936002)(86362001)(6512007)(6486002)(66556008)(316002)(66476007)(66946007)(110136005)(8676002)(83380400001)(478600001)(38100700002)(41300700001)(36756003)(38350700005)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TceAfFYlhZ8UhuzYaeMFf4CHk5eA0oelA0hV7kGRYb+0E6hdhbOPG+p9YK68APn4Q8YKGVhErxy2TqJN08PyXRy7b6eEeWCittjvF12NXnpI3ZrquWGyulV9645pL4M5U65Wk4Hl+h2kJ7iFSMvAXyMAyLZ0VVf9UXAxnVE25owmp7ibvnjV3FQkcVRVgHbb/1h/pT5Q38SZDE1Ydp8tuelurFAkfE5mkKqyKAOg9FOz0sl5gVcAQwHMX+tmdG95d8JEWfxv4d8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N598FkCAJIdU8LCQn64NLqLOhZPCgLC0QC3seo3RAbWO4TDFl7Y1ZQwaNLo/SlxoMPuO8hzJpRiapPu2r0pt33eMqHzoktt3FekbuysjzG0uPkpyq4ewF7yVendU9lht9WmpiFz3n7z9EDT6NsxDKv2+VnH7yvTk68c/9PPLpSs2Ysej02B+/Y6+w5Bhiw5VZ5cPJFWU/pq4l/cFSJGJNpeEzVb7OMnev024XqNHBk+oK2B X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 154a4494-7a47-485f-42ba-08dbf184a2d8 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2023 09:13:37.4295 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gIdQ0hj4mFTT2c17r1/jthdmZXAaEsZHgoRgqjHpSd465wJLdwCAOrApak3MTuJNGrCNqatsKfo64YKOJrYrDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR0601MB4068 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 30 Nov 2023 01:13:57 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783979721098791994 X-GMAIL-MSGID: 1783979721098791994 Remove unnecessary code logic. Signed-off-by: Yangtao Li --- fs/f2fs/compress.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index 36e5dab6baae..de55c266509a 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -1170,7 +1170,9 @@ int f2fs_truncate_partial_cluster(struct inode *inode, u64 from, bool lock) int log_cluster_size = F2FS_I(inode)->i_log_cluster_size; pgoff_t start_idx = from >> (PAGE_SHIFT + log_cluster_size) << log_cluster_size; - int err; + struct page **rpages = fsdata; + int cluster_size = F2FS_I(inode)->i_cluster_size; + int err, i; err = f2fs_is_compressed_cluster(inode, start_idx); if (err < 0) @@ -1190,25 +1192,19 @@ int f2fs_truncate_partial_cluster(struct inode *inode, u64 from, bool lock) if (err <= 0) return err; - if (err > 0) { - struct page **rpages = fsdata; - int cluster_size = F2FS_I(inode)->i_cluster_size; - int i; - - for (i = cluster_size - 1; i >= 0; i--) { - loff_t start = rpages[i]->index << PAGE_SHIFT; + for (i = cluster_size - 1; i >= 0; i--) { + loff_t start = rpages[i]->index << PAGE_SHIFT; - if (from <= start) { - zero_user_segment(rpages[i], 0, PAGE_SIZE); - } else { - zero_user_segment(rpages[i], from - start, - PAGE_SIZE); - break; - } + if (from <= start) { + zero_user_segment(rpages[i], 0, PAGE_SIZE); + } else { + zero_user_segment(rpages[i], from - start, + PAGE_SIZE); + break; } - - f2fs_compress_write_end(inode, fsdata, start_idx, true); } + + f2fs_compress_write_end(inode, fsdata, start_idx, true); return 0; }