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 <sbehr...@giantdisaster.de> >> CC: Wang Shilong <wangsl.f...@cn.fujitsu.com> >> Signed-off-by: David Sterba <dste...@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". -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html