From b45850388ea5505f4fd50cd659abe2f02aeca0b5 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 16 Aug 2019 19:52:42 +0200 Subject: cleanup: internalize deduplication list in data_writer This change removes the need for passing a list of files around for deduplication. Also the deduplication code no longer needs to worry about order, since the file being deduplicated is only added after deduplication is done. Signed-off-by: David Oberhollenzer --- include/data_writer.h | 19 ++++++------------- include/fstree.h | 4 +--- 2 files changed, 7 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/include/data_writer.h b/include/data_writer.h index dc63592..f384ce7 100644 --- a/include/data_writer.h +++ b/include/data_writer.h @@ -69,32 +69,25 @@ int data_writer_flush_fragments(data_writer_t *data); Blocks or fragments that are all zero bytes automatically detected, not written out and the sparse file accounting updated accordingly. - The flags argument is a combination of DW_* flags. - - If 'list' is not NULL, it is used for fragment and data block deduplication. - It is assumed that the list is processed in order and scanning stops as soon - as the current file info 'fi' is encountered in the list. + The flags argument is a combination of DW_* flags. After completion the + data writer collects the 'fi' in an internal list it uses for deduplication. Returns 0 on success, prints errors to stderr. */ int write_data_from_fd(data_writer_t *data, file_info_t *fi, int infd, - int flags, file_info_t *list); + int flags); /* Does the same as write_data_from_fd but the input file is the condensed representation of a sparse file. The layout must be in order and non-overlapping. - The flags argument is a combination of DW_* flags. - - If 'list' is not NULL, it is used for fragment and data block deduplication. - It is assumed that the list is processed in order and scanning stops as soon - as the current file info 'fi' is encountered in the list. + The flags argument is a combination of DW_* flags. After completion the + data writer collects the 'fi' in an internal list it uses for deduplication. Returns 0 on success, prints errors to stderr. */ int write_data_from_fd_condensed(data_writer_t *data, file_info_t *fi, - int infd, sparse_map_t *map, int flags, - file_info_t *list); + int infd, sparse_map_t *map, int flags); #endif /* DATA_WRITER_H */ diff --git a/include/fstree.h b/include/fstree.h index cbd3c9c..a5d930e 100644 --- a/include/fstree.h +++ b/include/fstree.h @@ -313,7 +313,6 @@ tree_node_t *fstree_node_from_path(fstree_t *fs, const char *path); /* Walk through 'list' to find a file with a fragment that has the same size ('frag_size') and checksum ('chksum') as 'fi'. - Processing stopps if 'fi' itself is found in the list. Returns NULL if no such fragment could be found. */ @@ -323,8 +322,7 @@ file_info_t *fragment_by_chksum(file_info_t *fi, uint32_t chksum, /* Walk through 'list' to find a file that contains the same sequence of blocks - as 'file', comparing size and checksum. Processing stops if 'file' is found - in the list. + as 'file', comparing size and checksum. Returns NULL if no such fragment could be found. */ -- cgit v1.2.3