Skip to content

Commit a03c5b3

Browse files
authored
Merge pull request #10 from appsignal/fix/activate-thin-snapshot-after-creation
Activate thin snapshot after creation with lvchange -K -ay
2 parents 7559a9c + d52657f commit a03c5b3

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

manager/src/lvm.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,22 @@ pub fn lvcreate_snapshot(vg: &str, source: &str, name: &str) -> Result<()> {
7878
if !status.success() {
7979
anyhow::bail!("lvcreate snapshot failed: {}/{} -> {}", vg, source, name);
8080
}
81-
info!(vg, source, name, "snapshot created");
82-
// Wait for udev to process the new device node before returning so callers
83-
// can immediately open or mount the device path under /dev.
81+
// Thin snapshots are created with the "skip activation" flag (k) set by
82+
// default. Plain lvchange -ay silently respects that flag and does nothing.
83+
// -K (--ignoreactivationskip) overrides it, creating the DM device so the
84+
// /dev/<vg>/<lv> node is present before we return.
85+
let status = Command::new("lvchange")
86+
.args(["-K", "-ay", &format!("{}/{}", vg, name)])
87+
.status()
88+
.context("failed to run lvchange -K -ay")?;
89+
if !status.success() {
90+
anyhow::bail!("lvchange -K -ay failed for {}/{}", vg, name);
91+
}
92+
// Wait for udev to finish creating the /dev/<vg>/<lv> symlink.
8493
let _ = Command::new("udevadm")
8594
.args(["settle", "--timeout=5"])
8695
.status();
96+
info!(vg, source, name, "snapshot created and activated");
8797
Ok(())
8898
}
8999

0 commit comments

Comments
 (0)