Skip to content

Commit

Permalink
fix import/discovery panic (openzfs#523)
Browse files Browse the repository at this point in the history
When starting the agent and discovering zettacaches, if there's an old
zettacache (with an older on-disk format) present, the agent crashes.
We should instead ignore this old cache.

Bonus cleanup: document recommended relationship between tunables.
  • Loading branch information
ahrens authored Jul 26, 2022
1 parent 48a470b commit 0dea6d8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
17 changes: 8 additions & 9 deletions cmd/zfs_object_agent/zettacache/src/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,14 @@ fn is_valid_cache(

match primary {
Some(disk) => {
let disks_from_primary = disk
.superblock
.primary
.as_ref()
.unwrap()
.disks
.iter()
.map(|(k, v)| (*k, v.guid))
.collect::<HashMap<_, _>>();
let disks_from_primary = match &disk.superblock.primary {
Some(primary) => primary
.disks
.iter()
.map(|(k, v)| (*k, v.guid))
.collect::<HashMap<_, _>>(),
None => return false,
};

// Only retain disks with IDs that are part of the primary block
disks.retain(
Expand Down
1 change: 1 addition & 0 deletions cmd/zfs_object_agent/zettacache/src/slab_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ tunable! {

// Try to keep this amount of slabs available for normal (i.e. BlockAllocator) use. Ideally
// this will be enough space to absorb all the writes that can occur between index merges.
// This should be less than TARGET_FREE_BLOCKS_PCT.
static ref TARGET_AVAILABLE_SLABS_PCT: Percent = Percent::new(2.0);
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/zfs_object_agent/zettacache/src/zettacache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ tunable! {
// keep at least 5% of the cache "free". We need to have slop for the rebalance code to be
// able to consolidate slabs (to create empty slabs) to accomodate block size changes in the
// workload. This target includes both free blocks within the BlockAllocator, and free slabs
// within the SlabAllocator which are available to the BlockAllocator.
// within the SlabAllocator which are available to the BlockAllocator. This should be more
// than TARGET_AVAILABLE_SLABS_PCT.
static ref TARGET_FREE_BLOCKS_PCT: Percent = Percent::new(5.0);

// Keep the total footprint for the pending changes and index cache data at about 12% of
Expand Down

0 comments on commit 0dea6d8

Please sign in to comment.