public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Stefan Behrens <sbehrens@giantdisaster.de>
To: Wang Shilong <wangsl.fnst@cn.fujitsu.com>,
	David Sterba <dsterba@suse.cz>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs-progs: enclose uuid tree compat code with ifdefs
Date: Thu, 23 Jan 2014 09:20:24 +0100	[thread overview]
Message-ID: <52E0D0C8.3090502@giantdisaster.de> (raw)
In-Reply-To: <52E0C7ED.3000709@cn.fujitsu.com>

On Thu, 23 Jan 2014 15:42:37 +0800, Wang Shilong wrote:
> Hi David,
> 
> On 01/21/2014 11:56 PM, David Sterba wrote:
>> Commit "Btrfs-progs: make send/receive compatible with older kernels"
>> adds code that will become deprecated, let's clearly mark it in the
>> sources.
>>
>> CC: Stefan Behrens <sbehrens@giantdisaster.de>
>> CC: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
>> Signed-off-by: David Sterba <dsterba@suse.cz>
>> ---
>>   send-utils.c |   28 ++++++++++++++++++++++++++++
>>   send-utils.h |   10 ++++++++++
>>   2 files changed, 38 insertions(+), 0 deletions(-)
>>
>> diff --git a/send-utils.c b/send-utils.c
[...]
>> +#else
>> +void subvol_uuid_search_add(struct subvol_uuid_search *s,
>> +                struct subvol_info *si)
>> +{
>> +    if (si) {
>> +        free(si->path);
>> +        free(si);
>> +    }
>> +}
>> +#endif
> I noticed subvol_uuid_search_add() function before, anyway
> it is not called anywhere before, aslo IMO it is a little strange that
> we free
> memory here.

The old code calls subvol_uuid_search_add() when btrfs receive finishes
receiving a snapshot. This is required when you receive an incremental
stream which includes multiple snapshots, and each snapshot is
incremental to the previous one in the stream. If the uuid-tree is not
available and the old code is used, subvol_uuid_search_add() needs to be
called in finish_subvol().

The free()s in subvol_uuid_search_add() in the new code are correct. And
that this function is not called in the new code is correct as well. It
is only there since it is part of the exported functions of the
"btrfs-lib". And since the old code used subvol_uuid_search_add()
instead of free(), to add the pointers to the database, which does not
exist anymore in the new code, now it's just a free() of the memory, to
prevent a memory leak in existing applications that use the "btrfs-lib".



      reply	other threads:[~2014-01-23  8:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-21 15:56 [PATCH] btrfs-progs: enclose uuid tree compat code with ifdefs David Sterba
2014-01-23  7:42 ` Wang Shilong
2014-01-23  8:20   ` Stefan Behrens [this message]

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=52E0D0C8.3090502@giantdisaster.de \
    --to=sbehrens@giantdisaster.de \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wangsl.fnst@cn.fujitsu.com \
    /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