From 21d5fd97f300363c9338a8488a98b55e08391d94 Mon Sep 17 00:00:00 2001 From: mulhern <amulhern@redhat.com> Date: Mon, 9 Sep 2024 15:48:54 -0400 Subject: [PATCH] Patch up origin fields if deleted filesystem was an origin Signed-off-by: mulhern <amulhern@redhat.com> --- src/engine/strat_engine/thinpool/thinpool.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/engine/strat_engine/thinpool/thinpool.rs b/src/engine/strat_engine/thinpool/thinpool.rs index cf76709381..6f07ff5466 100644 --- a/src/engine/strat_engine/thinpool/thinpool.rs +++ b/src/engine/strat_engine/thinpool/thinpool.rs @@ -819,7 +819,11 @@ impl<B> ThinPool<B> { let (mut removed, mut updated_origins) = (Vec::new(), Vec::new()); for &uuid in fs_uuids { - if let Some(uuid) = self.destroy_filesystem(pool_name, uuid)? { + if let Some((_, fs)) = self.get_filesystem_by_uuid(uuid) { + let fs_origin = fs.origin(); + let uuid = self + .destroy_filesystem(pool_name, uuid)? + .expect("just looked up"); removed.push(uuid); for (sn_uuid, _) in snapshots.remove(&uuid).unwrap_or_else(Vec::new) { @@ -828,8 +832,8 @@ impl<B> ThinPool<B> { // removal. if let Some((_, sn)) = self.get_mut_filesystem_by_uuid(sn_uuid) { assert!( - sn.set_origin(None), - "A snapshot can only have one origin, so it can be in snapshots.values() only once, so its origin value can be unset only once" + sn.set_origin(fs_origin), + "A snapshot can only have one origin, so it can be in snapshots.values() only once, so its origin value can be set only once" ); updated_origins.push(sn_uuid);