Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6213884ybv; Tue, 18 Feb 2020 12:09:21 -0800 (PST) X-Google-Smtp-Source: APXvYqxhkzzJ7MAi7h/Ac1e390uEkV57ME0wCU30boEJoMqpKQo1lzRquI0jw97nqoQXuLGW7Miy X-Received: by 2002:aca:4994:: with SMTP id w142mr2295402oia.178.1582056561583; Tue, 18 Feb 2020 12:09:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582056561; cv=none; d=google.com; s=arc-20160816; b=Ezehh9FnSz/8F9rwBaSzOG/ccGddVtcmR0tZwhNn6RT2CVHC1z659AVj3/CwOfUvVh KdZONsjlWqhjJ9oyjMBv3VJyY/Mp8hCtPtCIwdhXhR2RsIKvXIOyYkRiAydBxqm6at8y kP6n4MiPg2QvffmSDFnKBOLxruRpSlEj/kJY5HykD2meh0MqxAW6QGnGCMDtIGNWu5QI Cou/+u8XLlqtIJrhrd4rrRLLyoQJkTpF/gEqNiNgA6b1Ja7/3E34MiUot5Jj3NoK+ccc eb/sAScvj14NMa77RlKDjzvC8uPCE9nxTKajMiRKfeCHhdTWO74fL9F180ijlonjwsna fyag== 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=kD2QpMQrS1dyLAO/rbV3r4Gvbei+Xh7399mupRpjM/Q=; b=fh/VsHmDMx9Ytv2Opt73wvgnf681mELLP/HcDtngHoC87yMS6d21g6Hk+AlkIxjcW8 5ZWIPhct9mQYdacQbigZomaiTJCXIIhhwytm8AG9cmZxt0xLPw+9iYbffvyHta4RIK8u dD/jMVrsZB3QuizKbF+P4uSpkysLGjEs6YiiZMHmWlSq/Nv6JY3y4HG8OUrMt2Yd/aj4 Bu7t1SZfPVtTn7XHhuO3GW3xq3PwsONWKjaB45TEX9Cl8uSy2J9M3YkOOLoy/kGVe3wi FEZBhqw34ZXLo85sPTar35jIgLQKQHzIznluPdAR7omKQjPc7dNNfuULCGemAa1H77Pq OxVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CChIMgbN; 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 a92si2137148otc.294.2020.02.18.12.09.09; Tue, 18 Feb 2020 12:09:21 -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=CChIMgbN; 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 S1728271AbgBRUJE (ORCPT + 99 others); Tue, 18 Feb 2020 15:09:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:34844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727934AbgBRT53 (ORCPT ); Tue, 18 Feb 2020 14:57:29 -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 D89EA2465A; Tue, 18 Feb 2020 19:57:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582055848; bh=YsUAoqFLDYdV+2dulnURG+0+0deDRpiA7VAIMBWwO9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CChIMgbNQex/DU+R2KYDWUrKaugaXZ20LkBkzzkOlWVLtLXUdTddPMUm22YaFyxbm tf4iujF8dwxeVgnaY6epbdgGBI0HK7y9L7ktyvdN/My6ezDvF0OqkT1hj4mAoJ14JC kYTLSOS19tlJVoM3HeXKeSSpTCYykpBH9zTRgRa4= 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 4.19 36/38] jbd2: move the clearing of b_modified flag to the journal_unmap_buffer() Date: Tue, 18 Feb 2020 20:55:22 +0100 Message-Id: <20200218190422.713559950@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200218190418.536430858@linuxfoundation.org> References: <20200218190418.536430858@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 020bd7a0d8e03..3fe9b7c27ce82 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -971,34 +971,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 911ff18249b75..97ffe12a22624 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -2228,14 +2228,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