[sheepdog] [RFC PATCH] farm: don't check of the existing object before slice_write
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Fri Jul 19 06:33:16 CEST 2013
Currently, we stores sliced objects for the farm store, so
sha1_file_exist() fails always.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
Other approaches are:
- Calculate the sha1 digest before slicing objects and store the
value to the farm store so that sha1_file_exist() can check it.
- Make sheep return the hash value of the sliced data.
Any suggestions?
collie/collie.h | 2 --
collie/common.c | 27 ---------------------------
collie/farm/farm.c | 9 ---------
collie/farm/farm.h | 1 -
collie/farm/sha1_file.c | 5 -----
5 files changed, 44 deletions(-)
diff --git a/collie/collie.h b/collie/collie.h
index e0984e9..7f5c128 100644
--- a/collie/collie.h
+++ b/collie/collie.h
@@ -68,8 +68,6 @@ typedef void (*vdi_parser_func_t)(uint32_t vid, const char *name,
uint32_t flags,
const struct sd_inode *i, void *data);
int parse_vdi(vdi_parser_func_t func, size_t size, void *data);
-int sd_read_object_sha1(uint64_t oid, uint32_t epoch, int nr_copies,
- unsigned char *sha1);
int sd_read_object(uint64_t oid, void *data, unsigned int datalen,
uint64_t offset, bool direct);
int sd_write_object(uint64_t oid, uint64_t cow_oid, void *data,
diff --git a/collie/common.c b/collie/common.c
index 4a57d92..3af4ce8 100644
--- a/collie/common.c
+++ b/collie/common.c
@@ -38,33 +38,6 @@ char *size_to_str(uint64_t _size, char *str, int str_size)
return str;
}
-int sd_read_object_sha1(uint64_t oid, uint32_t epoch, int nr_copies,
- unsigned char *sha1)
-{
- struct sd_req req;
- struct sd_rsp *rsp = (struct sd_rsp *)&req;
- const struct sd_vnode *vnode = NULL;
- char host[HOST_NAME_MAX];
- int port, ret = -1;
-
- sd_init_req(&req, SD_OP_GET_HASH);
- req.obj.oid = oid;
- req.obj.tgt_epoch = epoch;
-
- for (int i = 0; i < nr_copies; i++) {
- vnode = oid_to_vnode(sd_vnodes, sd_vnodes_nr, oid, i);
- addr_to_str(host, sizeof(host), vnode->nid.addr, 0);
- port = vnode->nid.port;
- if (collie_exec_req(host, port, &req, NULL) == 0) {
- memcpy(sha1, rsp->hash.digest, SHA1_DIGEST_SIZE);
- ret = 0;
- goto out;
- }
- }
-out:
- return ret;
-}
-
int sd_read_object(uint64_t oid, void *data, unsigned int datalen,
uint64_t offset, bool direct)
{
diff --git a/collie/farm/farm.c b/collie/farm/farm.c
index a42ac47..8b4def6 100644
--- a/collie/farm/farm.c
+++ b/collie/farm/farm.c
@@ -222,21 +222,12 @@ static void do_save_object(struct work *work)
void *buf;
size_t size;
struct snapshot_work *sw;
- unsigned char object_sha1[SHA1_DIGEST_SIZE];
if (uatomic_is_true(&work_error))
return;
sw = container_of(work, struct snapshot_work, work);
- /* read object sha1 and check if exists in local path */
- if (sd_read_object_sha1(sw->entry.oid, sd_epoch, sw->entry.nr_copies,
- object_sha1) == 0 &&
- sha1_file_exist(object_sha1)) {
- memcpy(sw->entry.sha1, object_sha1, SHA1_DIGEST_SIZE);
- return;
- }
-
size = get_objsize(sw->entry.oid);
buf = xmalloc(size);
diff --git a/collie/farm/farm.h b/collie/farm/farm.h
index ba6f53e..aa82b0f 100644
--- a/collie/farm/farm.h
+++ b/collie/farm/farm.h
@@ -66,7 +66,6 @@ void *snap_log_read(int *out_nr);
int snap_log_write(uint32_t idx, const char *tag, unsigned char *sha1);
/* sha1_file.c */
-bool sha1_file_exist(const unsigned char *sha1);
int sha1_file_write(void *buf, size_t len, unsigned char *sha1);
void *sha1_file_read(const unsigned char *sha1, size_t *size);
int get_sha1_hex(const char *hex, unsigned char *sha1);
diff --git a/collie/farm/sha1_file.c b/collie/farm/sha1_file.c
index a2f3561..ecd0c8c 100644
--- a/collie/farm/sha1_file.c
+++ b/collie/farm/sha1_file.c
@@ -150,11 +150,6 @@ err_open:
return ret;
}
-bool sha1_file_exist(const unsigned char *sha1)
-{
- return (access(sha1_to_path(sha1), R_OK) == 0);
-}
-
int sha1_file_write(void *buf, size_t len, unsigned char *outsha1)
{
unsigned char sha1[SHA1_DIGEST_SIZE];
--
1.8.1.3.566.gaa39828
More information about the sheepdog
mailing list