junneyang / zumastor

Automatically exported from code.google.com/p/zumastor
0 stars 1 forks source link

snapshot kept for multiple rotations is umounted when it is removed from one rotation #114

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
After we added the feature of keeping snapshots on downstream, a snapshot
can be kept for multiple rotations (e.g., hourly and daily) on downstream.
When a rotation reaches its limit, the current code umounts the oldest
snapshot of that rotation even though the snapshot is also kept for another
rotation. The snapshot won't be removed until the other rotation also
removes it from its list. But this bug can leave some hanging daily.X or
weekly.X symlinks.

Here is a proposed patch for fixing the problem.

Index: bin/zumastor
===================================================================
--- bin/zumastor        (revision 1546)
+++ bin/zumastor        (working copy)
@@ -145,9 +145,17 @@ function new_snapshot {
        echo ${snapshots[@]} >$listfile
        echo "'$kind' snapshot list is now: ${snapshots[*]}"
        [[ -f $mountsnap ]] && update_symlinks $vol $kind
+
        # unmount/delete a snapshot may take a while. We do it after updating
        # symlinks to reduce the window that a symlink points to nowhere
-       [[ -z $oldest ]] || umount_drop_snapshot $vol $oldest
+       if [[ ! -z $oldest ]]; then
+               # don't umount a snapshot that is still kept for other schedule
+               if grep -w "$oldest" $VOLUMES/$vol/$type/snapshots/*
>&/dev/null; then
+                       drop_snapshot $vol $oldest
+               else
+                       umount_drop_snapshot $vol $oldest
+               fi
+       fi
        [[ -f $dotsnapshot ]] && umount -l ${mpoint}/.snapshot && mount
--rbind $snapmp ${mpoint}/.snapshot
 }

Shapor, could you review the patch? Thanks!

Jiaying

Original issue reported on code.google.com by jiayin...@gmail.com on 17 Apr 2008 at 12:28

GoogleCodeExporter commented 9 years ago

Original comment by jiahotc...@gmail.com on 22 Apr 2008 at 10:06

GoogleCodeExporter commented 9 years ago
This one LGTM.

Original comment by compbr...@gmail.com on 28 Apr 2008 at 4:42

GoogleCodeExporter commented 9 years ago
looks good to me

Original comment by Daniel.R...@gmail.com on 28 Apr 2008 at 5:44

GoogleCodeExporter commented 9 years ago
Fixed with revision 1602.

Original comment by jiahotc...@gmail.com on 28 Apr 2008 at 6:18