aboutsummaryrefslogtreecommitdiff
path: root/lib/fstree
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-21 13:30:34 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-21 13:30:34 +0200
commit321290241e84a3a2cfc30b65fc6e79ecd266e420 (patch)
tree1a12686dd3ea7afe0d6e6d93fac3440d2c70bd8d /lib/fstree
parent1bb19e4e6980019d0e4ac348f99d9d2cf0074d6b (diff)
Keep track of xattr key & value references AFTER deduplication
This commit adds a reference count functionality to the string table implementation and uses this functionality in the fstree code to count how often each key and value is referenced by the deduplicated Xattr blocks. This is needed to support deduplication through out-of-band storage of xattrs. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree')
-rw-r--r--lib/fstree/xattr.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/fstree/xattr.c b/lib/fstree/xattr.c
index 38f7703..4597d9d 100644
--- a/lib/fstree/xattr.c
+++ b/lib/fstree/xattr.c
@@ -102,11 +102,24 @@ static int cmp_u64(const void *lhs, const void *rhs)
void fstree_xattr_reindex(fstree_t *fs)
{
+ uint32_t key_idx, value_idx;
+ size_t i, index = 0;
tree_xattr_t *it;
- size_t index = 0;
- for (it = fs->xattr; it != NULL; it = it->next)
+ str_table_reset_ref_count(&fs->xattr_keys);
+ str_table_reset_ref_count(&fs->xattr_values);
+
+ for (it = fs->xattr; it != NULL; it = it->next) {
it->index = index++;
+
+ for (i = 0; i < it->num_attr; ++i) {
+ key_idx = (it->ref[i] >> 32) & 0x00000000FFFFFFFF;
+ value_idx = it->ref[i] & 0x00000000FFFFFFFF;
+
+ str_table_add_ref(&fs->xattr_keys, key_idx);
+ str_table_add_ref(&fs->xattr_values, value_idx);
+ }
+ }
}
void fstree_xattr_deduplicate(fstree_t *fs)