[sheepdog-users] snapshot & sheepfs

Marcin Mirosław marcin at mejor.pl
Tue May 26 12:46:35 CEST 2015


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:

When I have one snapshot it works correctly. sheepfs with "-d" option
displays:


# sheepfs -d /mnt/sheep
FUSE library version: 2.9.3
nullpath_ok: 0
nopath: 0
utime_omit_ok: 0
unique: 1, opcode: INIT (26), nodeid: 0, insize: 56, pid: 0
INIT: 7.23
flags=0x0003f7fb
max_readahead=0x00020000
   INIT: 7.19
   flags=0x00000031
   max_readahead=0x00020000
   max_write=0x00020000
   max_background=0
   congestion_threshold=0
   unique: 1, success, outsize: 40




unique: 2, opcode: LOOKUP (1), nodeid: 1, insize: 44, pid: 10694
LOOKUP /vdi
getattr /vdi
   NODEID: 2
   unique: 2, success, outsize: 144
unique: 3, opcode: LOOKUP (1), nodeid: 2, insize: 46, pid: 10694
LOOKUP /vdi/mount
getattr /vdi/mount
   NODEID: 3
   unique: 3, success, outsize: 144
unique: 4, opcode: OPEN (14), nodeid: 3, insize: 48, pid: 10694
open flags: 0x8001 /vdi/mount
   open[0] flags: 0x8001 /vdi/mount
   unique: 4, success, outsize: 32
unique: 5, opcode: SETATTR (4), nodeid: 3, insize: 128, pid: 10694
truncate /vdi/mount 0
getattr /vdi/mount
   unique: 5, success, outsize: 120
unique: 6, opcode: FLUSH (25), nodeid: 3, insize: 64, pid: 10694
   unique: 6, error: -38 (Function not implemented), outsize: 16
unique: 7, opcode: GETXATTR (22), nodeid: 3, insize: 68, pid: 10694
   unique: 7, error: -38 (Function not implemented), outsize: 16
unique: 8, opcode: WRITE (16), nodeid: 3, insize: 88, pid: 10694
write[0] 8 bytes to 0 flags: 0x8001
   write[0] 8 bytes to 0
   unique: 8, success, outsize: 24
unique: 9, opcode: RELEASE (18), nodeid: 3, insize: 64, pid: 0
release[0] flags: 0x8001
   unique: 9, success, outsize: 16

unique: 11, opcode: FORGET (2), nodeid: 1, insize: 48, pid: 0
FORGET 1/1
unique: 10, opcode: BATCH_FORGET (42), nodeid: 0, insize: 80, pid: 0
FORGET 3/1
DELETE: 3
FORGET 2/1
DELETE: 2


But when I create another snapshot, doing:
echo testowy > /mnt/sheep/vdi/mount
hangs forever.
# sheepfs -d /mnt/sheep
FUSE library version: 2.9.3
nullpath_ok: 0
nopath: 0
utime_omit_ok: 0
unique: 1, opcode: INIT (26), nodeid: 0, insize: 56, pid: 0
INIT: 7.23
flags=0x0003f7fb
max_readahead=0x00020000
   INIT: 7.19
   flags=0x00000031
   max_readahead=0x00020000
   max_write=0x00020000
   max_background=0
   congestion_threshold=0
   unique: 1, success, outsize: 40

unique: 2, opcode: LOOKUP (1), nodeid: 1, insize: 44, pid: 10694
LOOKUP /vdi
getattr /vdi
   NODEID: 2
   unique: 2, success, outsize: 144
unique: 3, opcode: LOOKUP (1), nodeid: 2, insize: 46, pid: 10694
LOOKUP /vdi/mount
getattr /vdi/mount
   NODEID: 3
   unique: 3, success, outsize: 144
unique: 4, opcode: OPEN (14), nodeid: 3, insize: 48, pid: 10694
open flags: 0x8001 /vdi/mount
   open[0] flags: 0x8001 /vdi/mount
   unique: 4, success, outsize: 32
unique: 5, opcode: SETATTR (4), nodeid: 3, insize: 128, pid: 10694
truncate /vdi/mount 0
getattr /vdi/mount
   unique: 5, success, outsize: 120
unique: 6, opcode: FLUSH (25), nodeid: 3, insize: 64, pid: 10694
   unique: 6, error: -38 (Function not implemented), outsize: 16
unique: 7, opcode: GETXATTR (22), nodeid: 3, insize: 68, pid: 10694
   unique: 7, error: -38 (Function not implemented), outsize: 16
unique: 8, opcode: WRITE (16), nodeid: 3, insize: 88, pid: 10694
write[0] 8 bytes to 0 flags: 0x8001

<at this moment only SIGKILL can stop sheepfs>

Thanks,
Marcin.

> 
> From 3d05d1f2da4f025968312a36a84a47eb4583d0ee Mon Sep 17 00:00:00 2001
> From: Liu Yuan <liuyuan at cmss.chinamobile.com>
> Date: Tue, 26 May 2015 18:15:15 +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..a384dfc 100644
> --- a/sheepfs/volume.c
> +++ b/sheepfs/volume.c
> @@ -400,17 +400,23 @@ 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");
> +       } while (snapid != 0);
>  
>         inode_buf = malloc(SD_INODE_SIZE);
>         if (!inode_buf) {
> 
> 


-- 
xmpp (jabber): marcin  [at]  mejor.pl
www: http://blog.mejor.pl/


More information about the sheepdog-users mailing list