osd, cli: Pause writes while making a live snapshot #177

Open
koolkhel wants to merge 5 commits from koolkhel/vitastor:readonly-inode-check into master

5 Commits

Author SHA1 Message Date
bef72607cd osd, cli: Pause writes to an image while making its snapshot
A client or an OSD that applies a live snapshot late still writes into
the old layer. With several clients writing to one image the snapshot
can then hold a write while missing an earlier one it depends on.

snap-create now first sets a new "paused" flag in the image's inode
config and waits until every primary OSD reports that it has applied
it, in a new config_revision field of /osd/state. An OSD rewrites its
state only when it applies a paused inode. Only then is the image
renamed into the snapshot. OSDs reject writes to a paused inode like
writes to a snapshot, with -ESTALE to clients announcing readonly_check,
which retry and resend them to the new layer. If OSDs don't apply the
pause in --pause-timeout seconds (10 by default), or the snapshot fails,
snap-create removes the pause. With OSDs that don't report
config_revision it warns and doesn't pause.
2026-11-25 23:42:17 +03:00
56234e270a Add a test for a client writing across a snapshot with a lagging etcd watch
A writer that applies etcd events 3 seconds late keeps writing while
snap-create runs. Check that the snapshot does not change after it was
taken and that the image has every write.
2026-11-25 23:20:42 +03:00
813e7bf249 osd, client: Reject writes to snapshots from clients that missed the switch
Inode readonly is only checked on the client, and a client learns about
a snapshot from its own etcd watch. Until then it keeps writing into the
inode that has become the snapshot, so writes made after the snapshot
change it and are missing from the image. Make PG primaries reject such
writes with -ESTALE (-EROFS for CAS writes) when the client announces
the readonly_check feature and the snapshot has a successor. The client
retries until its own view shows the snapshot, then resends the whole
write to the successor. Merge, flatten, rm-data and write-back flushes
send OSD_OP_IGNORE_INODE_READONLY and are not checked.
2026-11-25 23:20:42 +03:00
f35a4d870c cli: Record the layer that replaced a snapshot as its successor
When snap-create renames the current layer into a snapshot, nothing in
its config says which layer took its place, and the name alone is
ambiguous because clones of the snapshot have it as their parent too.
Store the new layer as successor_id/successor_pool, encoded like
parent_id/parent_pool, so clients holding the old inode number can
follow it.
2026-11-25 23:20:16 +03:00
455b83187f client: Add a debug option to delay applying etcd watch events
Bugs where a client or an OSD acts on stale metadata after a change in
etcd, like writing into a layer that has just become a snapshot, depend
on a narrow timing window and are hard to reproduce. Add a hidden
etcd_watch_delay_ms option which applies watch events that much later,
in order, so tests can make a lagging participant deterministic. Events
still queued when the state is reloaded after a compaction are dropped.
2026-11-25 23:20:16 +03:00