Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6652415rwd; Mon, 5 Jun 2023 23:19:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ58R/8itR8BERalhbjc3+wVJfoZLeqXX0HsRlVvblVj/kRx8VHPpK1wgg/dAdiE4/bt7jrZ X-Received: by 2002:a05:6830:110d:b0:6b1:5e8f:e50c with SMTP id w13-20020a056830110d00b006b15e8fe50cmr704386otq.30.1686032378670; Mon, 05 Jun 2023 23:19:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686032378; cv=none; d=google.com; s=arc-20160816; b=WdtyaFE320YCErE9DIqGR4HGL1CHdMcsh1JumlSFw6HQGAqlJ5BBGkVcS2/gU/2M1X hl9su4huabSoCIG9CajoKY7akQp0SOzXZOAC9pPUEgF8MkHRPncuDxjOY/7+y2elmf3l vCqirWrFIgvNikOI7zBtbAgQWxrnP5B0V7HobcG1tVeuyIdc8ZjOoAJHtrmGsWSX8IlD PbuXMUZaf/cH7NgvowqjgA3RgLRrSzKohJ0Q6IUtyZw3L/8/j+xY1+VLPf3rVI4WYOjf 2mh7VzPi5SIB0+q8Da1mKl1Npor8Vs5I3zgJSBtFZ40vpsBdKEBFp1NrLWbJBKaEaIAv 9Xeg== 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=xVJb8lSuO6qnqvpR2Z6cSmO3hS3lzB8yqnIDjxHPnNY=; b=cJYQP44UlwzbKWnjd1vIGzf49sLymuXwUVg5NGgkcZxY8QVqK6ohHd3BR5qIB+3K/X 5W3ESgkRucNvQa6hIcgLCY7xBxZCsLhRrd5MhUmUFz6lAO4yfhEFIXWzosnEB1WkAiZb Zq3AC67nyPyv0kRyIvN/acMNF+Ity+ec60wMIbBwBpknWPZpXcWKSJpYe1HICGqeUPaG J+MdgRG/nAo/HrrLcCXnhMW9ZXg4P3hUpVtpm4f91HfeYBa9HyI/i0K0RZh6i/z+YD6q R7z+768dOD9gDjBgvHEOo8fOtJbf28zhUKVcDN/YJZTW37PEkg1Ec723tQ8U2uXU9vRM kfzA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i25-20020a633c59000000b0053fb5df5561si1612217pgn.246.2023.06.05.23.19.24; Mon, 05 Jun 2023 23:19:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234917AbjFFGPK (ORCPT + 99 others); Tue, 6 Jun 2023 02:15:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234837AbjFFGPB (ORCPT ); Tue, 6 Jun 2023 02:15:01 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C1AE1BD for ; Mon, 5 Jun 2023 23:15:00 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Qb0Z924gQz4f3pFP for ; Tue, 6 Jun 2023 14:14:57 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.170]) by APP2 (Coremail) with SMTP id Syh0CgA33erXzn5kkHrZKw--.1805S10; Tue, 06 Jun 2023 14:14:58 +0800 (CST) From: Zhang Yi To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, yukuai3@huawei.com, chengzhihao1@huawei.com Subject: [PATCH v2 6/6] jbd2: remove __journal_try_to_free_buffer() Date: Tue, 6 Jun 2023 14:14:47 +0800 Message-Id: <20230606061447.1125036-7-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230606061447.1125036-1-yi.zhang@huaweicloud.com> References: <20230606061447.1125036-1-yi.zhang@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: Syh0CgA33erXzn5kkHrZKw--.1805S10 X-Coremail-Antispam: 1UD129KBjvJXoW7CF1DXw47Zr4rKrWDuw4xCrg_yoW8Zryxpr yak3y7Zryqva48Zr1kXF4rArWjqa1qvryUGrZru3Z3ta15AwsIv347tr1IqryDtFWSga15 Xr1UC3s8C3yjy3JanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9K14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxGrw CFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE 14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2 IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UMIIF0xvE42xK8VAv wI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14 v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUF18BUUUUU X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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-ext4@vger.kernel.org From: Zhang Yi __journal_try_to_free_buffer() has only one caller and it's logic is much simple now, so just remove it and open code in jbd2_journal_try_to_free_buffers(). Signed-off-by: Zhang Yi --- fs/jbd2/transaction.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index 6ef5022949c4..4d1fda1f7143 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -2099,29 +2099,6 @@ void jbd2_journal_unfile_buffer(journal_t *journal, struct journal_head *jh) __brelse(bh); } -/* - * Called from jbd2_journal_try_to_free_buffers(). - * - * Called under jh->b_state_lock - */ -static void -__journal_try_to_free_buffer(journal_t *journal, struct buffer_head *bh) -{ - struct journal_head *jh; - - jh = bh2jh(bh); - - if (jh->b_next_transaction != NULL || jh->b_transaction != NULL) - return; - - spin_lock(&journal->j_list_lock); - /* Remove written-back checkpointed metadata buffer */ - if (jh->b_cp_transaction != NULL) - jbd2_journal_try_remove_checkpoint(jh); - spin_unlock(&journal->j_list_lock); - return; -} - /** * jbd2_journal_try_to_free_buffers() - try to free page buffers. * @journal: journal for operation @@ -2179,7 +2156,13 @@ bool jbd2_journal_try_to_free_buffers(journal_t *journal, struct folio *folio) continue; spin_lock(&jh->b_state_lock); - __journal_try_to_free_buffer(journal, bh); + if (!jh->b_transaction && !jh->b_next_transaction) { + spin_lock(&journal->j_list_lock); + /* Remove written-back checkpointed metadata buffer */ + if (jh->b_cp_transaction != NULL) + jbd2_journal_try_remove_checkpoint(jh); + spin_unlock(&journal->j_list_lock); + } spin_unlock(&jh->b_state_lock); jbd2_journal_put_journal_head(jh); if (buffer_jbd(bh)) -- 2.31.1