[sheepdog] [PATCH V2] sheep: rename ->vnodes which type is vnode_info to ->vinfo
Yunkai Zhang
yunkai.me at gmail.com
Sun Aug 5 08:38:22 CEST 2012
From: Yunkai Zhang <qiushu.zyk at taobao.com>
V2:
- cleanup more places as possible as I can.
Note:
- this patch based on my two previous patches:
1) sheep: refactor oid_to_vnode[s] and cleanup obj_to_sheep[s]
2) sheep: refactor get_nth_node() and get_vnode_pos()
------------------------------------------------------ >8
The type of request->vnodes is vnode_info, let's rename it to ->vinfo which
will be more descriptive.
Cleanup other places as possible as I can according this naming rule.
Signed-off-by: Yunkai Zhang <qiushu.zyk at taobao.com>
---
sheep/farm/trunk.c | 10 +++++-----
sheep/gateway.c | 8 ++++----
sheep/ops.c | 2 +-
sheep/recovery.c | 32 ++++++++++++++++----------------
sheep/request.c | 12 ++++++------
sheep/sheep_priv.h | 7 +++----
6 files changed, 35 insertions(+), 36 deletions(-)
diff --git a/sheep/farm/trunk.c b/sheep/farm/trunk.c
index 6b5971b..cd1fd20 100644
--- a/sheep/farm/trunk.c
+++ b/sheep/farm/trunk.c
@@ -239,15 +239,15 @@ static unsigned char *omap_tree_insert(uint64_t oid, unsigned char *sha1)
static int oid_stale(uint64_t oid)
{
int i, nr_copies;
- struct vnode_info *vnodes;
+ struct vnode_info *vinfo;
struct sd_vnode *v;
int ret = 1;
struct sd_vnode *obj_vnodes[SD_MAX_COPIES];
- vnodes = get_vnode_info();
- nr_copies = get_nr_copies(vnodes);
+ vinfo = get_vnode_info();
+ nr_copies = get_nr_copies(vinfo);
- oid_to_vnodes(vnodes->vnodes, vnodes->nr_vnodes, oid,
+ oid_to_vnodes(vinfo->vnodes, vinfo->nr_vnodes, oid,
nr_copies, obj_vnodes);
for (i = 0; i < nr_copies; i++) {
v = obj_vnodes[i];
@@ -257,7 +257,7 @@ static int oid_stale(uint64_t oid)
}
}
- put_vnode_info(vnodes);
+ put_vnode_info(vinfo);
return ret;
}
diff --git a/sheep/gateway.c b/sheep/gateway.c
index fe7ef2d..382dc7c 100644
--- a/sheep/gateway.c
+++ b/sheep/gateway.c
@@ -35,8 +35,8 @@ int gateway_read_obj(struct request *req)
if (sys->enable_write_cache && !req->local && !bypass_object_cache(req))
return object_cache_handle_request(req);
- nr_copies = get_nr_copies(req->vnodes);
- oid_to_vnodes(req->vnodes->vnodes, req->vnodes->nr_vnodes, oid,
+ nr_copies = get_nr_copies(req->vinfo);
+ oid_to_vnodes(req->vinfo->vnodes, req->vinfo->nr_vnodes, oid,
nr_copies, obj_vnodes);
for (i = 0; i < nr_copies; i++) {
v = obj_vnodes[i];
@@ -245,8 +245,8 @@ static int gateway_forward_request(struct request *req)
write_info_init(&wi);
wlen = hdr.data_length;
- nr_copies = get_nr_copies(req->vnodes);
- oid_to_vnodes(req->vnodes->vnodes, req->vnodes->nr_vnodes, oid,
+ nr_copies = get_nr_copies(req->vinfo);
+ oid_to_vnodes(req->vinfo->vnodes, req->vinfo->nr_vnodes, oid,
nr_copies, obj_vnodes);
for (i = 0; i < nr_copies; i++) {
diff --git a/sheep/ops.c b/sheep/ops.c
index 861d449..2210173 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -815,7 +815,7 @@ int peer_create_and_write_obj(struct request *req)
goto out;
}
if (hdr->data_length != SD_DATA_OBJ_SIZE) {
- ret = read_copy_from_replica(req->vnodes, hdr->epoch,
+ ret = read_copy_from_replica(req->vinfo, hdr->epoch,
hdr->obj.cow_oid, buf);
if (ret != SD_RES_SUCCESS) {
eprintf("failed to read cow object\n");
diff --git a/sheep/recovery.c b/sheep/recovery.c
index 080a4b8..5164aa7 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -36,8 +36,8 @@ struct recovery_work {
uint64_t *prio_oids;
int nr_prio_oids;
- struct vnode_info *old_vnodes;
- struct vnode_info *cur_vnodes;
+ struct vnode_info *old_vinfo;
+ struct vnode_info *cur_vinfo;
};
static struct recovery_work *next_rw;
@@ -165,7 +165,7 @@ static int do_recover_object(struct recovery_work *rw)
uint32_t epoch = rw->epoch, tgt_epoch = rw->epoch - 1;
int nr_copies, ret, i;
- old = grab_vnode_info(rw->old_vnodes);
+ old = grab_vnode_info(rw->old_vinfo);
again:
dprintf("try recover object %"PRIx64" from epoch %"PRIu32"\n",
@@ -178,8 +178,8 @@ again:
old->nr_vnodes,
oid, i);
- if (is_invalid_vnode(tgt_vnode, rw->cur_vnodes->nodes,
- rw->cur_vnodes->nr_nodes))
+ if (is_invalid_vnode(tgt_vnode, rw->cur_vinfo->nodes,
+ rw->cur_vinfo->nr_nodes))
continue;
ret = recover_object_from_replica(oid, tgt_vnode,
epoch, tgt_epoch);
@@ -320,8 +320,8 @@ bool oid_in_recovery(uint64_t oid)
static void free_recovery_work(struct recovery_work *rw)
{
- put_vnode_info(rw->cur_vnodes);
- put_vnode_info(rw->old_vnodes);
+ put_vnode_info(rw->cur_vinfo);
+ put_vnode_info(rw->old_vinfo);
free(rw->oids);
free(rw);
}
@@ -343,7 +343,7 @@ static inline void finish_recovery(struct recovery_work *rw)
sys->recovered_epoch = rw->epoch;
if (sd_store->end_recover)
- sd_store->end_recover(sys->epoch - 1, rw->old_vnodes);
+ sd_store->end_recover(sys->epoch - 1, rw->old_vinfo);
free_recovery_work(rw);
@@ -515,9 +515,9 @@ static void screen_object_list(struct recovery_work *rw,
int nr_objs;
int i, j;
- nr_objs = get_nr_copies(rw->cur_vnodes);
+ nr_objs = get_nr_copies(rw->cur_vinfo);
for (i = 0; i < nr_oids; i++) {
- oid_to_vnodes(rw->cur_vnodes->vnodes, rw->cur_vnodes->nr_vnodes,
+ oid_to_vnodes(rw->cur_vinfo->vnodes, rw->cur_vinfo->nr_vnodes,
oids[i], nr_objs, vnodes);
for (j = 0; j < nr_objs; j++) {
if (!vnode_is_local(vnodes[j]))
@@ -536,7 +536,7 @@ static void screen_object_list(struct recovery_work *rw,
static int newly_joined(struct sd_node *node, struct recovery_work *rw)
{
- if (bsearch(node, rw->old_vnodes->nodes, rw->old_vnodes->nr_nodes,
+ if (bsearch(node, rw->old_vinfo->nodes, rw->old_vinfo->nr_nodes,
sizeof(struct sd_node), node_id_cmp))
return 0;
return 1;
@@ -549,8 +549,8 @@ static void prepare_object_list(struct work *work)
work);
uint8_t *buf = NULL;
size_t buf_size = SD_DATA_OBJ_SIZE; /* FIXME */
- struct sd_node *cur = rw->cur_vnodes->nodes;
- int cur_nr = rw->cur_vnodes->nr_nodes;
+ struct sd_node *cur = rw->cur_vinfo->nodes;
+ int cur_nr = rw->cur_vinfo->nr_nodes;
int start = random() % cur_nr, i, end = cur_nr;
dprintf("%u\n", rw->epoch);
@@ -592,7 +592,7 @@ static inline bool node_is_gateway_only(void)
return sys->this_node.nr_vnodes == 0 ? true : false;
}
-int start_recovery(struct vnode_info *cur_vnodes, struct vnode_info *old_vnodes)
+int start_recovery(struct vnode_info *cur_vinfo, struct vnode_info *old_vinfo)
{
struct recovery_work *rw;
@@ -610,8 +610,8 @@ int start_recovery(struct vnode_info *cur_vnodes, struct vnode_info *old_vnodes)
rw->epoch = sys->epoch;
rw->count = 0;
- rw->cur_vnodes = grab_vnode_info(cur_vnodes);
- rw->old_vnodes = grab_vnode_info(old_vnodes);
+ rw->cur_vinfo = grab_vnode_info(cur_vinfo);
+ rw->old_vinfo = grab_vnode_info(old_vinfo);
rw->work.fn = prepare_object_list;
rw->work.done = finish_object_list;
diff --git a/sheep/request.c b/sheep/request.c
index a673a63..ab7c63a 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -30,8 +30,8 @@ static int is_access_local(struct request *req, uint64_t oid)
int nr_copies;
int i;
- nr_copies = get_nr_copies(req->vnodes);
- oid_to_vnodes(req->vnodes->vnodes, req->vnodes->nr_vnodes, oid,
+ nr_copies = get_nr_copies(req->vinfo);
+ oid_to_vnodes(req->vinfo->vnodes, req->vinfo->nr_vnodes, oid,
nr_copies, obj_vnodes);
for (i = 0; i < nr_copies; i++) {
@@ -365,7 +365,7 @@ static void queue_request(struct request *req)
* called before we set up current_vnode_info
*/
if (!is_force_op(req->op))
- req->vnodes = get_vnode_info();
+ req->vinfo = get_vnode_info();
if (is_peer_op(req->op)) {
queue_peer_request(req);
@@ -391,8 +391,8 @@ done:
static void requeue_request(struct request *req)
{
- if (req->vnodes)
- put_vnode_info(req->vnodes);
+ if (req->vinfo)
+ put_vnode_info(req->vinfo);
queue_request(req);
}
@@ -479,7 +479,7 @@ static void free_request(struct request *req)
uatomic_dec(&sys->nr_outstanding_reqs);
req->ci->refcnt--;
- put_vnode_info(req->vnodes);
+ put_vnode_info(req->vinfo);
free(req->data);
free(req);
}
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 201d322..6f667ee 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -57,7 +57,7 @@ struct request {
uint64_t local_oid;
- struct vnode_info *vnodes;
+ struct vnode_info *vinfo;
struct work work;
};
@@ -214,7 +214,7 @@ struct vnode_info *grab_vnode_info(struct vnode_info *vnode_info);
struct vnode_info *get_vnode_info(void);
void update_vnode_info(struct vnode_info *vnode_info);
struct vnode_info *alloc_vnode_info(struct sd_node *nodes, size_t nr_nodes);
-void put_vnode_info(struct vnode_info *vnodes);
+void put_vnode_info(struct vnode_info *vinfo);
struct vnode_info *get_vnode_info_epoch(uint32_t epoch);
int get_nr_copies(struct vnode_info *vnode_info);
@@ -253,8 +253,7 @@ uint64_t get_cluster_ctime(void);
int get_obj_list(const struct sd_list_req *, struct sd_list_rsp *, void *);
int objlist_cache_cleanup(uint32_t vid);
-int start_recovery(struct vnode_info *cur_vnodes,
- struct vnode_info *old_vnodes);
+int start_recovery(struct vnode_info *cur_vinfo, struct vnode_info *old_vinfo);
void resume_recovery_work(void);
bool oid_in_recovery(uint64_t oid);
int is_recovery_init(void);
--
1.7.11.2
More information about the sheepdog
mailing list