[sheepdog-users] snapshot & sheepfs
Liu Yuan
namei.unix at gmail.com
Wed May 27 05:40:24 CEST 2015
On Tue, May 26, 2015 at 12:46:35PM +0200, Marcin Mirosław wrote:
> W dniu 26.05.2015 o 12:18, Liu Yuan pisze:
> Hi!
>
> > I checked the code, there is indeed having a bug for snapshot read/write.
> > Please try following patch:
Hi thanks for your test! I've updated the patch as following:
>From ea1b0da4c6c9d15517dde875af3d024073e31183 Mon Sep 17 00:00:00 2001
From: Liu Yuan <liuyuan at cmss.chinamobile.com>
Date: Wed, 27 May 2015 11:38:45 +0800
Subject: [PATCH] sheepfs: fix snapshot readwrite
'vdi list' will return all the snapshot chain, but we should only get the
working vdi with snapid == 0
Signed-off-by: Liu Yuan <liuyuan at cmss.chinamobile.com>
diff --git a/sheepfs/volume.c b/sheepfs/volume.c
index d43304c..c912991 100644
--- a/sheepfs/volume.c
+++ b/sheepfs/volume.c
@@ -400,17 +400,24 @@ static int init_vdi_info(const char *entry, uint32_t *vid, size_t *size)
void *inode_buf = NULL;
struct vdi_inode *inode = NULL, *dummy;
char command[COMMAND_LEN];
+ uint32_t snapid;
+ char *data;
snprintf(command, sizeof(command), "dog vdi list -r %s -a %s -p %d",
entry, sdhost, sdport);
buf = sheepfs_run_cmd(command);
if (!buf)
return -1;
- if (sscanf(buf->buf, "%*s %*s %*d %zu %*s %*s %*s %"PRIx32,
- size, vid) < 2) {
- sheepfs_pr("failed to sscanf %s\n", entry);
- goto err;
- }
+ data = buf->buf;
+ do {
+ if (sscanf(data, "%*s %*s %d %zu %*s %*s %*s %"PRIx32,
+ &snapid, size, vid) < 3) {
+ sheepfs_pr("failed to sscanf %s\n", entry);
+ goto err;
+ }
+ data = strstr(data, "\n");
+ data++; /* eat the "\n" */
+ } while (snapid != 0);
inode_buf = malloc(SD_INODE_SIZE);
if (!inode_buf) {
More information about the sheepdog-users
mailing list