[sheepdog] [PATCH 2/6] sheep: rename sheepdog_inode as sd_inode
Liu Yuan
namei.unix at gmail.com
Sat Apr 27 07:44:18 CEST 2013
From: Liu Yuan <tailai.ly at taobao.com>
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
collie/collie.h | 4 ++--
collie/common.c | 4 ++--
collie/node.c | 2 +-
collie/vdi.c | 42 +++++++++++++++++++++---------------------
include/sheepdog_proto.h | 8 ++++----
sheep/plain_store.c | 2 +-
sheep/vdi.c | 20 ++++++++++----------
sheepfs/volume.c | 2 +-
8 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/collie/collie.h b/collie/collie.h
index 5973748..b4c7117 100644
--- a/collie/collie.h
+++ b/collie/collie.h
@@ -56,12 +56,12 @@ extern struct sd_vnode sd_vnodes[SD_MAX_VNODES];
extern int sd_nodes_nr, sd_vnodes_nr;
extern unsigned master_idx;
-bool is_current(const struct sheepdog_inode *i);
+bool is_current(const struct sd_inode *i);
char *size_to_str(uint64_t _size, char *str, int str_size);
typedef void (*vdi_parser_func_t)(uint32_t vid, const char *name,
const char *tag, uint32_t snapid,
uint32_t flags,
- const struct sheepdog_inode *i, void *data);
+ const struct sd_inode *i, void *data);
int parse_vdi(vdi_parser_func_t func, size_t size, void *data);
int sd_read_object(uint64_t oid, void *data, unsigned int datalen,
uint64_t offset, bool direct);
diff --git a/collie/common.c b/collie/common.c
index 0642ee0..cd22bc7 100644
--- a/collie/common.c
+++ b/collie/common.c
@@ -11,7 +11,7 @@
#include "collie.h"
-bool is_current(const struct sheepdog_inode *i)
+bool is_current(const struct sd_inode *i)
{
return !i->snap_ctime;
}
@@ -117,7 +117,7 @@ int parse_vdi(vdi_parser_func_t func, size_t size, void *data)
{
int ret;
unsigned long nr;
- static struct sheepdog_inode i;
+ static struct sd_inode i;
struct sd_req req;
static DECLARE_BITMAP(vdi_inuse, SD_NR_VDIS);
unsigned int rlen = sizeof(vdi_inuse);
diff --git a/collie/node.c b/collie/node.c
index d92c078..237500e 100644
--- a/collie/node.c
+++ b/collie/node.c
@@ -17,7 +17,7 @@ static struct node_cmd_data {
static void cal_total_vdi_size(uint32_t vid, const char *name, const char *tag,
uint32_t snapid, uint32_t flags,
- const struct sheepdog_inode *i, void *data)
+ const struct sd_inode *i, void *data)
{
uint64_t *size = data;
diff --git a/collie/vdi.c b/collie/vdi.c
index 5594a51..b81866e 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -84,7 +84,7 @@ static int parse_option_size(const char *value, uint64_t *ret)
static void print_vdi_list(uint32_t vid, const char *name, const char *tag,
uint32_t snapid, uint32_t flags,
- const struct sheepdog_inode *i, void *data)
+ const struct sd_inode *i, void *data)
{
int idx;
bool is_clone = false;
@@ -145,7 +145,7 @@ static void print_vdi_list(uint32_t vid, const char *name, const char *tag,
static void print_vdi_tree(uint32_t vid, const char *name, const char *tag,
uint32_t snapid, uint32_t flags,
- const struct sheepdog_inode *i, void *data)
+ const struct sd_inode *i, void *data)
{
time_t ti;
struct tm tm;
@@ -166,7 +166,7 @@ static void print_vdi_tree(uint32_t vid, const char *name, const char *tag,
static void print_vdi_graph(uint32_t vid, const char *name, const char *tag,
uint32_t snapid, uint32_t flags,
- const struct sheepdog_inode *i, void *data)
+ const struct sd_inode *i, void *data)
{
time_t ti;
struct tm tm;
@@ -200,7 +200,7 @@ static void print_vdi_graph(uint32_t vid, const char *name, const char *tag,
static void get_oid(uint32_t vid, const char *name, const char *tag,
uint32_t snapid, uint32_t flags,
- const struct sheepdog_inode *i, void *data)
+ const struct sd_inode *i, void *data)
{
struct get_vdi_info *info = data;
@@ -263,7 +263,7 @@ static int get_data_oid(char *sheep, uint64_t oid, struct sd_rsp *rsp,
char *buf, void *data)
{
struct get_data_oid_info *info = data;
- struct sheepdog_inode *inode = (struct sheepdog_inode *)buf;
+ struct sd_inode *inode = (struct sd_inode *)buf;
switch (rsp->result) {
case SD_RES_SUCCESS:
@@ -410,7 +410,7 @@ static int find_vdi_name(const char *vdiname, uint32_t snapid, const char *tag,
}
static int read_vdi_obj(const char *vdiname, int snapid, const char *tag,
- uint32_t *pvid, struct sheepdog_inode *inode,
+ uint32_t *pvid, struct sd_inode *inode,
size_t size)
{
int ret;
@@ -486,7 +486,7 @@ static int vdi_create(int argc, char **argv)
uint32_t vid;
uint64_t oid;
int idx, max_idx, ret, nr_copies = vdi_cmd_data.nr_copies;
- struct sheepdog_inode *inode = NULL;
+ struct sd_inode *inode = NULL;
if (!argv[optind]) {
fprintf(stderr, "Please specify the VDI size\n");
@@ -552,7 +552,7 @@ static int vdi_snapshot(int argc, char **argv)
uint32_t vid;
int ret;
char buf[SD_INODE_HEADER_SIZE];
- struct sheepdog_inode *inode = (struct sheepdog_inode *)buf;
+ struct sd_inode *inode = (struct sd_inode *)buf;
if (vdi_cmd_data.snapshot_id != 0) {
fprintf(stderr, "Please specify a non-integer value for "
@@ -567,7 +567,7 @@ static int vdi_snapshot(int argc, char **argv)
if (vdi_cmd_data.snapshot_tag[0]) {
ret = sd_write_object(vid_to_vdi_oid(vid), 0, vdi_cmd_data.snapshot_tag,
SD_MAX_VDI_TAG_LEN,
- offsetof(struct sheepdog_inode, tag),
+ offsetof(struct sd_inode, tag),
0, inode->nr_copies, false, true);
}
@@ -581,7 +581,7 @@ static int vdi_clone(int argc, char **argv)
uint32_t base_vid, new_vid;
uint64_t oid;
int idx, max_idx, ret;
- struct sheepdog_inode *inode = NULL;
+ struct sd_inode *inode = NULL;
char *buf = NULL;
dst_vdi = argv[optind];
@@ -655,7 +655,7 @@ static int vdi_resize(int argc, char **argv)
uint32_t vid;
int ret;
char buf[SD_INODE_HEADER_SIZE];
- struct sheepdog_inode *inode = (struct sheepdog_inode *)buf;
+ struct sd_inode *inode = (struct sd_inode *)buf;
if (!argv[optind]) {
fprintf(stderr, "Please specify the new size for the VDI\n");
@@ -751,7 +751,7 @@ static int vdi_rollback(int argc, char **argv)
uint32_t base_vid;
int ret;
char buf[SD_INODE_HEADER_SIZE];
- struct sheepdog_inode *inode = (struct sheepdog_inode *)buf;
+ struct sd_inode *inode = (struct sd_inode *)buf;
if (!vdi_cmd_data.snapshot_id && !vdi_cmd_data.snapshot_tag[0]) {
fprintf(stderr, "Please specify the '-s' option\n");
@@ -1111,7 +1111,7 @@ static int vdi_read(int argc, char **argv)
{
const char *vdiname = argv[optind++];
int ret, idx;
- struct sheepdog_inode *inode = NULL;
+ struct sd_inode *inode = NULL;
uint64_t offset = 0, oid, done = 0, total = (uint64_t) -1;
unsigned int len, remain;
char *buf = NULL;
@@ -1193,7 +1193,7 @@ static int vdi_write(int argc, char **argv)
const char *vdiname = argv[optind++];
uint32_t vid, flags;
int ret, idx;
- struct sheepdog_inode *inode = NULL;
+ struct sd_inode *inode = NULL;
uint64_t offset = 0, oid, old_oid, done = 0, total = (uint64_t) -1;
unsigned int len, remain;
char *buf = NULL;
@@ -1413,7 +1413,7 @@ static int vdi_check(int argc, char **argv)
int ret;
uint64_t total, done = 0, oid;
uint32_t idx = 0, vid;
- struct sheepdog_inode *inode = xmalloc(sizeof(*inode));
+ struct sd_inode *inode = xmalloc(sizeof(*inode));
ret = read_vdi_obj(vdiname, vdi_cmd_data.snapshot_id,
vdi_cmd_data.snapshot_tag, &vid, inode,
@@ -1555,8 +1555,8 @@ static int vdi_backup(int argc, char **argv)
{
const char *vdiname = argv[optind++];
int ret = EXIT_SUCCESS, idx, nr_objs;
- struct sheepdog_inode *from_inode = xzalloc(sizeof(*from_inode));
- struct sheepdog_inode *to_inode = xzalloc(sizeof(*to_inode));
+ struct sd_inode *from_inode = xzalloc(sizeof(*from_inode));
+ struct sd_inode *to_inode = xzalloc(sizeof(*to_inode));
struct backup_hdr hdr = {
.version = VDI_BACKUP_FORMAT_VERSION,
.magic = VDI_BACKUP_MAGIC,
@@ -1644,7 +1644,7 @@ out:
/* restore backup data to vdi */
static int restore_obj(struct obj_backup *backup, uint32_t vid,
- struct sheepdog_inode *parent_inode)
+ struct sd_inode *parent_inode)
{
int ret;
uint32_t parent_vid = parent_inode->data_vdi_id[backup->idx];
@@ -1671,7 +1671,7 @@ static uint32_t do_restore(const char *vdiname, int snapid, const char *tag)
uint32_t vid;
struct backup_hdr hdr;
struct obj_backup *backup = xzalloc(sizeof(*backup));
- struct sheepdog_inode *inode = xzalloc(sizeof(*inode));
+ struct sd_inode *inode = xzalloc(sizeof(*inode));
ret = xread(STDIN_FILENO, &hdr, sizeof(hdr));
if (ret != sizeof(hdr))
@@ -1736,8 +1736,8 @@ static int vdi_restore(int argc, char **argv)
const char *vdiname = argv[optind++];
int ret;
char buf[SD_INODE_HEADER_SIZE] = {0};
- struct sheepdog_inode *current_inode = xzalloc(sizeof(*current_inode));
- struct sheepdog_inode *parent_inode = (struct sheepdog_inode *)buf;
+ struct sd_inode *current_inode = xzalloc(sizeof(*current_inode));
+ struct sd_inode *parent_inode = (struct sd_inode *)buf;
bool need_current_recovery = false;
if (!vdi_cmd_data.snapshot_id && !vdi_cmd_data.snapshot_tag[0]) {
diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h
index 627a90b..96e1de4 100644
--- a/include/sheepdog_proto.h
+++ b/include/sheepdog_proto.h
@@ -97,8 +97,8 @@
#define SD_DATA_OBJ_SIZE (UINT64_C(1) << 22)
#define SD_MAX_VDI_SIZE (SD_DATA_OBJ_SIZE * MAX_DATA_OBJS)
-#define SD_INODE_SIZE (sizeof(struct sheepdog_inode))
-#define SD_INODE_HEADER_SIZE (sizeof(struct sheepdog_inode) - \
+#define SD_INODE_SIZE (sizeof(struct sd_inode))
+#define SD_INODE_HEADER_SIZE (sizeof(struct sd_inode) - \
sizeof(uint32_t) * MAX_DATA_OBJS)
#define SD_ATTR_OBJ_SIZE (sizeof(struct sheepdog_vdi_attr))
#define CURRENT_VDI_ID 0
@@ -155,7 +155,7 @@ struct sd_rsp {
};
};
-struct sheepdog_inode {
+struct sd_inode {
char name[SD_MAX_VDI_LEN];
char tag[SD_MAX_VDI_TAG_LEN];
uint64_t create_time;
@@ -214,7 +214,7 @@ static inline uint64_t hash_64(uint64_t val, unsigned int bits)
return hash & ((1 << bits) - 1);
}
-static inline bool is_data_obj_writeable(const struct sheepdog_inode *inode,
+static inline bool is_data_obj_writeable(const struct sd_inode *inode,
int idx)
{
return inode->vdi_id == inode->data_vdi_id[idx];
diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index adfd923..c1db177 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -165,7 +165,7 @@ static int init_vdi_copy_number(uint64_t oid, char *wd)
{
char path[PATH_MAX];
int fd, flags = get_open_flags(oid, false, 0), ret;
- struct sheepdog_inode *inode = xzalloc(sizeof(*inode));
+ struct sd_inode *inode = xzalloc(sizeof(*inode));
snprintf(path, sizeof(path), "%s/%016"PRIx64, wd, oid);
diff --git a/sheep/vdi.c b/sheep/vdi.c
index 8abc23c..960dc55 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -165,14 +165,14 @@ int fill_vdi_copy_list(void *data)
return nr * sizeof(*vc);
}
-static inline bool vdi_is_deleted(struct sheepdog_inode *inode)
+static inline bool vdi_is_deleted(struct sd_inode *inode)
{
return *inode->name == '\0';
}
int vdi_exist(uint32_t vid)
{
- struct sheepdog_inode *inode;
+ struct sd_inode *inode;
int ret = 1;
int nr_copies;
@@ -202,7 +202,7 @@ static int create_vdi_obj(struct vdi_iocb *iocb, uint32_t new_vid,
uint32_t cur_vid)
{
/* we are not called concurrently */
- struct sheepdog_inode *new = NULL, *base = NULL, *cur = NULL;
+ struct sd_inode *new = NULL, *base = NULL, *cur = NULL;
struct timeval tv;
int ret = SD_RES_NO_MEM;
unsigned long block_size = SD_DATA_OBJ_SIZE;
@@ -332,7 +332,7 @@ static int get_vdi_bitmap_range(const char *name, unsigned long *left,
return SD_RES_SUCCESS;
}
-static inline bool vdi_is_snapshot(struct sheepdog_inode *inode)
+static inline bool vdi_is_snapshot(struct sd_inode *inode)
{
return !!inode->snap_ctime;
}
@@ -345,7 +345,7 @@ static inline bool vdi_has_tag(struct vdi_iocb *iocb)
}
static inline bool vdi_tag_match(struct vdi_iocb *iocb,
- struct sheepdog_inode *inode)
+ struct sd_inode *inode)
{
const char *tag = iocb->tag;
@@ -359,7 +359,7 @@ static inline bool vdi_tag_match(struct vdi_iocb *iocb,
static int fill_vdi_info_range(uint32_t left, uint32_t right,
struct vdi_iocb *iocb, struct vdi_info *info)
{
- struct sheepdog_inode *inode;
+ struct sd_inode *inode;
bool vdi_found = false;
int nr_copies, ret;
uint32_t i;
@@ -569,7 +569,7 @@ static LIST_HEAD(deletion_work_list);
static int delete_inode(struct deletion_work *dw)
{
- struct sheepdog_inode *inode = NULL;
+ struct sd_inode *inode = NULL;
int ret = SD_RES_SUCCESS;
inode = xzalloc(sizeof(*inode));
@@ -616,7 +616,7 @@ static void delete_one(struct work *work)
struct deletion_work *dw = container_of(work, struct deletion_work, work);
uint32_t vdi_id = *(dw->buf + dw->count - dw->done - 1);
int ret, i, nr_deleted;
- struct sheepdog_inode *inode = NULL;
+ struct sd_inode *inode = NULL;
int nr_copies;
sd_dprintf("%d %d, %16x", dw->done, dw->count, vdi_id);
@@ -705,7 +705,7 @@ static void delete_one_done(struct work *work)
static int fill_vdi_list(struct deletion_work *dw, uint32_t root_vid)
{
int ret, i;
- struct sheepdog_inode *inode = NULL;
+ struct sd_inode *inode = NULL;
int done = dw->count;
uint32_t vid;
int nr_copies;
@@ -751,7 +751,7 @@ out:
static uint64_t get_vdi_root(uint32_t vid, bool *cloned)
{
int ret, nr_copies;
- struct sheepdog_inode *inode = NULL;
+ struct sd_inode *inode = NULL;
*cloned = false;
diff --git a/sheepfs/volume.c b/sheepfs/volume.c
index 701d488..5f55030 100644
--- a/sheepfs/volume.c
+++ b/sheepfs/volume.c
@@ -45,7 +45,7 @@
struct vdi_inode {
struct rb_node rb;
uint32_t vid;
- struct sheepdog_inode *inode;
+ struct sd_inode *inode;
/*
* FIXME
* 1) Consider various VM request queue depth.
--
1.7.9.5
More information about the sheepdog
mailing list