Skip to main content

NewGeneration

Struct NewGeneration 

Source
pub struct NewGeneration {
    pub stop_after: StopAfter,
}
Expand description

GC into a new generation, keeping the old one until the new one is proven.

repo.znippy becomes repo.g1.znippy, then repo.g2.znippy, and so on. The old file is unlinked only after the new one has been read back in full.

The sequence, and why each step is where it is:

  1. link(archive, work) — a hard link, so the work name and the archive name are the same inode and not one byte is copied. This is what lets step 2 be compact_archive verbatim (LAW 5) while the archive’s own name stays untouched: compact_archive renames over the name it was given, and the name it is given here is the work link, not the archive.
  2. compact_archive(work) — stages beside work and renames over it. The archive’s inode is still fully referenced by the archive’s own name throughout, so every reader of repo.znippy is unaffected.
  3. verify — [verify_archive_integrity] over the new file, plus a manifest set comparison against the original. Both are read back off disk.
  4. rename(work, repo.gN.znippy) — atomic; the new generation now has its permanent name.
  5. unlink(repo.znippy) — the old index and old data go, and only now.

A death at any point leaves at least one complete, readable archive: before 4 the original under its own name (plus debris), after 4 and before 5 both of them, after 5 the new generation. Asserted, per step, in [tests::an_interruption_at_every_step_leaves_a_readable_archive].

Fields§

§stop_after: StopAfter

Test-only interruption point. StopAfter::Never in every real run.

Implementations§

Source§

impl NewGeneration

Source

pub fn new() -> Self

Source

pub fn stopping_after(stop: StopAfter) -> Self

Stop the run at stop, leaving the filesystem as a crash there would.

Trait Implementations§

Source§

impl Clone for NewGeneration

Source§

fn clone(&self) -> NewGeneration

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for NewGeneration

Source§

impl Debug for NewGeneration

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for NewGeneration

Source§

fn default() -> NewGeneration

Returns the “default value” for a type. Read more
Source§

impl Gc for NewGeneration

Source§

fn run(&self, archive: &Path) -> Result<GcReport>

Source§

fn name(&self) -> &'static str

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.