[lxc-devel] [lxd/master] lxd/storage/btrfs: Delete any orphaned *.ro snapshots
joelhockey on Github
lxc-bot at linuxcontainers.org
Tue Jun 4 11:02:28 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 617 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190604/285e73e4/attachment.bin>
-------------- next part --------------
From 6711de8f212f20f666fd18efc96975483797079d Mon Sep 17 00:00:00 2001
From: Joel Hockey <joelhockey at chromium.org>
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 <joelhockey at chromium.org>
---
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
+ }
}
}
More information about the lxc-devel
mailing list