Make snapshot replacement crash-safe using retiring snapshots
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run

This commit is contained in:
Andrea Mazzoleni 2026-09-08 22:19:55 +02:00
parent 7ba5f63d2d
commit f11b649cf4
4 changed files with 228 additions and 38 deletions

View file

@ -85,6 +85,7 @@ int fsinfo(const char* path, int* has_persistent_inode, int* has_syncronized_har
#define SNAPSHOT_PENDING "pending"
#define SNAPSHOT_STABLE "stable"
#define SNAPSHOT_SCAN "scan"
#define SNAPSHOT_RETIRING_SUFFIX ".retiring"
/*
* Snapshots context
@ -189,6 +190,18 @@ int fssnapshot_delete(const struct fssnapshot_struct* fss, const char* name);
*/
int fssnapshot_rename(const struct fssnapshot_struct* fss, const char* old_name, const char* new_name);
/**
* Replace a snapshot while preserving the previous destination until the new one is published.
*
* An interrupted replacement is recovered automatically by fssnapshot_mount().
*
* @param fss Snapshot context
* @param old_name Existing source snapshot name
* @param new_name Destination snapshot name
* @return 0 on success, -1 on failure
*/
int fssnapshot_replace(struct fssnapshot_struct* fss, const char* old_name, const char* new_name);
/**
* Get the path where a logical snapshot is accessible.
*