Skip to content

Commit

Permalink
Free filerec compared trees after find_dupes
Browse files Browse the repository at this point in the history
We don't need these hanging around any more.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
  • Loading branch information
Mark Fasheh committed Sep 21, 2016
1 parent fae80ce commit 2bb8309
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
8 changes: 8 additions & 0 deletions filerec.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ static void free_compared_tree(struct filerec *file)
abort_on(!RB_EMPTY_ROOT(&file->comparisons));
}

void free_all_filerec_compared(void)
{
struct filerec *file;

list_for_each_entry(file, &filerec_list, rec_list)
free_compared_tree(file);
}

static int cmp_filerecs(struct filerec *file1, uint64_t file2_inum,
uint64_t file2_subvolid)
{
Expand Down
2 changes: 1 addition & 1 deletion filerec.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ struct filerec_token *filerec_token_new(struct filerec *file);

int filerecs_compared(struct filerec *file1, struct filerec *file2);
int mark_filerecs_compared(struct filerec *file1, struct filerec *file2);

void free_all_filerec_compared(void);

struct fiemap_ctxt;
struct fiemap_ctxt *alloc_fiemap_ctxt(void);
Expand Down
7 changes: 5 additions & 2 deletions find_dupes.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,12 @@ static int find_all_dupes_filewise(struct hash_tree *tree,
wait_update_extent_search_status(pool);

out:

g_thread_pool_free(pool, FALSE, TRUE);

/*
* Save memory by freeing each filerec compared tree once all
* threads have finished.
*/
free_all_filerec_compared();
return ret;
}

Expand Down

0 comments on commit 2bb8309

Please sign in to comment.