Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3537131rwb; Fri, 16 Dec 2022 17:02:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXv8fpgOpVEG4744ZQ3kOg2X1ODAKOcz8c9MjVq2NT3R8m15Gx8vElUhMkFD+AyNGSOF83cj X-Received: by 2002:a05:6a20:d69a:b0:af:fcb6:2ee2 with SMTP id it26-20020a056a20d69a00b000affcb62ee2mr308741pzb.47.1671238926492; Fri, 16 Dec 2022 17:02:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671238926; cv=none; d=google.com; s=arc-20160816; b=d/amPrFV5rczpuHjeQNpwW7gIzPhAbr2p3OdNBZNNMwizt3H5hKX0R+j1buw2BwMAG 709V5oR+hC7CYm+5bgV42AR11c7gRJI55VhoahP4k2RxtNZu4eYwgAY4qF3LhqjCm2S9 itALbQykRZM11Su9GQ8PAReUFoEldYuD7a9vD6U2JAVmafW+Ydw6LP5ekrC0YrGPKW1g 7ziS6exUlWOIQa4yzzeWZWrd9gqLaMqCC9Gp/jaoABCp/XcZVGAWvyst5L/BoL8F2Tsj 9/h0cIIBZLbYtyt2MR3g5503UNXlb1Eh3l0WT6/3m6/v/uv7DGOq8VYi2H3yx0b7hyQW SGQg== 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 :dkim-signature; bh=hKYvtkFrQ5Gu/XGBw1Du7t9DP65ZOOocIcAU545xFeM=; b=ndpSKNOE1Eb4zsDmgJpmZLVXkvjz1oPcpgHcUFiJg7KyHkiTvaBpMwIhh+NxaizpC+ awg0ARh0tZuxokeCTgvl2W4VfU7yQr8q4/QBrEwxbc8gjCY/Re0BZUTbPqqIGn0RrUID a9PNP0+21hwDI/nr8MDNzNWhGSKiLROqnP05/QDDasuW82JoBmd0uzQn83z1Vxw178w9 sO+9oMwHpdhv1U6qDAHh47ZukblXZYB1Vd6lo6NdUCqDyAuKjjXuQ9gWoe7sM0L7ToLx U28rvvldUbA0+qNeLoUidKPJO69ZUMoinEKsNnVCWQAGgtB4i0UStx12NRf7cM+cQJ/U qXKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ItJS5nPx; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bn12-20020a056a02030c00b00439d86cf509si4287528pgb.645.2022.12.16.17.01.57; Fri, 16 Dec 2022 17:02:06 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ItJS5nPx; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229811AbiLQArR (ORCPT + 68 others); Fri, 16 Dec 2022 19:47:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229793AbiLQArK (ORCPT ); Fri, 16 Dec 2022 19:47:10 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEB334F643 for ; Fri, 16 Dec 2022 16:47:08 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4C88062300 for ; Sat, 17 Dec 2022 00:47:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DF15C433D2; Sat, 17 Dec 2022 00:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671238027; bh=AzwJwO831ToMtkyVqdqwG2XUb0eIPd36DW9P8p2Lef0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ItJS5nPxoXXc64tEoC8hOfl3x6pXx4brhOBseH0Pyxksxzz8in1nqVZnqERljNmqU brEIUU6hQEmXiUDL3EO7RmSQSIZ39aeG+LvjL+ndsRthYCklXmUKHKbg1ZU1/4euEv DdJjdXqHwWWcNokSfdY0S0YFxiPnuVTTkXUeC9dmmtwPepkh7gwmibrfwTU3/6nCZU hr9DCu5h1Ocig/o8lj4ISjo1vRRGvUhvMbraTdE8qMuigvKPWF1tNvzanI+Qb2U3O4 nsjUThYrohqD37nig5b+Z6mGHivajLd5heX/wzOmPxVyim35RY649jXB+2LRCXELTn 3g0kXPxMvVdyw== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH 3/3] f2fs: should use a temp extent_info for lookup Date: Fri, 16 Dec 2022 16:46:59 -0800 Message-Id: <20221217004659.2092427-4-jaegeuk@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221217004659.2092427-1-jaegeuk@kernel.org> References: <20221217004659.2092427-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Otherwise, __lookup_extent_tree() will override the given extent_info which will be used by caller. Signed-off-by: Jaegeuk Kim --- fs/f2fs/extent_cache.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c index 7bd1e1832412..a510fa57a823 100644 --- a/fs/f2fs/extent_cache.c +++ b/fs/f2fs/extent_cache.c @@ -888,6 +888,7 @@ static int __get_new_block_age(struct inode *inode, struct extent_info *ei, loff_t f_size = i_size_read(inode); unsigned long long cur_blocks = atomic64_read(&sbi->allocated_data_blocks); + struct extent_info tei = *ei; /* only fofs and len are valid */ /* * When I/O is not aligned to a PAGE_SIZE, update will happen to the last @@ -898,17 +899,17 @@ static int __get_new_block_age(struct inode *inode, struct extent_info *ei, blkaddr == NEW_ADDR) return -EINVAL; - if (__lookup_extent_tree(inode, ei->fofs, ei, EX_BLOCK_AGE)) { + if (__lookup_extent_tree(inode, ei->fofs, &tei, EX_BLOCK_AGE)) { unsigned long long cur_age; - if (cur_blocks >= ei->last_blocks) - cur_age = cur_blocks - ei->last_blocks; + if (cur_blocks >= tei.last_blocks) + cur_age = cur_blocks - tei.last_blocks; else /* allocated_data_blocks overflow */ - cur_age = ULLONG_MAX - ei->last_blocks + cur_blocks; + cur_age = ULLONG_MAX - tei.last_blocks + cur_blocks; - if (ei->age) - ei->age = __calculate_block_age(cur_age, ei->age); + if (tei.age) + ei->age = __calculate_block_age(cur_age, tei.age); else ei->age = cur_age; ei->last_blocks = cur_blocks; -- 2.39.0.314.g84b9a713c41-goog