mirror of
https://github.com/versity/scoutfs.git
synced 2026-09-06 08:06:56 +00:00
Add SUBTREE btree walk flag to restrict join/merge
Add a BTW_SUBTREE flag to btree_walk() to restrict splitting or joining of the root block. When clients are merging into the root built from a reference to the last parent in the fs tree we want to be careful that we maintain a single root block that can be spliced back into the fs tree. We specifically check that the root block remain within the split/join thresholds. If it falls out of compliance we return an error so that it can be spliced back into the fs tree and then split/joined with its siblings. Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
@@ -86,6 +86,7 @@ enum btree_walk_flags {
|
||||
BTW_PAR_RNG = (1 << 6), /* return range through final parent */
|
||||
BTW_GET_PAR = (1 << 7), /* get reference to final parent */
|
||||
BTW_SET_PAR = (1 << 8), /* override reference to final parent */
|
||||
BTW_SUBTREE = (1 << 9), /* root is parent subtree, return -ERANGE if split/join */
|
||||
};
|
||||
|
||||
/* total length of the value payload */
|
||||
@@ -1209,6 +1210,17 @@ restart:
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* join/split won't check subtree parent root, let
|
||||
* caller know when it needs to be split/join.
|
||||
*/
|
||||
if ((flags & BTW_SUBTREE) && level == 1 &&
|
||||
(!total_above_join_low_water(bt) ||
|
||||
!mid_free_item_room(bt, sizeof(struct scoutfs_block_ref)))) {
|
||||
ret = -ERANGE;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Splitting and joining can add or remove parents or
|
||||
* change the parent item we use to reach the child
|
||||
|
||||
Reference in New Issue
Block a user