|
|
bd8fca8 |
From a1ec5a369d2e2a98c21e8f508f444a80f1aef496 Mon Sep 17 00:00:00 2001
|
|
|
bd8fca8 |
From: Saki <shadowofs@gmail.com>
|
|
|
bd8fca8 |
Date: Fri, 1 Sep 2017 00:38:06 +0800
|
|
|
bd8fca8 |
Subject: [PATCH] Fix seed chunker discriminator not set (#78)
|
|
|
bd8fca8 |
|
|
|
bd8fca8 |
When user set a chunk_size, chunker.discriminator should be re-caculated
|
|
|
bd8fca8 |
with new chunk_size. Elsewise, Local seed cache can't be used to extract
|
|
|
bd8fca8 |
remote server.
|
|
|
bd8fca8 |
---
|
|
|
bd8fca8 |
src/caseed.c | 31 ++-----------------------------
|
|
|
bd8fca8 |
src/caseed.h | 4 +---
|
|
|
bd8fca8 |
src/casync.c | 10 +---------
|
|
|
bd8fca8 |
3 files changed, 4 insertions(+), 41 deletions(-)
|
|
|
bd8fca8 |
|
|
|
bd8fca8 |
diff --git a/src/caseed.c b/src/caseed.c
|
|
|
bd8fca8 |
index 6923750..ccf333a 100644
|
|
|
bd8fca8 |
--- a/src/caseed.c
|
|
|
bd8fca8 |
+++ b/src/caseed.c
|
|
|
bd8fca8 |
@@ -773,39 +773,12 @@ int ca_seed_set_feature_flags(CaSeed *s, uint64_t flags) {
|
|
|
bd8fca8 |
return ca_feature_flags_normalize(flags, &s->feature_flags);
|
|
|
bd8fca8 |
}
|
|
|
bd8fca8 |
|
|
|
bd8fca8 |
-int ca_seed_set_chunk_size_min(CaSeed *s, size_t cmin) {
|
|
|
bd8fca8 |
+int ca_seed_set_chunk_size(CaSeed *s, size_t cmin, size_t cavg, size_t cmax) {
|
|
|
bd8fca8 |
if (!s)
|
|
|
bd8fca8 |
return -EINVAL;
|
|
|
bd8fca8 |
- if (cmin < CA_CHUNK_SIZE_LIMIT_MIN)
|
|
|
bd8fca8 |
- return -EINVAL;
|
|
|
bd8fca8 |
- if (cmin > CA_CHUNK_SIZE_LIMIT_MAX)
|
|
|
bd8fca8 |
- return -EINVAL;
|
|
|
bd8fca8 |
-
|
|
|
bd8fca8 |
- s->chunker.chunk_size_min = cmin;
|
|
|
bd8fca8 |
- return 0;
|
|
|
bd8fca8 |
-}
|
|
|
bd8fca8 |
|
|
|
bd8fca8 |
-int ca_seed_set_chunk_size_avg(CaSeed *s, size_t cavg) {
|
|
|
bd8fca8 |
- if (!s)
|
|
|
bd8fca8 |
- return -EINVAL;
|
|
|
bd8fca8 |
- if (cavg < CA_CHUNK_SIZE_LIMIT_MIN)
|
|
|
bd8fca8 |
- return -EINVAL;
|
|
|
bd8fca8 |
- if (cavg > CA_CHUNK_SIZE_LIMIT_MAX)
|
|
|
bd8fca8 |
- return -EINVAL;
|
|
|
bd8fca8 |
-
|
|
|
bd8fca8 |
- s->chunker.chunk_size_avg = cavg;
|
|
|
bd8fca8 |
- return 0;
|
|
|
bd8fca8 |
-}
|
|
|
bd8fca8 |
-
|
|
|
bd8fca8 |
-int ca_seed_set_chunk_size_max(CaSeed *s, size_t cmax) {
|
|
|
bd8fca8 |
- if (!s)
|
|
|
bd8fca8 |
- return -EINVAL;
|
|
|
bd8fca8 |
- if (cmax < CA_CHUNK_SIZE_LIMIT_MIN)
|
|
|
bd8fca8 |
- return -EINVAL;
|
|
|
bd8fca8 |
- if (cmax > CA_CHUNK_SIZE_LIMIT_MAX)
|
|
|
bd8fca8 |
- return -EINVAL;
|
|
|
bd8fca8 |
+ ca_chunker_set_size(&s->chunker, cmin, cavg, cmax);
|
|
|
bd8fca8 |
|
|
|
bd8fca8 |
- s->chunker.chunk_size_max = cmax;
|
|
|
bd8fca8 |
return 0;
|
|
|
bd8fca8 |
}
|
|
|
bd8fca8 |
|
|
|
bd8fca8 |
diff --git a/src/caseed.h b/src/caseed.h
|
|
|
bd8fca8 |
index f2d9f8e..55c3d43 100644
|
|
|
bd8fca8 |
--- a/src/caseed.h
|
|
|
bd8fca8 |
+++ b/src/caseed.h
|
|
|
bd8fca8 |
@@ -36,9 +36,7 @@ int ca_seed_current_mode(CaSeed *seed, mode_t *ret);
|
|
|
bd8fca8 |
|
|
|
bd8fca8 |
int ca_seed_set_feature_flags(CaSeed *s, uint64_t flags);
|
|
|
bd8fca8 |
|
|
|
bd8fca8 |
-int ca_seed_set_chunk_size_min(CaSeed *s, size_t cmin);
|
|
|
bd8fca8 |
-int ca_seed_set_chunk_size_avg(CaSeed *s, size_t cavg);
|
|
|
bd8fca8 |
-int ca_seed_set_chunk_size_max(CaSeed *s, size_t cmax);
|
|
|
bd8fca8 |
+int ca_seed_set_chunk_size(CaSeed *s, size_t cmin, size_t cavg, size_t cmax);
|
|
|
bd8fca8 |
|
|
|
bd8fca8 |
int ca_seed_set_hardlink(CaSeed *s, bool b);
|
|
|
bd8fca8 |
int ca_seed_set_chunks(CaSeed *s, bool b);
|
|
|
bd8fca8 |
diff --git a/src/casync.c b/src/casync.c
|
|
|
bd8fca8 |
index 346d08b..a74b0d9 100644
|
|
|
bd8fca8 |
--- a/src/casync.c
|
|
|
bd8fca8 |
+++ b/src/casync.c
|
|
|
bd8fca8 |
@@ -2473,15 +2473,7 @@ static int ca_sync_propagate_flags_to_seeds(CaSync *s, uint64_t flags, size_t cm
|
|
|
bd8fca8 |
if (r < 0)
|
|
|
bd8fca8 |
return r;
|
|
|
bd8fca8 |
|
|
|
bd8fca8 |
- r = ca_seed_set_chunk_size_min(s->seeds[i], cmin);
|
|
|
bd8fca8 |
- if (r < 0)
|
|
|
bd8fca8 |
- return r;
|
|
|
bd8fca8 |
-
|
|
|
bd8fca8 |
- r = ca_seed_set_chunk_size_avg(s->seeds[i], cavg);
|
|
|
bd8fca8 |
- if (r < 0)
|
|
|
bd8fca8 |
- return r;
|
|
|
bd8fca8 |
-
|
|
|
bd8fca8 |
- r = ca_seed_set_chunk_size_max(s->seeds[i], cmax);
|
|
|
bd8fca8 |
+ r = ca_seed_set_chunk_size(s->seeds[i], cmin, cavg, cmax);
|
|
|
bd8fca8 |
if (r < 0)
|
|
|
bd8fca8 |
return r;
|
|
|
bd8fca8 |
}
|