]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Fix JBD memory leak
authorAndrew Morton <akpm@osdl.org>
Wed, 22 Oct 2003 01:21:54 +0000 (18:21 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Wed, 22 Oct 2003 01:21:54 +0000 (18:21 -0700)
Plug the two-megabyte-per-day memory leak.

fs/jbd/commit.c
fs/jbd/journal.c

index 10845a5110038acae19156cb6525305de2a2e12f..4ee3c3e18f436ff7a0a9a21ae91da3997196f5ac 100644 (file)
@@ -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);
        }
 
index 04a96e22e58431d225c792eb297e2a43a1c3b6cb..9f88325e2a408d57f29e3f5857b98ee13d6f810f 100644 (file)
@@ -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);