From 623e0c823c54ff44448db2954632b6cb0d868120 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Sat, 20 Nov 2010 23:33:18 +0100 Subject: [PATCH] Add delta_seq to restore tree code Add list of Delta Sequence to TREE_NODE, each Delta is composed of with JobIndex and JobId --- bacula/src/lib/tree.c | 24 +++++++++++++++++++++++- bacula/src/lib/tree.h | 12 ++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/bacula/src/lib/tree.c b/bacula/src/lib/tree.c index ddbf2dcd15..6d4a295dad 100644 --- a/bacula/src/lib/tree.c +++ b/bacula/src/lib/tree.c @@ -111,6 +111,7 @@ static TREE_NODE *new_tree_node(TREE_ROOT *root) int size = sizeof(TREE_NODE); node = (TREE_NODE *)tree_alloc(root, size); memset(node, 0, size); + node->delta_seq = -1; return node; } @@ -125,7 +126,16 @@ static void free_tree_node(TREE_ROOT *root) root->mem->mem -= asize; } - +void tree_remove_node(TREE_ROOT *root, TREE_NODE *node) +{ + int asize = BALIGN(sizeof(TREE_NODE)); + node->parent->child.remove(node); + if ((root->mem->mem - asize) == (char *)node) { + free_tree_node(root); + } else { + Dmsg0(0, "Can't release tree node\n"); + } +} /* * Allocate bytes for filename in tree structure. @@ -172,6 +182,18 @@ void free_tree(TREE_ROOT *root) return; } +/* Add Delta part for this node */ +void tree_add_delta_part(TREE_ROOT *root, TREE_NODE *node, + JobId_t JobId, int32_t FileIndex) +{ + struct delta_list *elt = + (struct delta_list*) tree_alloc(root, sizeof(struct delta_list)); + + elt->next = node->delta_list; + elt->JobId = JobId; + elt->FileIndex = FileIndex; + node->delta_list = elt; +} /* * Insert a node in the tree. This is the main subroutine diff --git a/bacula/src/lib/tree.h b/bacula/src/lib/tree.h index c24feb3960..3464cb1965 100644 --- a/bacula/src/lib/tree.h +++ b/bacula/src/lib/tree.h @@ -50,6 +50,11 @@ struct s_mem { #define first_child(node) \ ((TREE_NODE *)(node->child.first()) +struct delta_list { + struct delta_list *next; + JobId_t JobId; + int32_t FileIndex; +}; /* * Keep this node as small as possible because @@ -63,6 +68,7 @@ struct s_tree_node { char *fname; /* file name */ int32_t FileIndex; /* file index */ uint32_t JobId; /* JobId */ + int32_t delta_seq; /* current delta sequence */ uint16_t fname_len; /* filename length */ int type: 8; /* node type */ unsigned int extract: 1; /* extract item */ @@ -73,6 +79,7 @@ struct s_tree_node { unsigned int loaded: 1; /* set when the dir is in the tree */ struct s_tree_node *parent; struct s_tree_node *next; /* next hash of FileIndex */ + struct delta_list *delta_list; /* delta parts for this node */ }; typedef struct s_tree_node TREE_NODE; @@ -84,6 +91,7 @@ struct s_tree_root { const char *fname; /* file name */ int32_t FileIndex; /* file index */ uint32_t JobId; /* JobId */ + int32_t delta_seq; /* current delta sequence */ uint16_t fname_len; /* filename length */ unsigned int type: 8; /* node type */ unsigned int extract: 1; /* extract item */ @@ -93,6 +101,7 @@ struct s_tree_root { unsigned int loaded: 1; /* set when the dir is in the tree */ struct s_tree_node *parent; struct s_tree_node *next; /* next hash of FileIndex */ + struct delta_list *delta_list; /* delta parts for this node */ /* The above ^^^ must be identical to a TREE_NODE structure */ struct s_tree_node *first; /* first entry in the tree */ @@ -121,8 +130,11 @@ TREE_NODE *insert_tree_node(char *path, char *fname, int type, TREE_NODE *make_tree_path(char *path, TREE_ROOT *root); TREE_NODE *tree_cwd(char *path, TREE_ROOT *root, TREE_NODE *node); TREE_NODE *tree_relcwd(char *path, TREE_ROOT *root, TREE_NODE *node); +void tree_add_delta_part(TREE_ROOT *root, TREE_NODE *node, + JobId_t JobId, int32_t FileIndex); void free_tree(TREE_ROOT *root); int tree_getpath(TREE_NODE *node, char *buf, int buf_size); +void tree_remove_node(TREE_ROOT *root, TREE_NODE *node); /* * Use the following for traversing the whole tree. It will be -- 2.39.5