[sheepdog] [PATCH v6 3/8] sheep: rename ctime to create_time in vdi.c

levin li levin108 at gmail.com
Thu Aug 23 05:48:37 CEST 2012


From: levin li <xingke.lwp at taobao.com>

'ctime' shadows a variable in pthread.h, in order to use pthread in
vdi.c, so we need to rename ctime to get rid of the compile warning

Signed-off-by: levin li <xingke.lwp at taobao.com>
---
 collie/vdi.c             |    6 +++---
 include/sheepdog_proto.h |    2 +-
 sheep/vdi.c              |   23 ++++++++++++-----------
 3 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/collie/vdi.c b/collie/vdi.c
index d8fe029..52015ed 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -78,7 +78,7 @@ static void print_vdi_list(uint32_t vid, char *name, char *tag, uint32_t snapid,
 	if (info && strcmp(name, info->name) != 0)
 		return;
 
-	ti = i->ctime >> 32;
+	ti = i->create_time >> 32;
 	if (raw_output) {
 		snprintf(dbuf, sizeof(dbuf), "%" PRIu64, (uint64_t) ti);
 	} else {
@@ -133,7 +133,7 @@ static void print_vdi_tree(uint32_t vid, char *name, char * tag, uint32_t snapid
 	if (is_current(i))
 		strcpy(buf, "(you are here)");
 	else {
-		ti = i->ctime >> 32;
+		ti = i->create_time >> 32;
 		localtime_r(&ti, &tm);
 
 		strftime(buf, sizeof(buf),
@@ -150,7 +150,7 @@ static void print_vdi_graph(uint32_t vid, char *name, char * tag, uint32_t snapi
 	struct tm tm;
 	char dbuf[128], tbuf[128], size_str[128];
 
-	ti = i->ctime >> 32;
+	ti = i->create_time >> 32;
 	localtime_r(&ti, &tm);
 
 	strftime(dbuf, sizeof(dbuf), "%Y-%m-%d", &tm);
diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h
index f119f9c..7d96d63 100644
--- a/include/sheepdog_proto.h
+++ b/include/sheepdog_proto.h
@@ -155,7 +155,7 @@ struct sd_rsp {
 struct sheepdog_inode {
 	char name[SD_MAX_VDI_LEN];
 	char tag[SD_MAX_VDI_TAG_LEN];
-	uint64_t ctime;
+	uint64_t create_time;
 	uint64_t snap_ctime;
 	uint64_t vm_clock_nsec;
 	uint64_t vdi_size;
diff --git a/sheep/vdi.c b/sheep/vdi.c
index f669006..3c8bef2 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -107,7 +107,7 @@ static int create_vdi_obj(struct vdi_iocb *iocb, uint32_t new_vid,
 
 	strncpy(new->name, name, sizeof(new->name));
 	new->vdi_id = new_vid;
-	new->ctime = (uint64_t) tv.tv_sec << 32 | tv.tv_usec * 1000;
+	new->create_time = (uint64_t) tv.tv_sec << 32 | tv.tv_usec * 1000;
 	new->vdi_size = iocb->size;
 	new->copy_policy = 0;
 	new->nr_copies = iocb->nr_copies;
@@ -168,7 +168,7 @@ out:
 static int find_first_vdi(unsigned long start, unsigned long end, char *name,
 			  char *tag, uint32_t snapid, uint32_t *vid,
 			  unsigned long *deleted_nr, uint32_t *next_snap,
-			  unsigned int *inode_nr_copies, uint64_t *ctime)
+			  unsigned int *inode_nr_copies, uint64_t *create_time)
 {
 	struct sheepdog_inode *inode = NULL;
 	unsigned long i;
@@ -205,8 +205,8 @@ static int find_first_vdi(unsigned long start, unsigned long end, char *name,
 			*next_snap = inode->snap_id + 1;
 			*vid = inode->vdi_id;
 			*inode_nr_copies = inode->nr_copies;
-			if (ctime)
-				*ctime = inode->ctime;
+			if (create_time)
+				*create_time = inode->create_time;
 			ret = SD_RES_SUCCESS;
 			goto out_free_inode;
 		}
@@ -226,7 +226,7 @@ out:
 static int do_lookup_vdi(char *name, int namelen, uint32_t *vid, char *tag,
 		uint32_t snapid, uint32_t *next_snapid, unsigned long *right_nr,
 		unsigned long *deleted_nr, unsigned int *nr_copies,
-		uint64_t *ctime)
+		uint64_t *create_time)
 {
 	int ret;
 	unsigned long nr, start_nr;
@@ -245,7 +245,7 @@ static int do_lookup_vdi(char *name, int namelen, uint32_t *vid, char *tag,
 		/* look up on the right side of the hash point */
 		ret = find_first_vdi(nr - 1, start_nr, name,
 				     tag, snapid, vid, deleted_nr, next_snapid,
-				     nr_copies, ctime);
+				     nr_copies, create_time);
 		return ret;
 	} else {
 		/* round up... bitmap search from the head of the bitmap */
@@ -257,7 +257,8 @@ static int do_lookup_vdi(char *name, int namelen, uint32_t *vid, char *tag,
 			/* look up on the left side of the hash point */
 			ret = find_first_vdi(nr - 1, 0, name,
 					     tag, snapid, vid, deleted_nr,
-					     next_snapid, nr_copies, ctime);
+					     next_snapid, nr_copies,
+					     create_time);
 			if (ret == SD_RES_NO_VDI)
 				; /* we need to go to the right side */
 			else
@@ -270,14 +271,14 @@ static int do_lookup_vdi(char *name, int namelen, uint32_t *vid, char *tag,
 }
 
 int lookup_vdi(char *name, char *tag, uint32_t *vid, uint32_t snapid,
-	       unsigned int *nr_copies, uint64_t *ctime)
+	       unsigned int *nr_copies, uint64_t *create_time)
 {
 	uint32_t dummy0;
 	unsigned long dummy1, dummy2;
 
 	return do_lookup_vdi(name, strlen(name), vid, tag,
 			     snapid, &dummy0, &dummy1, &dummy2, nr_copies,
-			     ctime);
+			     create_time);
 }
 
 int add_vdi(struct vdi_iocb *iocb, uint32_t *new_vid)
@@ -677,7 +678,7 @@ err:
 }
 
 int get_vdi_attr(struct sheepdog_vdi_attr *vattr, int data_len,
-		 uint32_t vid, uint32_t *attrid, uint64_t ctime,
+		 uint32_t vid, uint32_t *attrid, uint64_t create_time,
 		 int wr, int excl, int delete)
 {
 	struct sheepdog_vdi_attr tmp_attr;
@@ -685,7 +686,7 @@ int get_vdi_attr(struct sheepdog_vdi_attr *vattr, int data_len,
 	uint32_t end;
 	int ret;
 
-	vattr->ctime = ctime;
+	vattr->ctime = create_time;
 
 	/* we cannot include value_len for calculating the hash value */
 	hval = fnv_64a_buf(vattr->name, sizeof(vattr->name), FNV1A_64_INIT);
-- 
1.7.1




More information about the sheepdog mailing list