From 7ae0eef732c586aed62b321fb7842b054f3ebbe1 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 21 Oct 2003 18:21:54 -0700 Subject: [PATCH] [PATCH] Fix JBD memory leak Plug the two-megabyte-per-day memory leak. --- fs/jbd/commit.c | 8 ++++++++ fs/jbd/journal.c | 2 ++ 2 files changed, 10 insertions(+) diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c index 10845a5110038..4ee3c3e18f436 100644 --- a/fs/jbd/commit.c +++ b/fs/jbd/commit.c @@ -172,6 +172,14 @@ void journal_commit_transaction(journal_t *journal) while (commit_transaction->t_reserved_list) { jh = commit_transaction->t_reserved_list; JBUFFER_TRACE(jh, "reserved, unused: refile"); + /* + * A journal_get_undo_access()+journal_release_buffer() may + * leave undo-committed data. + */ + if (jh->b_committed_data) { + kfree(jh->b_committed_data); + jh->b_committed_data = NULL; + } journal_refile_buffer(journal, jh); } diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c index 04a96e22e5843..9f88325e2a408 100644 --- a/fs/jbd/journal.c +++ b/fs/jbd/journal.c @@ -1729,6 +1729,8 @@ static void __journal_remove_journal_head(struct buffer_head *bh) J_ASSERT_BH(bh, buffer_jbd(bh)); J_ASSERT_BH(bh, jh2bh(jh) == bh); BUFFER_TRACE(bh, "remove journal_head"); + J_ASSERT_BH(bh, !jh->b_frozen_data); + J_ASSERT_BH(bh, !jh->b_committed_data); bh->b_private = NULL; jh->b_bh = NULL; /* debug, really */ clear_buffer_jbd(bh); -- 2.53.0