Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp423373pxj; Thu, 10 Jun 2021 04:17:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ8IItKalgTfX40pWYh/ellM3CxJYe9PkOAJcioifrnKocRo3NRO0bmLHG3sx5dmJjPUBA X-Received: by 2002:a05:6402:3101:: with SMTP id dc1mr4089039edb.324.1623323852429; Thu, 10 Jun 2021 04:17:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623323852; cv=none; d=google.com; s=arc-20160816; b=PQWilYZ4hcxmQvcZBOQn4wnqM/Nvr7PTPwhS6CkG4WL3U+sDNJvl3ey+tC4ql/pJtJ HxHXNigpREzYWCUMzhdvHxTTuGceC4UXmLETltwocWhQ8z593LRRly59AGsM+0ZLfC20 NV73L5FgeTe7wKa3yCWXSZLJozcnkABB9o5qW2VIXlelEb85b3a/vHLD8GNMItApoFRB 0RZGV2MvEHUBCwckCvtIUCe2URJh8lsajsqzjM2c1uJX0ZjRSSVFNgcdXZ0ljqBuoQ+q N7ai/bv6WCCNRXYcG12UpNnckNURjtrljQIFxbJ3ICLUlMu/HU94Tg+J4QaOUKWIzSvq LXWQ== 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=3/zM0k9Rgou/nMB5J9/B65BoXNFutzQGne5GUQGgxbE=; b=Kf1pjOhjBqZXiG6Q1eEjqEthZGGjmn7ZWgkyiqcn4qw5IwkhmCYgkP73lf5bJcMbXV I1469gR6tJ0IqTbr9UW/mMdNnbflgJ35i/JaugduIVj4qYOCM3jOOycaFE/ke78vU2jt vXL3CDyXkkTPrpBPuq23Rkr9ZTUgSeizJYiCt8RquUz6Ncmru2xxlgJPJZCEvueNgUsY p8gF2fb5QDJoTof2RHesDmEXqGKmP60idmYKQyoS3Xc25pHsTdzwQUzd6hjektMY4xV1 y7K4s2Z4GnamNK4EcrHTnsaA+fUF636OAvsZcpKXGUVDHvxGnJgaDghcEYbFvagRjz39 Hv+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-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 s2si2003816edt.551.2021.06.10.04.17.09; Thu, 10 Jun 2021 04:17:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-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 S230247AbhFJLRz (ORCPT + 99 others); Thu, 10 Jun 2021 07:17:55 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:5488 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230205AbhFJLRu (ORCPT ); Thu, 10 Jun 2021 07:17:50 -0400 Received: from dggeme752-chm.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4G11YB2S0YzZf9N; Thu, 10 Jun 2021 19:13:02 +0800 (CST) Received: from huawei.com (10.175.127.227) by dggeme752-chm.china.huawei.com (10.3.19.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 10 Jun 2021 19:15:52 +0800 From: Zhang Yi To: , , , CC: , , , Subject: [RFC PATCH v4 6/8] jbd2: simplify journal_clean_one_cp_list() Date: Thu, 10 Jun 2021 19:24:38 +0800 Message-ID: <20210610112440.3438139-7-yi.zhang@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210610112440.3438139-1-yi.zhang@huawei.com> References: <20210610112440.3438139-1-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggeme752-chm.china.huawei.com (10.3.19.98) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Now that __try_to_free_cp_buf() remove checkpointed buffer or transaction when the buffer is not 'busy', which is only called by journal_clean_one_cp_list(). This patch simplify this function by remove __try_to_free_cp_buf() and invoke __cp_buffer_busy() directly. Signed-off-by: Zhang Yi Reviewed-by: Jan Kara --- fs/jbd2/checkpoint.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c index 1abdae44a3d8..51d1eb2ffeb9 100644 --- a/fs/jbd2/checkpoint.c +++ b/fs/jbd2/checkpoint.c @@ -91,25 +91,6 @@ static inline bool __cp_buffer_busy(struct journal_head *jh) return (jh->b_transaction || buffer_locked(bh) || buffer_dirty(bh)); } -/* - * Try to release a checkpointed buffer from its transaction. - * Returns 1 if we released it and 2 if we also released the - * whole transaction. - * - * Requires j_list_lock - */ -static int __try_to_free_cp_buf(struct journal_head *jh) -{ - int ret = 0; - struct buffer_head *bh = jh2bh(jh); - - if (!jh->b_transaction && !buffer_locked(bh) && !buffer_dirty(bh)) { - JBUFFER_TRACE(jh, "remove from checkpoint list"); - ret = __jbd2_journal_remove_checkpoint(jh) + 1; - } - return ret; -} - /* * __jbd2_log_wait_for_space: wait until there is space in the journal. * @@ -440,7 +421,6 @@ static int journal_clean_one_cp_list(struct journal_head *jh, bool destroy) { struct journal_head *last_jh; struct journal_head *next_jh = jh; - int ret; if (!jh) return 0; @@ -449,13 +429,11 @@ static int journal_clean_one_cp_list(struct journal_head *jh, bool destroy) do { jh = next_jh; next_jh = jh->b_cpnext; - if (!destroy) - ret = __try_to_free_cp_buf(jh); - else - ret = __jbd2_journal_remove_checkpoint(jh) + 1; - if (!ret) + + if (!destroy && __cp_buffer_busy(jh)) return 0; - if (ret == 2) + + if (__jbd2_journal_remove_checkpoint(jh)) return 1; /* * This function only frees up some memory -- 2.31.1