[sheepdog-users] snapshot & sheepfs

Liu Yuan namei.unix at gmail.com
Tue May 26 12:18:08 CEST 2015


On Tue, May 26, 2015 at 09:59:00AM +0200, Marcin Mirosław wrote:
> W dniu 26.05.2015 o 05:16, Liu Yuan pisze:
> 
> Hi Liu!
> 
> > On Tue, May 26, 2015 at 10:04:57AM +0800, Liu Yuan wrote:
> >> On Mon, May 25, 2015 at 05:13:45PM +0200, Marcin Mirosław wrote:
> >>> Hi again!
> >>> I've got problem when I'm using sheepfs to access vdi and I create
> >>> snapshot. Please look:
> >>> # sheepfs /mnt/sheep
> >>> # echo testowy > /mnt/sheep/vdi/mount
> >>> # fsck.ext4 -f /mnt/sheep/volume/testowy
> >>> e2fsck 1.42.13 (17-May-2015)
> >>> Przebieg 1: Sprawdzanie i-węzłów, bloków i rozmiarów
> >>> Przebieg 2: Sprawdzanie struktury katalogów
> >>> Przebieg 3: Sprawdzanie łączności katalogów
> >>> Przebieg 4: Sprawdzanie liczników odwołań
> >>> Przebieg 5: Sprawdzanie sumarycznych informacji o grupach
> >>> /mnt/sheep/volume/testowy: 66149/655360 plików (0.1% nieciągłych),
> >>> 1053139/2621440 bloków
> >>>
> >>> Everything is ok.
> >>> Now:
> >>> # dog vdi snapshot -s pierwszysnap testowy
> >>> # LC_ALL=en_US.utf-8 fsck.ext4 -f /mnt/sheep/volume/testowy
> >>> e2fsck 1.42.13 (17-May-2015)
> >>> Error writing block 1081344 (Attempt to write block to filesystem
> >>> resulted in short write).  Ignore error<y>? cancelled!
> >>>
> >>> Umounting and mounting sheepfs doesn't change anything. Is sheepfs using
> >>> vdi or it mounts snapshot?
> >>> Sheepdog HEAD.
> >>> Marcin
> >>
> >> sheepfs doesn't reload inode after snapshoting yet. This is a bug of sheepfs
> >> that need to be fixed.
> >>
> > 
> > As a workaround, you may try offline snapshot:
> > 
> > 1 umount vdi
> > 2 dog vdi snapshot vdi
> > 3 mount vdi again (this will reload the right vdi's meta data)
> 
> It doesn't help, sheepfs can't handle vdi with snapshot even with this
> trick.
> Thanks for answer.
> Marcin

I checked the code, there is indeed having a bug for snapshot read/write.
Please try following patch:


>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) {



More information about the sheepdog-users mailing list