Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6212771ybv; Tue, 18 Feb 2020 12:08:11 -0800 (PST) X-Google-Smtp-Source: APXvYqzRjy4xxOn2z1w5RERgkArzymK2WX7zbCeW2LzmmHpFOqMpM/pb3Ny3L5pxpeMJao5Y1n5+ X-Received: by 2002:a9d:6f0a:: with SMTP id n10mr17633197otq.54.1582056491087; Tue, 18 Feb 2020 12:08:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582056491; cv=none; d=google.com; s=arc-20160816; b=u82Im+1OMCocyWHRXIAXagfjN0Zum5Y8nJwryXvZY6KkbIcDbCNcjWT0biACl4Hjf0 wrWKL7LIDQ1OHHpq4BX4p0DypNWfpEbirCRzFq6SWlzIZWOj7IeMXRfB2HC1hKPYvTwP Lm0WupSAWHWM5iBcElHSF1NSE0vBs3U7nxXZquTN476xgxo+brimoBhNNRomQo0sRWDb h28ZySe7owAnHBxcgXhyWQd3pWgIQ8Ay9OKBowflTb50jE/BYnc+oK8Ik+cSrB6xwSgx 24d30DG0rciBV/7Qwqn6HYlR63CcmsEIqBNKjY8JyLVnesJZcYcFXkdrnHwf0aydUqrC ahXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=13p353bb5zP+5UVXa391ECLIuhFFVM7a8MMRNsXLDEU=; b=PDygAs/ywVckPN3KQdIRabaMBRBQFA67txkQqoa6C9m8rZ7DAKKFR04R43ybiEZoio EcrOpk8x042J8JwYt8Bjl6NUo9fWc+l9Xt8UudGV5kav/M1nQjaxrdTExlaniu5mQMuz ZiwyHC28YAtbufTqSwdNL3sM+3zfbbaQcNVtOhYSwg9sTLqYuzoq+voPUY0v2L20QxGe tzXCY2fiEiSrh26kEBKxtRjI7pp593pzB7Zw/yevIhZkL1wZLYlT7tC5GW6qDqJzAA1E B+kacB2pmZTHHBA81kYVM03mtNydTqUBx6ZrvLfUD1XUkibSxcUI9Yoclr2uq9RFK8sN IGCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="fetxkM/U"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j70si9184394oib.219.2020.02.18.12.07.59; Tue, 18 Feb 2020 12:08:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="fetxkM/U"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727668AbgBRUGr (ORCPT + 99 others); Tue, 18 Feb 2020 15:06:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:38836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726801AbgBRT7z (ORCPT ); Tue, 18 Feb 2020 14:59:55 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D8C7524125; Tue, 18 Feb 2020 19:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582055994; bh=ECGvmFKxD67Z6wpEVJNvoBIaymJUwKg9QKOsMuNJfNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fetxkM/UFousr1MvFGjWeJ507eBFYoZTm4JkCrYJDEF9VrpNfjo1R43sxqDHfAaC8 YUGlLo7D01tokXzqaK6NwsgI5euGXLvpHBlI2E3F0rUVL4CuJzu9zf0KQezjw004n5 mZf7Hkfsqb2iGaQjVB/6wIhoTBxx0VfE1RnSkJpE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kara , "zhangyi (F)" , Theodore Tso , stable@kernel.org, Sasha Levin Subject: [PATCH 5.4 61/66] jbd2: move the clearing of b_modified flag to the journal_unmap_buffer() Date: Tue, 18 Feb 2020 20:55:28 +0100 Message-Id: <20200218190433.829638977@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200218190428.035153861@linuxfoundation.org> References: <20200218190428.035153861@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: zhangyi (F) [ Upstream commit 6a66a7ded12baa6ebbb2e3e82f8cb91382814839 ] There is no need to delay the clearing of b_modified flag to the transaction committing time when unmapping the journalled buffer, so just move it to the journal_unmap_buffer(). Link: https://lore.kernel.org/r/20200213063821.30455-2-yi.zhang@huawei.com Reviewed-by: Jan Kara Signed-off-by: zhangyi (F) Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Sasha Levin --- fs/jbd2/commit.c | 43 +++++++++++++++---------------------------- fs/jbd2/transaction.c | 10 ++++++---- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index c43591cd70f1c..7fdb5f130f642 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -974,34 +974,21 @@ void jbd2_journal_commit_transaction(journal_t *journal) * it. */ /* - * A buffer which has been freed while still being journaled by - * a previous transaction. - */ - if (buffer_freed(bh)) { - /* - * If the running transaction is the one containing - * "add to orphan" operation (b_next_transaction != - * NULL), we have to wait for that transaction to - * commit before we can really get rid of the buffer. - * So just clear b_modified to not confuse transaction - * credit accounting and refile the buffer to - * BJ_Forget of the running transaction. If the just - * committed transaction contains "add to orphan" - * operation, we can completely invalidate the buffer - * now. We are rather through in that since the - * buffer may be still accessible when blocksize < - * pagesize and it is attached to the last partial - * page. - */ - jh->b_modified = 0; - if (!jh->b_next_transaction) { - clear_buffer_freed(bh); - clear_buffer_jbddirty(bh); - clear_buffer_mapped(bh); - clear_buffer_new(bh); - clear_buffer_req(bh); - bh->b_bdev = NULL; - } + * A buffer which has been freed while still being journaled + * by a previous transaction, refile the buffer to BJ_Forget of + * the running transaction. If the just committed transaction + * contains "add to orphan" operation, we can completely + * invalidate the buffer now. We are rather through in that + * since the buffer may be still accessible when blocksize < + * pagesize and it is attached to the last partial page. + */ + if (buffer_freed(bh) && !jh->b_next_transaction) { + clear_buffer_freed(bh); + clear_buffer_jbddirty(bh); + clear_buffer_mapped(bh); + clear_buffer_new(bh); + clear_buffer_req(bh); + bh->b_bdev = NULL; } if (buffer_jbddirty(bh)) { diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index bee8498d77929..3930c68a9c204 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -2296,14 +2296,16 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh, return -EBUSY; } /* - * OK, buffer won't be reachable after truncate. We just set - * j_next_transaction to the running transaction (if there is - * one) and mark buffer as freed so that commit code knows it - * should clear dirty bits when it is done with the buffer. + * OK, buffer won't be reachable after truncate. We just clear + * b_modified to not confuse transaction credit accounting, and + * set j_next_transaction to the running transaction (if there + * is one) and mark buffer as freed so that commit code knows + * it should clear dirty bits when it is done with the buffer. */ set_buffer_freed(bh); if (journal->j_running_transaction && buffer_jbddirty(bh)) jh->b_next_transaction = journal->j_running_transaction; + jh->b_modified = 0; jbd2_journal_put_journal_head(jh); spin_unlock(&journal->j_list_lock); jbd_unlock_bh_state(bh); -- 2.20.1