public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Stephen C. Tweedie" <sct@redhat.com>
To: Zwane Mwaikambo <zwane@linux.realnet.co.sz>
Cc: sct@redhat.com, Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] JBD code path (kfree cleanup)
Date: Sat, 1 Dec 2001 16:08:39 +0000	[thread overview]
Message-ID: <20011201160839.A2773@redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.33.0112011324370.11026-100000@netfinity.realnet.co.sz>
In-Reply-To: <Pine.LNX.4.33.0112011324370.11026-100000@netfinity.realnet.co.sz>; from zwane@linux.realnet.co.sz on Sat, Dec 01, 2001 at 01:28:56PM +0200

Him

On Sat, Dec 01, 2001 at 01:28:56PM +0200, Zwane Mwaikambo wrote:

> Please comment on the code path change, it seems sane to me.

No, it is broken.  Even a brief read of the comment above
this code would have revealed that:

		/*
		 * If there is undo-protected committed data against
		 * this buffer, then we can remove it now.  If it is a
		 * buffer needing such protection, the old frozen_data
		 * field now points to a committed version of the
		 * buffer, so rotate that field to the new committed
		 * data.

The old code you replaced was:

> diff -urN linux-2.5.1-pre4.orig/fs/jbd/commit.c linux-2.5.1-pre4.kfree/fs/jbd/commit.c
> --- linux-2.5.1-pre4.orig/fs/jbd/commit.c	Sat Nov 10 00:25:04 2001
> +++ linux-2.5.1-pre4.kfree/fs/jbd/commit.c	Fri Nov 30 23:08:58 2001
> @@ -619,17 +619,15 @@
>  		 *
>  		 * Otherwise, we can just throw away the frozen data now.
>  		 */
> -		if (jh->b_committed_data) {
> -			kfree(jh->b_committed_data);
> -			jh->b_committed_data = NULL;
> -			if (jh->b_frozen_data) {
> -				jh->b_committed_data = jh->b_frozen_data;
> -				jh->b_frozen_data = NULL;
> -			}

and this version  has the intended effect of replacing any existing
committed_data field with the current frozen_data field, keeping the
contents of committed_data valid.  Your new code

> +		kfree(jh->b_committed_data);
> +		jh->b_committed_data = NULL;
> +
> +		if (jh->b_frozen_data)
> +			jh->b_committed_data = jh->b_frozen_data;
> +		else
>  			kfree(jh->b_frozen_data);
> +
> +		jh->b_frozen_data = NULL;

will discard the state of committed_data entirely, and will assign any
existing frozen_data to the new committed_data field even if
committed_data was previously NULL.  That is *definitely* not the
correct behaviour.  It won't actually corrupt anything but it will
leak memory, as you'll end up creating committed_data copies of every
metadata buffer in the system, instead of this being done only for
those block bitmap buffers which need it.

Cheers,
 Stephen

  reply	other threads:[~2001-12-01 16:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-01 11:28 [PATCH] JBD code path (kfree cleanup) Zwane Mwaikambo
2001-12-01 16:08 ` Stephen C. Tweedie [this message]
2001-12-01 16:24   ` Zwane Mwaikambo
2001-12-02 13:59     ` Bernd Eckenfels
2001-12-03 10:38     ` Stephen C. Tweedie
  -- strict thread matches above, loose matches on Subject: below --
2001-12-03 15:22 Zwane Mwaikambo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011201160839.A2773@redhat.com \
    --to=sct@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zwane@linux.realnet.co.sz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox