From: levin li <[email protected]>

As I noticed, object_cache_rw() never used epoch and nr_copies at all,
so it's no need to pass epoch and nr_copies to object_cache_write, for
the same reason, read/write/remove_object() will never use these parameters
any more, since we will send a gateway request to the node itself, epoch
and nr_copes together with vnode_info would not be used any more.

Signed-off-by: levin li <[email protected]>
---
 sheep/object_cache.c |    7 ++--
 sheep/sheep_priv.h   |   18 ++++-------
 sheep/store.c        |   18 ++++-------
 sheep/vdi.c          |   87 ++++++++++++++++++++------------------------------
 4 files changed, 51 insertions(+), 79 deletions(-)

diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index 1854a77..404944a 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -797,8 +797,7 @@ int object_cache_handle_request(struct request *req)
 }
 
 int object_cache_write(uint64_t oid, char *data, unsigned int datalen,
-                      uint64_t offset, uint16_t flags, int copies,
-                      uint32_t epoch, int create)
+                      uint64_t offset, uint16_t flags, int create)
 {
        int ret;
        struct request *req;
@@ -821,7 +820,6 @@ int object_cache_write(uint64_t oid, char *data, unsigned 
int datalen,
 
        req->rq.obj.oid = oid;
        req->rq.obj.offset = offset;
-       req->rq.obj.copies = copies;
 
        req->data = data;
        req->op = get_sd_op(req->rq.opcode);
@@ -833,7 +831,7 @@ int object_cache_write(uint64_t oid, char *data, unsigned 
int datalen,
 }
 
 int object_cache_read(uint64_t oid, char *data, unsigned int datalen,
-                     uint64_t offset, int copies, uint32_t epoch)
+                     uint64_t offset)
 {
        int ret;
        struct request *req;
@@ -852,7 +850,6 @@ int object_cache_read(uint64_t oid, char *data, unsigned 
int datalen,
 
        req->rq.obj.oid = oid;
        req->rq.obj.offset = offset;
-       req->rq.obj.copies = copies;
 
        req->data = data;
        req->op = get_sd_op(req->rq.opcode);
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index afdaad8..290ea82 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -283,14 +283,11 @@ bool oid_in_recovery(uint64_t oid);
 int is_recovery_init(void);
 int node_in_recovery(void);
 
-int write_object(struct vnode_info *vnodes, uint32_t node_version,
-                uint64_t oid, char *data, unsigned int datalen,
-                uint64_t offset, uint16_t flags, int nr, int create);
-int read_object(struct vnode_info *vnodes, uint32_t node_version,
-               uint64_t oid, char *data, unsigned int datalen,
-               uint64_t offset, int nr);
-int remove_object(struct vnode_info *vnodes, uint32_t node_version,
-                 uint64_t oid, int nr);
+int write_object(uint64_t oid, char *data, unsigned int datalen,
+                uint64_t offset, uint16_t flags, int create);
+int read_object(uint64_t oid, char *data, unsigned int datalen,
+               uint64_t offset);
+int remove_object(uint64_t oid);
 
 void del_sheep_fd(int fd);
 int get_sheep_fd(uint8_t *addr, uint16_t port, int node_idx, uint32_t epoch);
@@ -394,10 +391,9 @@ int object_is_cached(uint64_t oid);
 
 int object_cache_handle_request(struct request *req);
 int object_cache_write(uint64_t oid, char *data, unsigned int datalen,
-               uint64_t offset, uint16_t flags, int copies, uint32_t epoch,
-               int create);
+                      uint64_t offset, uint16_t flags, int create);
 int object_cache_read(uint64_t oid, char *data, unsigned int datalen,
-               uint64_t offset, int copies, uint32_t epoch);
+                     uint64_t offset);
 int object_cache_flush_vdi(struct request *req);
 int object_cache_flush_and_del(struct request *req);
 void object_cache_delete(uint32_t vid);
diff --git a/sheep/store.c b/sheep/store.c
index cfd980b..d394cf5 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -512,9 +512,8 @@ int init_store(const char *d, int enable_write_cache)
 /*
  * Write data to both local object cache (if enabled) and backends
  */
-int write_object(struct vnode_info *vnodes, uint32_t epoch,
-                uint64_t oid, char *data, unsigned int datalen,
-                uint64_t offset, uint16_t flags, int nr_copies, int create)
+int write_object(uint64_t oid, char *data, unsigned int datalen,
+                uint64_t offset, uint16_t flags, int create)
 {
        struct sd_req hdr;
        struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
@@ -524,7 +523,7 @@ int write_object(struct vnode_info *vnodes, uint32_t epoch,
 
        if (sys->enable_write_cache && object_is_cached(oid)) {
                ret = object_cache_write(oid, data, datalen, offset,
-                       flags, nr_copies, epoch, create);
+                                        flags, create);
                if (ret != 0) {
                        eprintf("write cache failed %"PRIx64" %"PRIx32"\n",
                                oid, ret);
@@ -568,9 +567,8 @@ int write_object(struct vnode_info *vnodes, uint32_t epoch,
  * Read data firstly from local object cache(if enabled), if fail,
  * try read backends
  */
-int read_object(struct vnode_info *vnodes, uint32_t epoch,
-               uint64_t oid, char *data, unsigned int datalen,
-               uint64_t offset, int nr_copies)
+int read_object(uint64_t oid, char *data,
+               unsigned int datalen, uint64_t offset)
 {
        struct sd_req hdr;
        struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
@@ -579,8 +577,7 @@ int read_object(struct vnode_info *vnodes, uint32_t epoch,
        int fd, ret;
 
        if (sys->enable_write_cache && object_is_cached(oid)) {
-               ret = object_cache_read(oid, data, datalen, offset,
-                                       nr_copies, epoch);
+               ret = object_cache_read(oid, data, datalen, offset);
                if (ret != SD_RES_SUCCESS) {
                        eprintf("try forward read %"PRIx64" %"PRIx32"\n",
                                oid, ret);
@@ -621,8 +618,7 @@ forward_read:
        return ret;
 }
 
-int remove_object(struct vnode_info *vnodes, uint32_t epoch,
-                 uint64_t oid, int nr)
+int remove_object(uint64_t oid)
 {
        struct sd_req hdr;
        struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
diff --git a/sheep/vdi.c b/sheep/vdi.c
index 76a7128..300cf89 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -56,9 +56,8 @@ static int create_vdi_obj(struct vnode_info *vnode_info, 
uint32_t epoch,
                nr_copies = copies;
 
        if (base_vid) {
-               ret = read_object(vnode_info, epoch,
-                                 vid_to_vdi_oid(base_vid), (char *)base,
-                                 sizeof(*base), 0, nr_copies);
+               ret = read_object(vid_to_vdi_oid(base_vid), (char *)base,
+                                 sizeof(*base), 0);
                if (ret != SD_RES_SUCCESS) {
                        ret = SD_RES_BASE_VDI_READ;
                        goto out;
@@ -72,9 +71,8 @@ static int create_vdi_obj(struct vnode_info *vnode_info, 
uint32_t epoch,
                        vprintf(SDOG_INFO, "tree snapshot %s %" PRIx32 " %" 
PRIx32 "\n",
                                name, cur_vid, base_vid);
 
-                       ret = read_object(vnode_info, epoch,
-                                         vid_to_vdi_oid(cur_vid), (char *)cur,
-                                         SD_INODE_HEADER_SIZE, 0, nr_copies);
+                       ret = read_object(vid_to_vdi_oid(cur_vid), (char *)cur,
+                                         SD_INODE_HEADER_SIZE, 0);
                        if (ret != SD_RES_SUCCESS) {
                                vprintf(SDOG_ERR, "failed\n");
                                ret = SD_RES_BASE_VDI_READ;
@@ -115,9 +113,8 @@ static int create_vdi_obj(struct vnode_info *vnode_info, 
uint32_t epoch,
        }
 
        if (is_snapshot && cur_vid != base_vid) {
-               ret = write_object(vnode_info, epoch,
-                                  vid_to_vdi_oid(cur_vid), (char *)cur,
-                                  SD_INODE_HEADER_SIZE, 0, 0, nr_copies, 0);
+               ret = write_object(vid_to_vdi_oid(cur_vid), (char *)cur,
+                                  SD_INODE_HEADER_SIZE, 0, 0, 0);
                if (ret != 0) {
                        vprintf(SDOG_ERR, "failed\n");
                        ret = SD_RES_BASE_VDI_READ;
@@ -126,9 +123,8 @@ static int create_vdi_obj(struct vnode_info *vnode_info, 
uint32_t epoch,
        }
 
        if (base_vid) {
-               ret = write_object(vnode_info, epoch,
-                                  vid_to_vdi_oid(base_vid), (char *)base,
-                                  SD_INODE_HEADER_SIZE, 0, 0, nr_copies, 0);
+               ret = write_object(vid_to_vdi_oid(base_vid), (char *)base,
+                                  SD_INODE_HEADER_SIZE, 0, 0, 0);
                if (ret != 0) {
                        vprintf(SDOG_ERR, "failed\n");
                        ret = SD_RES_BASE_VDI_WRITE;
@@ -136,9 +132,8 @@ static int create_vdi_obj(struct vnode_info *vnode_info, 
uint32_t epoch,
                }
        }
 
-       ret = write_object(vnode_info, epoch,
-                          vid_to_vdi_oid(new_vid), (char *)new, sizeof(*new),
-                          0, 0, nr_copies, 1);
+       ret = write_object(vid_to_vdi_oid(new_vid), (char *)new, sizeof(*new),
+                          0, 0, 1);
        if (ret != 0)
                ret = SD_RES_VDI_WRITE;
 
@@ -170,9 +165,8 @@ static int find_first_vdi(struct vnode_info *vnode_info, 
uint32_t epoch,
        nr_copies = get_nr_copies(vnode_info);
 
        for (i = start; i >= end; i--) {
-               ret = read_object(vnode_info, epoch,
-                                 vid_to_vdi_oid(i), (char *)inode,
-                                 SD_INODE_HEADER_SIZE, 0, nr_copies);
+               ret = read_object(vid_to_vdi_oid(i), (char *)inode,
+                                 SD_INODE_HEADER_SIZE, 0);
                if (ret != SD_RES_SUCCESS) {
                        ret = SD_RES_EIO;
                        goto out_free_inode;
@@ -406,8 +400,8 @@ static int delete_inode(struct deletion_work *dw)
 
        nr_copies = get_nr_copies(dw->vnodes);
 
-       ret = read_object(dw->vnodes, dw->epoch, vid_to_vdi_oid(dw->vid),
-                         (char *)inode, SD_INODE_HEADER_SIZE, 0, nr_copies);
+       ret = read_object(vid_to_vdi_oid(dw->vid), (char *)inode,
+                         SD_INODE_HEADER_SIZE, 0);
        if (ret != SD_RES_SUCCESS) {
                ret = SD_RES_EIO;
                goto out;
@@ -415,9 +409,8 @@ static int delete_inode(struct deletion_work *dw)
 
        memset(inode->name, 0, sizeof(inode->name));
 
-       ret = write_object(dw->vnodes, dw->epoch, vid_to_vdi_oid(dw->vid),
-                          (char *)inode, SD_INODE_HEADER_SIZE, 0, 0,
-                          nr_copies, 0);
+       ret = write_object(vid_to_vdi_oid(dw->vid),
+                          (char *)inode, SD_INODE_HEADER_SIZE, 0, 0, 0);
        if (ret != 0) {
                ret = SD_RES_EIO;
                goto out;
@@ -447,9 +440,8 @@ static void delete_one(struct work *work)
 
        nr_copies = get_nr_copies(dw->vnodes);
 
-       ret = read_object(dw->vnodes, dw->epoch, vid_to_vdi_oid(vdi_id),
-                         (void *)inode, sizeof(*inode),
-                         0, nr_copies);
+       ret = read_object(vid_to_vdi_oid(vdi_id),
+                         (void *)inode, sizeof(*inode), 0);
 
        if (ret != SD_RES_SUCCESS) {
                eprintf("cannot find VDI object\n");
@@ -469,9 +461,7 @@ static void delete_one(struct work *work)
                        continue;
                }
 
-               ret = remove_object(dw->vnodes, dw->epoch,
-                             vid_to_data_oid(inode->data_vdi_id[i], i),
-                             nr_copies);
+               ret = remove_object(vid_to_data_oid(inode->data_vdi_id[i], i));
 
                if (ret != SD_RES_SUCCESS)
                        dw->delete_error = 1;
@@ -486,8 +476,8 @@ static void delete_one(struct work *work)
        if (!dw->delete_error)
                memset(inode->name, 0, sizeof(inode->name));
 
-       write_object(dw->vnodes, dw->epoch, vid_to_vdi_oid(vdi_id),
-                    (void *)inode, sizeof(*inode), 0, 0, nr_copies, 0);
+       write_object(vid_to_vdi_oid(vdi_id), (void *)inode,
+                    sizeof(*inode), 0, 0, 0);
 out:
        free(inode);
 }
@@ -535,9 +525,8 @@ static int fill_vdi_list(struct deletion_work *dw, uint32_t 
root_vid)
        dw->buf[dw->count++] = root_vid;
 again:
        vid = dw->buf[done++];
-       ret = read_object(dw->vnodes, dw->epoch, vid_to_vdi_oid(vid),
-                         (char *)inode, SD_INODE_HEADER_SIZE, 0,
-                         nr_copies);
+       ret = read_object(vid_to_vdi_oid(vid), (char *)inode,
+                         SD_INODE_HEADER_SIZE, 0);
 
        if (ret != SD_RES_SUCCESS) {
                eprintf("cannot find VDI object\n");
@@ -564,12 +553,10 @@ out:
        return 1;
 }
 
-static uint64_t get_vdi_root(struct vnode_info *vnode_info, uint32_t epoch,
-               uint32_t vid, int *cloned)
+static uint64_t get_vdi_root(uint32_t vid, int *cloned)
 {
        int ret;
        struct sheepdog_inode *inode = NULL;
-       int nr_copies = get_nr_copies(vnode_info);
 
        *cloned = 0;
 
@@ -580,8 +567,8 @@ static uint64_t get_vdi_root(struct vnode_info *vnode_info, 
uint32_t epoch,
                goto out;
        }
 next:
-       ret = read_object(vnode_info, epoch, vid_to_vdi_oid(vid), (char *)inode,
-                         SD_INODE_HEADER_SIZE, 0, nr_copies);
+       ret = read_object(vid_to_vdi_oid(vid), (char *)inode,
+                         SD_INODE_HEADER_SIZE, 0);
 
        if (vid == inode->vdi_id && inode->snap_id == 1
                        && inode->parent_vdi_id != 0
@@ -634,7 +621,7 @@ static int start_deletion(struct vnode_info *vnode_info, 
uint32_t vid,
 
        dw->vnodes = vnode_info;
 
-       root_vid = get_vdi_root(dw->vnodes, dw->epoch, dw->vid, &cloned);
+       root_vid = get_vdi_root(dw->vid, &cloned);
        if (!root_vid) {
                ret = SD_RES_EIO;
                goto err;
@@ -711,13 +698,12 @@ int get_vdi_attr(struct vnode_info *vnode_info, uint32_t 
epoch,
        end = *attrid - 1;
        while (*attrid != end) {
                oid = vid_to_attr_oid(vid, *attrid);
-               ret = read_object(vnode_info, epoch, oid, (char *)&tmp_attr,
-                                 sizeof(tmp_attr), 0, nr_copies);
+               ret = read_object(oid, (char *)&tmp_attr,
+                                 sizeof(tmp_attr), 0);
 
                if (ret == SD_RES_NO_OBJ && wr) {
-                       ret = write_object(vnode_info, epoch, oid,
-                                          (char *)vattr, data_len, 0, 0,
-                                          nr_copies, 1);
+                       ret = write_object(oid, (char *)vattr, data_len,
+                                          0, 0, 1);
                        if (ret)
                                ret = SD_RES_EIO;
                        else
@@ -736,19 +722,16 @@ int get_vdi_attr(struct vnode_info *vnode_info, uint32_t 
epoch,
                        if (excl)
                                ret = SD_RES_VDI_EXIST;
                        else if (delete) {
-                               ret = write_object(vnode_info,
-                                                  epoch, oid, (char *)"", 1,
+                               ret = write_object(oid, (char *)"", 1,
                                                   offsetof(struct 
sheepdog_vdi_attr, name),
-                                                  0, nr_copies, 0);
+                                                  0, 0);
                                if (ret)
                                        ret = SD_RES_EIO;
                                else
                                        ret = SD_RES_SUCCESS;
                        } else if (wr) {
-                               ret = write_object(vnode_info,
-                                                  epoch, oid, (char *)vattr,
-                                                  SD_ATTR_OBJ_SIZE, 0, 0,
-                                                  nr_copies, 0);
+                               ret = write_object(oid, (char *)vattr,
+                                                  SD_ATTR_OBJ_SIZE, 0, 0, 0);
 
                                if (ret)
                                        ret = SD_RES_EIO;
-- 
1.7.10

-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to