[Sheepdog] [PATCH] sheep: rename sheepdog_{, v}node_list_entry into sd_{, v}node
Liu Yuan
namei.unix at gmail.com
Wed Dec 21 05:03:22 CET 2011
From: Liu Yuan <tailai.ly at taobao.com>
This naming mostly force us to use multiple lines for function paras.
We'd better have them terse.
This patch is generated by utility 'find & sed'.
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
collie/cluster.c | 2 +-
collie/collie.c | 6 ++--
collie/collie.h | 4 +-
include/sheep.h | 32 ++++++++++----------
sheep/cluster.h | 16 +++++-----
sheep/cluster/accord.c | 20 ++++++------
sheep/cluster/corosync.c | 12 ++++----
sheep/cluster/local.c | 20 ++++++------
sheep/cluster/zookeeper.c | 20 ++++++------
sheep/group.c | 72 ++++++++++++++++++++++----------------------
sheep/ops.c | 6 ++--
sheep/sdnet.c | 8 ++--
sheep/sheep_priv.h | 24 +++++++-------
sheep/store.c | 62 +++++++++++++++++++-------------------
sheep/vdi.c | 16 +++++-----
15 files changed, 160 insertions(+), 160 deletions(-)
diff --git a/collie/cluster.c b/collie/cluster.c
index f0284ae..6fbda6b 100644
--- a/collie/cluster.c
+++ b/collie/cluster.c
@@ -117,7 +117,7 @@ static int cluster_info(int argc, char **argv)
for (i = 0; i < nr_logs; i++) {
int j;
char name[128];
- struct sheepdog_node_list_entry *entry;
+ struct sd_node *entry;
ti = logs[i].time;
if (raw_output) {
diff --git a/collie/collie.c b/collie/collie.c
index 408f98d..19cc9a9 100644
--- a/collie/collie.c
+++ b/collie/collie.c
@@ -52,8 +52,8 @@ static void usage(struct command *commands, int status);
uint64_t node_list_version;
-struct sheepdog_node_list_entry node_list_entries[SD_MAX_NODES];
-struct sheepdog_vnode_list_entry vnode_list_entries[SD_MAX_VNODES];
+struct sd_node node_list_entries[SD_MAX_NODES];
+struct sd_vnode vnode_list_entries[SD_MAX_VNODES];
int nr_nodes, nr_vnodes;
unsigned master_idx;
@@ -62,7 +62,7 @@ static int update_node_list(int max_nodes, int epoch)
int fd, ret;
unsigned int size, wlen;
char *buf = NULL;
- struct sheepdog_node_list_entry *ent;
+ struct sd_node *ent;
struct sd_node_req hdr;
struct sd_node_rsp *rsp = (struct sd_node_rsp *)&hdr;
diff --git a/collie/collie.h b/collie/collie.h
index b814751..85a1289 100644
--- a/collie/collie.h
+++ b/collie/collie.h
@@ -54,8 +54,8 @@ extern int highlight;
extern int raw_output;
extern uint64_t node_list_version;
-extern struct sheepdog_node_list_entry node_list_entries[SD_MAX_NODES];
-extern struct sheepdog_vnode_list_entry vnode_list_entries[SD_MAX_VNODES];
+extern struct sd_node node_list_entries[SD_MAX_NODES];
+extern struct sd_vnode vnode_list_entries[SD_MAX_VNODES];
extern int nr_nodes, nr_vnodes;
extern unsigned master_idx;
diff --git a/include/sheep.h b/include/sheep.h
index c4a1c14..906c1f5 100644
--- a/include/sheep.h
+++ b/include/sheep.h
@@ -137,14 +137,14 @@ struct sd_node_rsp {
uint64_t store_free;
};
-struct sheepdog_node_list_entry {
+struct sd_node {
uint8_t addr[16];
uint16_t port;
uint16_t nr_vnodes;
uint32_t zone;
};
-struct sheepdog_vnode_list_entry {
+struct sd_vnode {
uint64_t id;
uint8_t addr[16];
uint16_t port;
@@ -157,10 +157,10 @@ struct epoch_log {
uint64_t time;
uint32_t epoch;
uint32_t nr_nodes;
- struct sheepdog_node_list_entry nodes[SD_MAX_NODES];
+ struct sd_node nodes[SD_MAX_NODES];
};
-static inline int same_node(struct sheepdog_vnode_list_entry *e, int n1, int n2)
+static inline int same_node(struct sd_vnode *e, int n1, int n2)
{
if (memcmp(e[n1].addr, e[n2].addr, sizeof(e->addr)) == 0 &&
e[n1].port == e[n2].port)
@@ -169,13 +169,13 @@ static inline int same_node(struct sheepdog_vnode_list_entry *e, int n1, int n2)
return 0;
}
-static inline int same_zone(struct sheepdog_vnode_list_entry *e, int n1, int n2)
+static inline int same_zone(struct sd_vnode *e, int n1, int n2)
{
return e[n1].zone != 0 && e[n1].zone == e[n2].zone;
}
/* traverse the virtual node list and return the n'th one */
-static inline int get_nth_node(struct sheepdog_vnode_list_entry *entries,
+static inline int get_nth_node(struct sd_vnode *entries,
int nr_entries, int base, int n)
{
int nodes[SD_MAX_REDUNDANCY];
@@ -201,11 +201,11 @@ next:
return idx;
}
-static inline int hval_to_sheep(struct sheepdog_vnode_list_entry *entries,
+static inline int hval_to_sheep(struct sd_vnode *entries,
int nr_entries, uint64_t id, int idx)
{
int i;
- struct sheepdog_vnode_list_entry *e = entries, *n;
+ struct sd_vnode *e = entries, *n;
for (i = 0; i < nr_entries - 1; i++, e++) {
n = e + 1;
@@ -215,7 +215,7 @@ static inline int hval_to_sheep(struct sheepdog_vnode_list_entry *entries,
return get_nth_node(entries, nr_entries, (i + 1) % nr_entries, idx);
}
-static inline int obj_to_sheep(struct sheepdog_vnode_list_entry *entries,
+static inline int obj_to_sheep(struct sd_vnode *entries,
int nr_entries, uint64_t oid, int idx)
{
uint64_t id = fnv_64a_buf(&oid, sizeof(oid), FNV1A_64_INIT);
@@ -280,8 +280,8 @@ static inline const char *sd_strerror(int err)
static inline int node_cmp(const void *a, const void *b)
{
- const struct sheepdog_node_list_entry *node1 = a;
- const struct sheepdog_node_list_entry *node2 = b;
+ const struct sd_node *node1 = a;
+ const struct sd_node *node2 = b;
int cmp;
cmp = memcmp(node1->addr, node2->addr, sizeof(node1->addr));
@@ -297,8 +297,8 @@ static inline int node_cmp(const void *a, const void *b)
static inline int vnode_cmp(const void *a, const void *b)
{
- const struct sheepdog_vnode_list_entry *node1 = a;
- const struct sheepdog_vnode_list_entry *node2 = b;
+ const struct sd_vnode *node1 = a;
+ const struct sd_vnode *node2 = b;
if (node1->id < node2->id)
return -1;
@@ -307,10 +307,10 @@ static inline int vnode_cmp(const void *a, const void *b)
return 0;
}
-static inline int nodes_to_vnodes(struct sheepdog_node_list_entry *nodes, int nr,
- struct sheepdog_vnode_list_entry *vnodes)
+static inline int nodes_to_vnodes(struct sd_node *nodes, int nr,
+ struct sd_vnode *vnodes)
{
- struct sheepdog_node_list_entry *n = nodes;
+ struct sd_node *n = nodes;
int i, j, nr_vnodes = 0;
uint64_t hval;
diff --git a/sheep/cluster.h b/sheep/cluster.h
index 352a844..b50dbb2 100644
--- a/sheep/cluster.h
+++ b/sheep/cluster.h
@@ -32,14 +32,14 @@ enum cluster_join_result {
};
struct cdrv_handlers {
- void (*join_handler)(struct sheepdog_node_list_entry *joined,
- struct sheepdog_node_list_entry *members,
+ void (*join_handler)(struct sd_node *joined,
+ struct sd_node *members,
size_t nr_members, enum cluster_join_result result,
void *opaque);
- void (*leave_handler)(struct sheepdog_node_list_entry *left,
- struct sheepdog_node_list_entry *members,
+ void (*leave_handler)(struct sd_node *left,
+ struct sd_node *members,
size_t nr_members);
- void (*notify_handler)(struct sheepdog_node_list_entry *sender,
+ void (*notify_handler)(struct sd_node *sender,
void *msg, size_t msg_len);
};
@@ -69,9 +69,9 @@ struct cluster_driver {
*
* Returns zero on success, -1 on error
*/
- int (*join)(struct sheepdog_node_list_entry *myself,
+ int (*join)(struct sd_node *myself,
enum cluster_join_result (*check_join_cb)(
- struct sheepdog_node_list_entry *joining,
+ struct sd_node *joining,
void *opaque),
void *opaque, size_t opaque_len);
@@ -157,7 +157,7 @@ static inline const char *get_cdrv_option(struct cluster_driver *cdrv,
return NULL;
}
-static inline char *node_to_str(struct sheepdog_node_list_entry *id)
+static inline char *node_to_str(struct sd_node *id)
{
static char str[256];
char name[256];
diff --git a/sheep/cluster/accord.c b/sheep/cluster/accord.c
index a685f9e..17a0a63 100644
--- a/sheep/cluster/accord.c
+++ b/sheep/cluster/accord.c
@@ -35,13 +35,13 @@ enum acrd_event_type {
struct acrd_event {
enum acrd_event_type type;
- struct sheepdog_node_list_entry sender;
+ struct sd_node sender;
size_t buf_len;
uint8_t buf[MAX_EVENT_BUF_SIZE];
size_t nr_nodes; /* the number of sheep */
- struct sheepdog_node_list_entry nodes[SD_MAX_NODES];
+ struct sd_node nodes[SD_MAX_NODES];
uint64_t ids[SD_MAX_NODES];
enum cluster_join_result join_result;
@@ -52,7 +52,7 @@ struct acrd_event {
int callbacked; /* set non-zero if sheep already called block_cb() */
};
-static struct sheepdog_node_list_entry this_node;
+static struct sd_node this_node;
static uint64_t this_id;
@@ -219,11 +219,11 @@ static struct work_queue *acrd_wq;
static struct cdrv_handlers acrd_hdlrs;
static enum cluster_join_result (*acrd_check_join_cb)(
- struct sheepdog_node_list_entry *joining, void *opaque);
+ struct sd_node *joining, void *opaque);
/* get node list from the last pushed data */
static size_t get_nodes(struct acrd_handle *ah,
- struct sheepdog_node_list_entry *nodes,
+ struct sd_node *nodes,
uint64_t *ids)
{
int rc;
@@ -249,11 +249,11 @@ again:
}
static int add_event(struct acrd_handle *ah, enum acrd_event_type type,
- struct sheepdog_node_list_entry *node, void *buf,
+ struct sd_node *node, void *buf,
size_t buf_len, void (*block_cb)(void *arg))
{
int idx;
- struct sheepdog_node_list_entry *n;
+ struct sd_node *n;
uint64_t *i;
struct acrd_event ev;
@@ -398,7 +398,7 @@ static void __acrd_leave(struct work *work, int idx)
int i;
size_t nr_nodes;
uint64_t ids[SD_MAX_NODES];
- struct sheepdog_node_list_entry nodes[SD_MAX_NODES];
+ struct sd_node nodes[SD_MAX_NODES];
struct acrd_tx *atx;
pthread_mutex_lock(&queue_lock);
@@ -514,9 +514,9 @@ static int accord_init(struct cdrv_handlers *handlers, const char *option,
return efd;
}
-static int accord_join(struct sheepdog_node_list_entry *myself,
+static int accord_join(struct sd_node *myself,
enum cluster_join_result (*check_join_cb)(
- struct sheepdog_node_list_entry *joining,
+ struct sd_node *joining,
void *opaque),
void *opaque, size_t opaque_len)
{
diff --git a/sheep/cluster/corosync.c b/sheep/cluster/corosync.c
index 4fe7704..9ff0651 100644
--- a/sheep/cluster/corosync.c
+++ b/sheep/cluster/corosync.c
@@ -20,7 +20,7 @@ struct cpg_node {
uint32_t nodeid;
uint32_t pid;
uint32_t gone;
- struct sheepdog_node_list_entry ent;
+ struct sd_node ent;
};
static cpg_handle_t cpg_handle;
@@ -33,7 +33,7 @@ static struct work_queue *corosync_block_wq;
static struct cdrv_handlers corosync_handlers;
static enum cluster_join_result (*corosync_check_join_cb)(
- struct sheepdog_node_list_entry *joining, void *opaque);
+ struct sd_node *joining, void *opaque);
static LIST_HEAD(corosync_event_list);
static LIST_HEAD(corosync_block_list);
@@ -265,7 +265,7 @@ static int is_master(struct cpg_node *node)
}
static void build_node_list(struct cpg_node *nodes, size_t nr_nodes,
- struct sheepdog_node_list_entry *entries)
+ struct sd_node *entries)
{
int i;
@@ -282,7 +282,7 @@ static int __corosync_dispatch_one(struct corosync_event *cevent)
{
struct corosync_block_msg *bm;
enum cluster_join_result res;
- struct sheepdog_node_list_entry entries[SD_MAX_NODES];
+ struct sd_node entries[SD_MAX_NODES];
int idx;
switch (cevent->type) {
@@ -669,9 +669,9 @@ static int corosync_init(struct cdrv_handlers *handlers, const char *option,
return fd;
}
-static int corosync_join(struct sheepdog_node_list_entry *myself,
+static int corosync_join(struct sd_node *myself,
enum cluster_join_result (*check_join_cb)(
- struct sheepdog_node_list_entry *joining,
+ struct sd_node *joining,
void *opaque),
void *opaque, size_t opaque_len)
{
diff --git a/sheep/cluster/local.c b/sheep/cluster/local.c
index 84d4bb0..b371a44 100644
--- a/sheep/cluster/local.c
+++ b/sheep/cluster/local.c
@@ -30,13 +30,13 @@ const char *shmfile = "/tmp/sheepdog_shm";
static int shmfd;
static int sigfd;
static int event_pos;
-static struct sheepdog_node_list_entry this_node;
+static struct sd_node this_node;
static struct work_queue *local_block_wq;
static struct cdrv_handlers lhdlrs;
static enum cluster_join_result (*local_check_join_cb)(
- struct sheepdog_node_list_entry *joining, void *opaque);
+ struct sd_node *joining, void *opaque);
enum local_event_type {
EVENT_JOIN = 1,
@@ -46,13 +46,13 @@ enum local_event_type {
struct local_event {
enum local_event_type type;
- struct sheepdog_node_list_entry sender;
+ struct sd_node sender;
size_t buf_len;
uint8_t buf[MAX_EVENT_BUF_SIZE];
size_t nr_nodes; /* the number of sheep processes */
- struct sheepdog_node_list_entry nodes[SD_MAX_NODES];
+ struct sd_node nodes[SD_MAX_NODES];
pid_t pids[SD_MAX_NODES];
enum cluster_join_result join_result;
@@ -88,7 +88,7 @@ static int shm_queue_empty(void)
return event_pos == shm_queue->pos;
}
-static size_t get_nodes(struct sheepdog_node_list_entry *n, pid_t *p)
+static size_t get_nodes(struct sd_node *n, pid_t *p)
{
struct local_event *ev;
@@ -218,11 +218,11 @@ static void shm_queue_init(void)
}
static void add_event(enum local_event_type type,
- struct sheepdog_node_list_entry *node, void *buf,
+ struct sd_node *node, void *buf,
size_t buf_len, void (*block_cb)(void *arg))
{
int idx;
- struct sheepdog_node_list_entry *n;
+ struct sd_node *n;
pid_t *p;
struct local_event ev = {
.type = type,
@@ -268,7 +268,7 @@ static void check_pids(void *arg)
{
int i;
size_t nr;
- struct sheepdog_node_list_entry nodes[SD_MAX_NODES];
+ struct sd_node nodes[SD_MAX_NODES];
pid_t pids[SD_MAX_NODES];
shm_queue_lock();
@@ -324,9 +324,9 @@ static int local_init(struct cdrv_handlers *handlers, const char *option,
return sigfd;
}
-static int local_join(struct sheepdog_node_list_entry *myself,
+static int local_join(struct sd_node *myself,
enum cluster_join_result (*check_join_cb)(
- struct sheepdog_node_list_entry *joining,
+ struct sd_node *joining,
void *opaque),
void *opaque, size_t opaque_len)
{
diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index 7717b6b..5230a03 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -44,13 +44,13 @@ enum zk_event_type {
struct zk_event {
enum zk_event_type type;
- struct sheepdog_node_list_entry sender;
+ struct sd_node sender;
size_t buf_len;
uint8_t buf[MAX_EVENT_BUF_SIZE];
size_t nr_nodes; /* the number of sheep */
- struct sheepdog_node_list_entry nodes[SD_MAX_NODES];
+ struct sd_node nodes[SD_MAX_NODES];
enum cluster_join_result join_result;
@@ -220,14 +220,14 @@ static int efd;
static struct work_queue *zk_block_wq;
-static struct sheepdog_node_list_entry this_node;
+static struct sd_node this_node;
static struct cdrv_handlers zk_hdlrs;
static enum cluster_join_result (*zk_check_join_cb)(
- struct sheepdog_node_list_entry *joining, void *opaque);
+ struct sd_node *joining, void *opaque);
/* get node list from the last pushed data */
-static size_t get_nodes(zhandle_t *zh, struct sheepdog_node_list_entry *nodes)
+static size_t get_nodes(zhandle_t *zh, struct sd_node *nodes)
{
int rc, len;
struct zk_event ev;
@@ -252,11 +252,11 @@ static size_t get_nodes(zhandle_t *zh, struct sheepdog_node_list_entry *nodes)
}
static int add_event(zhandle_t *zh, enum zk_event_type type,
- struct sheepdog_node_list_entry *node, void *buf,
+ struct sd_node *node, void *buf,
size_t buf_len, void (*block_cb)(void *arg))
{
int idx;
- struct sheepdog_node_list_entry *n;
+ struct sd_node *n;
struct zk_event ev;
zk_lock(zh);
@@ -303,7 +303,7 @@ static void watcher(zhandle_t *zh, int type, int state, const char *path, void*
char str[256];
int ret, i;
size_t nr_nodes;
- struct sheepdog_node_list_entry nodes[SD_MAX_NODES];
+ struct sd_node nodes[SD_MAX_NODES];
if (type == ZOO_DELETED_EVENT) {
ret = sscanf(path, MEMBER_ZNODE "/%[^\n]", str);
@@ -408,9 +408,9 @@ static int zk_init(struct cdrv_handlers *handlers, const char *option,
return efd;
}
-static int zk_join(struct sheepdog_node_list_entry *myself,
+static int zk_join(struct sd_node *myself,
enum cluster_join_result (*check_join_cb)(
- struct sheepdog_node_list_entry *joining,
+ struct sd_node *joining,
void *opaque),
void *opaque, size_t opaque_len)
{
diff --git a/sheep/group.c b/sheep/group.c
index 2c075c5..1a1233f 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -29,7 +29,7 @@ static int cdrv_fd;
static struct coroutine *cdrv_co;
struct node {
- struct sheepdog_node_list_entry ent;
+ struct sd_node ent;
struct list_head list;
};
@@ -46,8 +46,8 @@ struct join_message {
uint8_t inc_epoch; /* set non-zero when we increment epoch of all nodes */
uint8_t pad[3];
union {
- struct sheepdog_node_list_entry nodes[0];
- struct sheepdog_node_list_entry leave_nodes[0];
+ struct sd_node nodes[0];
+ struct sd_node leave_nodes[0];
};
};
@@ -60,7 +60,7 @@ struct vdi_op_message {
struct work_notify {
struct cpg_event cev;
- struct sheepdog_node_list_entry sender;
+ struct sd_node sender;
struct request *req;
void *msg;
@@ -69,9 +69,9 @@ struct work_notify {
struct work_join {
struct cpg_event cev;
- struct sheepdog_node_list_entry *member_list;
+ struct sd_node *member_list;
size_t member_list_entries;
- struct sheepdog_node_list_entry joined;
+ struct sd_node joined;
struct join_message *jm;
};
@@ -79,9 +79,9 @@ struct work_join {
struct work_leave {
struct cpg_event cev;
- struct sheepdog_node_list_entry *member_list;
+ struct sd_node *member_list;
size_t member_list_entries;
- struct sheepdog_node_list_entry left;
+ struct sd_node left;
};
#define print_node_list(nodes, nr_nodes) \
@@ -106,7 +106,7 @@ static size_t get_join_message_size(struct join_message *jm)
return sizeof(*jm) + jm->nr_nodes * sizeof(jm->nodes[0]);
}
-int get_zones_nr_from(struct sheepdog_node_list_entry *nodes, int nr_nodes)
+int get_zones_nr_from(struct sd_node *nodes, int nr_nodes)
{
int nr_zones = 0, i, j;
uint32_t zones[SD_MAX_REDUNDANCY];
@@ -127,7 +127,7 @@ int get_zones_nr_from(struct sheepdog_node_list_entry *nodes, int nr_nodes)
}
struct vnodes_cache {
- struct sheepdog_vnode_list_entry vnodes[SD_MAX_VNODES];
+ struct sd_vnode vnodes[SD_MAX_VNODES];
int nr_vnodes;
int nr_zones;
uint32_t epoch;
@@ -136,7 +136,7 @@ struct vnodes_cache {
struct list_head list;
};
-int get_ordered_sd_vnode_list(struct sheepdog_vnode_list_entry **entries,
+int get_ordered_sd_vnode_list(struct sd_vnode **entries,
int *nr_vnodes, int *nr_zones)
{
static LIST_HEAD(vnodes_list);
@@ -175,7 +175,7 @@ int get_ordered_sd_vnode_list(struct sheepdog_vnode_list_entry **entries,
return SD_RES_SUCCESS;
}
-void free_ordered_sd_vnode_list(struct sheepdog_vnode_list_entry *entries)
+void free_ordered_sd_vnode_list(struct sd_vnode *entries)
{
struct vnodes_cache *cache;
@@ -279,7 +279,7 @@ static inline int get_nodes_nr_from(struct list_head *l)
static int get_nodes_nr_epoch(int epoch)
{
- struct sheepdog_node_list_entry nodes[SD_MAX_NODES];
+ struct sd_node nodes[SD_MAX_NODES];
int nr;
nr = epoch_log_read(epoch, (char *)nodes, sizeof(nodes));
@@ -287,7 +287,7 @@ static int get_nodes_nr_epoch(int epoch)
return nr;
}
-static struct sheepdog_node_list_entry *find_entry_list(struct sheepdog_node_list_entry *entry,
+static struct sd_node *find_entry_list(struct sd_node *entry,
struct list_head *head)
{
struct node *n;
@@ -299,10 +299,10 @@ static struct sheepdog_node_list_entry *find_entry_list(struct sheepdog_node_lis
}
-static struct sheepdog_node_list_entry *find_entry_epoch(struct sheepdog_node_list_entry *entry,
+static struct sd_node *find_entry_epoch(struct sd_node *entry,
int epoch)
{
- struct sheepdog_node_list_entry nodes[SD_MAX_NODES];
+ struct sd_node nodes[SD_MAX_NODES];
int nr, i;
nr = epoch_log_read_nr(epoch, (char *)nodes, sizeof(nodes));
@@ -314,11 +314,11 @@ static struct sheepdog_node_list_entry *find_entry_epoch(struct sheepdog_node_li
return NULL;
}
-static int cluster_sanity_check(struct sheepdog_node_list_entry *entries,
+static int cluster_sanity_check(struct sd_node *entries,
int nr_entries, uint64_t ctime, uint32_t epoch)
{
int ret = SD_RES_SUCCESS, nr_local_entries;
- struct sheepdog_node_list_entry local_entries[SD_MAX_NODES];
+ struct sd_node local_entries[SD_MAX_NODES];
uint32_t lepoch;
if (sys_stat_wait_format() || sys_stat_shutdown())
@@ -359,14 +359,14 @@ out:
return ret;
}
-static int get_cluster_status(struct sheepdog_node_list_entry *from,
- struct sheepdog_node_list_entry *entries,
+static int get_cluster_status(struct sd_node *from,
+ struct sd_node *entries,
int nr_entries, uint64_t ctime, uint32_t epoch,
uint32_t *status, uint8_t *inc_epoch)
{
int i, j, ret = SD_RES_SUCCESS;
int nr, nr_local_entries, nr_leave_entries;
- struct sheepdog_node_list_entry local_entries[SD_MAX_NODES];
+ struct sd_node local_entries[SD_MAX_NODES];
char str[256];
uint32_t sys_stat = sys_stat_get();
@@ -434,7 +434,7 @@ out:
return ret;
}
-static void join(struct sheepdog_node_list_entry *joining, struct join_message *msg)
+static void join(struct sd_node *joining, struct join_message *msg)
{
if (msg->proto_ver != SD_SHEEP_PROTO_VER) {
eprintf("joining node sent a message with the wrong protocol version\n");
@@ -450,7 +450,7 @@ static void join(struct sheepdog_node_list_entry *joining, struct join_message *
msg->ctime = get_cluster_ctime();
}
-static int get_vdi_bitmap_from(struct sheepdog_node_list_entry *node)
+static int get_vdi_bitmap_from(struct sd_node *node)
{
struct sd_req hdr;
struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
@@ -507,8 +507,8 @@ static void get_vdi_bitmap_from_sd_list(void)
}
static void update_cluster_info(struct join_message *msg,
- struct sheepdog_node_list_entry *joined,
- struct sheepdog_node_list_entry *nodes,
+ struct sd_node *joined,
+ struct sd_node *nodes,
size_t nr_nodes)
{
int i, le;
@@ -612,7 +612,7 @@ static void __sd_notify_done(struct cpg_event *cevent)
req->done(req);
}
-static void sd_notify_handler(struct sheepdog_node_list_entry *sender,
+static void sd_notify_handler(struct sd_node *sender,
void *msg, size_t msg_len)
{
struct cpg_event *cevent;
@@ -656,7 +656,7 @@ static void sd_notify_handler(struct sheepdog_node_list_entry *sender,
/*
* Check whether the majority of Sheepdog nodes are still alive or not
*/
-static int check_majority(struct sheepdog_node_list_entry *nodes, int nr_nodes)
+static int check_majority(struct sd_node *nodes, int nr_nodes)
{
int nr_majority, nr_reachable = 0, fd, i;
char name[INET6_ADDRSTRLEN];
@@ -715,13 +715,13 @@ static void __sd_leave(struct cpg_event *cevent)
}
static enum cluster_join_result sd_check_join_cb(
- struct sheepdog_node_list_entry *joining, void *opaque)
+ struct sd_node *joining, void *opaque)
{
struct join_message *jm = opaque;
struct node *node;
if (node_cmp(joining, &sys->this_node) == 0) {
- struct sheepdog_node_list_entry entries[SD_MAX_NODES];
+ struct sd_node entries[SD_MAX_NODES];
int nr_entries;
uint64_t ctime;
uint32_t epoch;
@@ -773,7 +773,7 @@ static enum cluster_join_result sd_check_join_cb(
return CJ_RES_FAIL;
}
-static int send_join_request(struct sheepdog_node_list_entry *ent)
+static int send_join_request(struct sd_node *ent)
{
struct join_message *msg;
int nr_entries, ret;
@@ -1161,8 +1161,8 @@ do_retry:
queue_work(sys->cpg_wqueue, &cpg_event_work);
}
-static void sd_join_handler(struct sheepdog_node_list_entry *joined,
- struct sheepdog_node_list_entry *members,
+static void sd_join_handler(struct sd_node *joined,
+ struct sd_node *members,
size_t nr_members, enum cluster_join_result result,
void *opaque)
{
@@ -1204,7 +1204,7 @@ static void sd_join_handler(struct sheepdog_node_list_entry *joined,
vprintf(SDOG_DEBUG, "allow new confchg %p\n", cevent);
- size = sizeof(struct sheepdog_node_list_entry) * nr_members;
+ size = sizeof(struct sd_node) * nr_members;
w->member_list = zalloc(size);
if (!w->member_list)
panic("failed to allocate memory");
@@ -1307,8 +1307,8 @@ static void sd_join_handler(struct sheepdog_node_list_entry *joined,
}
}
-static void sd_leave_handler(struct sheepdog_node_list_entry *left,
- struct sheepdog_node_list_entry *members,
+static void sd_leave_handler(struct sd_node *left,
+ struct sd_node *members,
size_t nr_members)
{
struct cpg_event *cevent;
@@ -1332,7 +1332,7 @@ static void sd_leave_handler(struct sheepdog_node_list_entry *left,
vprintf(SDOG_DEBUG, "allow new confchg %p\n", cevent);
- size = sizeof(struct sheepdog_node_list_entry) * nr_members;
+ size = sizeof(struct sd_node) * nr_members;
w->member_list = zalloc(size);
if (!w->member_list)
goto oom;
diff --git a/sheep/ops.c b/sheep/ops.c
index ea5d1c4..13ecdf2 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -218,8 +218,8 @@ static int local_read_vdis(const struct sd_req *req, struct sd_rsp *rsp,
return read_vdis(data, req->data_length, &rsp->data_length);
}
-static int get_node_idx(struct sheepdog_node_list_entry *ent,
- struct sheepdog_node_list_entry *entries, int nr_nodes)
+static int get_node_idx(struct sd_node *ent,
+ struct sd_node *entries, int nr_nodes)
{
ent = bsearch(ent, entries, nr_nodes, sizeof(*ent), node_cmp);
if (!ent)
@@ -236,7 +236,7 @@ static int local_get_node_list(const struct sd_req *req, struct sd_rsp *rsp,
nr_nodes = sys->nr_nodes;
memcpy(data, sys->nodes, sizeof(*sys->nodes) * nr_nodes);
- node_rsp->data_length = nr_nodes * sizeof(struct sheepdog_node_list_entry);
+ node_rsp->data_length = nr_nodes * sizeof(struct sd_node);
node_rsp->nr_nodes = nr_nodes;
node_rsp->local_idx = get_node_idx(&sys->this_node, data, nr_nodes);
node_rsp->master_idx = -1;
diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index 510fd4e..183b47b 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -35,7 +35,7 @@ void resume_pending_requests(void)
start_cpg_event_work();
}
-int is_access_local(struct sheepdog_vnode_list_entry *e, int nr_nodes,
+int is_access_local(struct sd_vnode *e, int nr_nodes,
uint64_t oid, int copies)
{
int i, n;
@@ -613,7 +613,7 @@ int create_listen_port(int port, void *data)
return create_listen_ports(port, create_listen_port_fn, data);
}
-int write_object(struct sheepdog_vnode_list_entry *e,
+int write_object(struct sd_vnode *e,
int vnodes, int zones, uint32_t node_version,
uint64_t oid, char *data, unsigned int datalen,
uint64_t offset, uint16_t flags, int nr, int create)
@@ -676,7 +676,7 @@ int write_object(struct sheepdog_vnode_list_entry *e,
return 0;
}
-int read_object(struct sheepdog_vnode_list_entry *e,
+int read_object(struct sd_vnode *e,
int vnodes, int zones, uint32_t node_version,
uint64_t oid, char *data, unsigned int datalen,
uint64_t offset, int nr)
@@ -747,7 +747,7 @@ int read_object(struct sheepdog_vnode_list_entry *e,
return last_error;
}
-int remove_object(struct sheepdog_vnode_list_entry *e,
+int remove_object(struct sd_vnode *e,
int vnodes, int zones, uint32_t node_version,
uint64_t oid, int nr)
{
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 80ddef1..29ffd74 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -84,7 +84,7 @@ struct request {
uint64_t local_oid;
- struct sheepdog_vnode_list_entry *entry;
+ struct sd_vnode *entry;
int nr_vnodes;
int nr_zones;
int check_consistency;
@@ -110,7 +110,7 @@ struct cluster_info {
/* set after finishing the JOIN procedure */
int join_finished;
- struct sheepdog_node_list_entry this_node;
+ struct sd_node this_node;
uint32_t epoch;
uint32_t status;
@@ -121,11 +121,11 @@ struct cluster_info {
*/
struct list_head leave_list;
- struct sheepdog_node_list_entry nodes[SD_MAX_NODES];
+ struct sd_node nodes[SD_MAX_NODES];
int nr_nodes;
/* this array contains a list of ordered virtual nodes */
- struct sheepdog_vnode_list_entry vnodes[SD_MAX_VNODES];
+ struct sd_vnode vnodes[SD_MAX_VNODES];
int nr_vnodes;
struct list_head pending_list;
@@ -202,13 +202,13 @@ int get_vdi_attr(uint32_t epoch, struct sheepdog_vdi_attr *vattr, int data_len,
uint32_t vid, uint32_t *attrid, int copies, uint64_t ctime,
int write, int excl, int delete);
-int get_zones_nr_from(struct sheepdog_node_list_entry *nodes, int nr_nodes);
+int get_zones_nr_from(struct sd_node *nodes, int nr_nodes);
void setup_ordered_sd_vnode_list(struct request *req);
-int get_ordered_sd_vnode_list(struct sheepdog_vnode_list_entry **entries,
+int get_ordered_sd_vnode_list(struct sd_vnode **entries,
int *nr_vnodes, int *nr_zones);
-void free_ordered_sd_vnode_list(struct sheepdog_vnode_list_entry *entries);
+void free_ordered_sd_vnode_list(struct sd_vnode *entries);
int is_access_to_busy_objects(uint64_t oid);
-int is_access_local(struct sheepdog_vnode_list_entry *e, int nr_nodes,
+int is_access_local(struct sd_vnode *e, int nr_nodes,
uint64_t oid, int copies);
void resume_pending_requests(void);
@@ -225,7 +225,7 @@ int read_object_local(uint64_t oid, char *data, unsigned int datalen,
uint64_t offset, int copies, uint32_t epoch);
int read_epoch(uint32_t *epoch, uint64_t *ctime,
- struct sheepdog_node_list_entry *entries, int *nr_entries);
+ struct sd_node *entries, int *nr_entries);
void do_cluster_request(struct work *work, int idx);
int update_epoch_store(uint32_t epoch);
@@ -258,15 +258,15 @@ int start_recovery(uint32_t epoch);
void resume_recovery_work(void);
int is_recoverying_oid(uint64_t oid);
-int write_object(struct sheepdog_vnode_list_entry *e,
+int write_object(struct sd_vnode *e,
int vnodes, int zones, 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 sheepdog_vnode_list_entry *e,
+int read_object(struct sd_vnode *e,
int vnodes, int zones, uint32_t node_version,
uint64_t oid, char *data, unsigned int datalen,
uint64_t offset, int nr);
-int remove_object(struct sheepdog_vnode_list_entry *e,
+int remove_object(struct sd_vnode *e,
int vnodes, int zones, uint32_t node_version,
uint64_t oid, int nr);
diff --git a/sheep/store.c b/sheep/store.c
index 22e5a5a..4adae51 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -141,7 +141,7 @@ static int read_copy_from_cluster(struct request *req, uint32_t epoch,
int i, n, nr, ret;
unsigned wlen, rlen;
char name[128];
- struct sheepdog_vnode_list_entry *e;
+ struct sd_vnode *e;
struct sd_obj_req hdr;
struct sd_obj_rsp *rsp = (struct sd_obj_rsp *)&hdr;
struct siocb iocb;
@@ -220,7 +220,7 @@ static int forward_read_obj_req(struct request *req, int idx)
unsigned wlen, rlen;
struct sd_obj_req hdr = *(struct sd_obj_req *)&req->rq;
struct sd_obj_rsp *rsp = (struct sd_obj_rsp *)&hdr;
- struct sheepdog_vnode_list_entry *e;
+ struct sd_vnode *e;
uint64_t oid = hdr.oid;
int copies;
@@ -277,7 +277,7 @@ static int forward_write_obj_req(struct request *req, int idx)
char name[128];
struct sd_obj_req hdr = *(struct sd_obj_req *)&req->rq;
struct sd_obj_rsp *rsp = (struct sd_obj_rsp *)&req->rp;
- struct sheepdog_vnode_list_entry *e;
+ struct sd_vnode *e;
uint64_t oid = hdr.oid;
int copies;
struct pollfd pfds[SD_MAX_REDUNDANCY];
@@ -421,7 +421,7 @@ int update_epoch_log(int epoch)
goto err_open;
}
- len = sys->nr_nodes * sizeof(struct sheepdog_node_list_entry);
+ len = sys->nr_nodes * sizeof(struct sd_node);
ret = write(fd, (char *)sys->nodes, len);
if (ret != len)
goto err;
@@ -766,7 +766,7 @@ int epoch_log_read_remote(uint32_t epoch, char *buf, int len)
int fd, i, ret;
unsigned int rlen, wlen, nr, le = get_latest_epoch();
char host[128];
- struct sheepdog_node_list_entry nodes[SD_MAX_NODES];
+ struct sd_node nodes[SD_MAX_NODES];
nr = epoch_log_read(le, (char *)nodes, ARRAY_SIZE(nodes));
nr /= sizeof(nodes[0]);
@@ -810,7 +810,7 @@ int epoch_log_read_nr(uint32_t epoch, char *buf, int len)
nr = epoch_log_read(epoch, buf, len);
if (nr < 0)
return nr;
- nr /= sizeof(struct sheepdog_node_list_entry);
+ nr /= sizeof(struct sd_node);
return nr;
}
@@ -977,7 +977,7 @@ uint64_t get_cluster_ctime(void)
return ct;
}
-static int get_max_copies(struct sheepdog_node_list_entry *entries, int nr)
+static int get_max_copies(struct sd_node *entries, int nr)
{
int i, j;
unsigned int nr_zones = 0;
@@ -1005,8 +1005,8 @@ static int get_max_copies(struct sheepdog_node_list_entry *entries, int nr)
* from the base_idx'th on the consistent hash ring, where N is the
* number of copies of objects.
*/
-static int contains_node(struct sheepdog_vnode_list_entry *key,
- struct sheepdog_vnode_list_entry *entry,
+static int contains_node(struct sd_vnode *key,
+ struct sd_vnode *entry,
int nr, int base_idx, int copies)
{
int i;
@@ -1040,13 +1040,13 @@ struct recovery_work {
uint64_t *oids;
int old_nr_nodes;
- struct sheepdog_node_list_entry old_nodes[SD_MAX_NODES];
+ struct sd_node old_nodes[SD_MAX_NODES];
int cur_nr_nodes;
- struct sheepdog_node_list_entry cur_nodes[SD_MAX_NODES];
+ struct sd_node cur_nodes[SD_MAX_NODES];
int old_nr_vnodes;
- struct sheepdog_vnode_list_entry old_vnodes[SD_MAX_VNODES];
+ struct sd_vnode old_vnodes[SD_MAX_VNODES];
int cur_nr_vnodes;
- struct sheepdog_vnode_list_entry cur_vnodes[SD_MAX_VNODES];
+ struct sd_vnode cur_vnodes[SD_MAX_VNODES];
};
static struct recovery_work *next_rw;
@@ -1084,9 +1084,9 @@ static struct recovery_work *recovering_work;
* The node D, E, F, and A can recover objects from local, and the
* node G recovers from the node B.
*/
-static int find_tgt_node(struct sheepdog_vnode_list_entry *old_entry,
+static int find_tgt_node(struct sd_vnode *old_entry,
int old_nr, int old_idx, int old_copies,
- struct sheepdog_vnode_list_entry *cur_entry,
+ struct sd_vnode *cur_entry,
int cur_nr, int cur_idx, int cur_copies,
int copy_idx)
{
@@ -1157,8 +1157,8 @@ static void *alloc_buffer_for(uint64_t oid)
static void *get_vnodes_from_epoch(int epoch, int *nr, int *copies)
{
- int nodes_nr, len = sizeof(struct sheepdog_vnode_list_entry) * SD_MAX_VNODES;
- struct sheepdog_node_list_entry nodes[SD_MAX_NODES];
+ int nodes_nr, len = sizeof(struct sd_vnode) * SD_MAX_VNODES;
+ struct sd_node nodes[SD_MAX_NODES];
void *buf = xmalloc(len);
nodes_nr = epoch_log_read_nr(epoch, (void *)nodes, ARRAY_SIZE(nodes));
@@ -1177,7 +1177,7 @@ static void *get_vnodes_from_epoch(int epoch, int *nr, int *copies)
}
static int recover_object_from_replica(uint64_t oid,
- struct sheepdog_vnode_list_entry *entry,
+ struct sd_vnode *entry,
int epoch, int tgt_epoch)
{
struct sd_obj_req hdr;
@@ -1291,9 +1291,9 @@ out:
return ret;
}
-static void rollback_old_cur(struct sheepdog_vnode_list_entry *old, int *old_nr, int *old_copies,
- struct sheepdog_vnode_list_entry *cur, int *cur_nr, int *cur_copies,
- struct sheepdog_vnode_list_entry *new_old, int new_old_nr, int new_old_copies)
+static void rollback_old_cur(struct sd_vnode *old, int *old_nr, int *old_copies,
+ struct sd_vnode *cur, int *cur_nr, int *cur_copies,
+ struct sd_vnode *new_old, int new_old_nr, int new_old_copies)
{
int nr_old = *old_nr;
int copies_old = *old_copies;
@@ -1313,11 +1313,11 @@ static void rollback_old_cur(struct sheepdog_vnode_list_entry *old, int *old_nr,
*/
static int do_recover_object(struct recovery_work *rw, int copy_idx)
{
- struct sheepdog_vnode_list_entry *old, *cur;
+ struct sd_vnode *old, *cur;
uint64_t oid = rw->oids[rw->done];
int old_nr = rw->old_nr_vnodes, cur_nr = rw->cur_nr_vnodes;
int epoch = rw->epoch, tgt_epoch = rw->epoch - 1;
- struct sheepdog_vnode_list_entry *tgt_entry;
+ struct sd_vnode *tgt_entry;
int old_idx, cur_idx, tgt_idx, old_copies, cur_copies, ret;
old = xmalloc(sizeof(*old) * SD_MAX_VNODES);
@@ -1344,7 +1344,7 @@ again:
ret = recover_object_from_replica(oid, tgt_entry, epoch, tgt_epoch);
if (ret < 0) {
- struct sheepdog_vnode_list_entry *new_old;
+ struct sd_vnode *new_old;
int new_old_nr, new_old_copies;
tgt_epoch--;
@@ -1578,7 +1578,7 @@ static void recover_done(struct work *work, int idx)
resume_pending_requests();
}
-static int __fill_obj_list(struct sheepdog_node_list_entry *e, uint32_t epoch,
+static int __fill_obj_list(struct sd_node *e, uint32_t epoch,
uint8_t *buf, size_t buf_size)
{
int fd, ret;
@@ -1639,7 +1639,7 @@ static int merge_objlist(uint64_t *list1, int nr_list1, uint64_t *list2, int nr_
return nr_list1;
}
-static int screen_obj_list(struct sheepdog_vnode_list_entry *nodes, int nodes_nr,
+static int screen_obj_list(struct sd_vnode *nodes, int nodes_nr,
uint64_t *list, int list_nr, int nr_objs)
{
int ret, i, cp, idx;
@@ -1667,8 +1667,8 @@ static int screen_obj_list(struct sheepdog_vnode_list_entry *nodes, int nodes_nr
#define MAX_RETRY_CNT 6
static int fill_obj_list(struct recovery_work *rw,
- struct sheepdog_node_list_entry *old_entry, int old_nr,
- struct sheepdog_node_list_entry *cur_entry, int cur_nr,
+ struct sd_node *old_entry, int old_nr,
+ struct sd_node *cur_entry, int cur_nr,
int nr_objs)
{
int i, j;
@@ -1741,7 +1741,7 @@ static void __start_recovery(struct work *work, int idx)
eprintf("failed to read epoch log for epoch %"PRIu32"\n", epoch);
goto fail;
}
- rw->cur_nr_nodes /= sizeof(struct sheepdog_node_list_entry);
+ rw->cur_nr_nodes /= sizeof(struct sd_node);
rw->old_nr_nodes = epoch_log_read(epoch - 1, (char *)rw->old_nodes,
sizeof(rw->old_nodes));
@@ -1749,7 +1749,7 @@ static void __start_recovery(struct work *work, int idx)
eprintf("failed to read epoch log for epoch %"PRIu32"\n", epoch - 1);
goto fail;
}
- rw->old_nr_nodes /= sizeof(struct sheepdog_node_list_entry);
+ rw->old_nr_nodes /= sizeof(struct sd_node);
rw->old_nr_vnodes = nodes_to_vnodes(rw->old_nodes, rw->old_nr_nodes,
rw->old_vnodes);
@@ -2009,7 +2009,7 @@ int init_store(const char *d)
}
int read_epoch(uint32_t *epoch, uint64_t *ct,
- struct sheepdog_node_list_entry *entries, int *nr_entries)
+ struct sd_node *entries, int *nr_entries)
{
int ret;
diff --git a/sheep/vdi.c b/sheep/vdi.c
index f00ce04..3615d3c 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -21,7 +21,7 @@ static int create_vdi_obj(uint32_t epoch, char *name, uint32_t new_vid, uint64_t
uint32_t base_vid, uint32_t cur_vid, uint32_t copies,
uint32_t snapid, int is_snapshot)
{
- struct sheepdog_vnode_list_entry *entries = NULL;
+ struct sd_vnode *entries = NULL;
/* we are not called concurrently */
struct sheepdog_inode *new = NULL, *base = NULL, *cur = NULL;
struct timeval tv;
@@ -156,7 +156,7 @@ static int find_first_vdi(uint32_t epoch, unsigned long start, unsigned long end
unsigned long *deleted_nr, uint32_t *next_snap,
unsigned int *nr_copies, uint64_t *ctime)
{
- struct sheepdog_vnode_list_entry *entries = NULL;
+ struct sd_vnode *entries = NULL;
struct sheepdog_inode *inode = NULL;
unsigned long i;
int nr_vnodes, nr_zones, nr_reqs;
@@ -345,7 +345,7 @@ int del_vdi(uint32_t epoch, char *data, int data_len, uint32_t *vid,
uint32_t dummy0;
unsigned long dummy1, dummy2;
int ret;
- struct sheepdog_vnode_list_entry *entries = NULL;
+ struct sd_vnode *entries = NULL;
int nr_vnodes, nr_zones, nr_reqs;
struct sheepdog_inode *inode = NULL;
@@ -434,7 +434,7 @@ static void delete_one(struct work *work, int idx)
{
struct deletion_work *dw = container_of(work, struct deletion_work, work);
uint32_t vdi_id = *(((uint32_t *)dw->buf) + dw->count - dw->done - 1);
- struct sheepdog_vnode_list_entry *entries = NULL;
+ struct sd_vnode *entries = NULL;
int nr_vnodes, nr_zones;
int ret, i;
struct sheepdog_inode *inode = NULL;
@@ -502,7 +502,7 @@ static void delete_one_done(struct work *work, int idx)
}
static int fill_vdi_list(struct deletion_work *dw,
- struct sheepdog_vnode_list_entry *entries,
+ struct sd_vnode *entries,
int nr_vnodes, int nr_zones, uint32_t root_vid)
{
int ret, i;
@@ -548,7 +548,7 @@ out:
return 1;
}
-static uint64_t get_vdi_root(struct sheepdog_vnode_list_entry *entries,
+static uint64_t get_vdi_root(struct sd_vnode *entries,
int nr_vnodes, int nr_zones, uint32_t epoch,
uint32_t vid)
{
@@ -587,7 +587,7 @@ out:
int start_deletion(uint32_t vid, uint32_t epoch)
{
struct deletion_work *dw = NULL;
- struct sheepdog_vnode_list_entry *entries = NULL;
+ struct sd_vnode *entries = NULL;
int nr_vnodes, nr_zones, ret;
uint32_t root_vid;
@@ -653,7 +653,7 @@ int get_vdi_attr(uint32_t epoch, struct sheepdog_vdi_attr *vattr, int data_len,
uint32_t vid, uint32_t *attrid, int copies, uint64_t ctime,
int write, int excl, int delete)
{
- struct sheepdog_vnode_list_entry *entries = NULL;
+ struct sd_vnode *entries = NULL;
struct sheepdog_vdi_attr tmp_attr;
uint64_t oid, hval;
uint32_t end;
--
1.7.8.rc3
More information about the sheepdog
mailing list