The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/5814

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
See #5763
During a publish, a *.ro subvolume snapshot copy is made
whilst the original snapshot is set read-write.
If lxd is killed before publish finishes, the *.ro copy
can be left orphaned, and should be deleted when
the associated snapshot is deleted.

Signed-off-by: Joel Hockey <[email protected]>
From 6711de8f212f20f666fd18efc96975483797079d Mon Sep 17 00:00:00 2001
From: Joel Hockey <[email protected]>
Date: Tue, 4 Jun 2019 03:51:53 -0700
Subject: [PATCH] lxd/storage/btrfs: Delete any orphaned *.ro snapshots See
 #5763 During a publish, a *.ro subvolume snapshot copy is made whilst the
 original snapshot is set read-write. If lxd is killed before publish
 finishes, the *.ro copy can be left orphaned, and should be deleted when the
 associated snapshot is deleted.

Signed-off-by: Joel Hockey <[email protected]>
---
 lxd/storage_btrfs.go | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index 2ce3bca3ad..c186549892 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -1442,10 +1442,15 @@ func (s *storageBtrfs) 
ContainerSnapshotCreate(snapshotContainer container, sour
 
 func btrfsSnapshotDeleteInternal(project, poolName string, snapshotName 
string) error {
        snapshotSubvolumeName := getSnapshotMountPoint(project, poolName, 
snapshotName)
-       if shared.PathExists(snapshotSubvolumeName) && 
isBtrfsSubVolume(snapshotSubvolumeName) {
-               err := btrfsSubVolumesDelete(snapshotSubvolumeName)
-               if err != nil {
-                       return err
+       // Also delete any leftover .ro snapshot.
+       roSnapshotSubvolumeName := fmt.Sprintf("%s.ro", snapshotSubvolumeName)
+       names := []string{snapshotSubvolumeName, roSnapshotSubvolumeName}
+       for _, name := range names {
+               if shared.PathExists(name) && isBtrfsSubVolume(name) {
+                       err := btrfsSubVolumesDelete(name)
+                       if err != nil {
+                               return err
+                       }
                }
        }
 
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to