static bool data_fits(struct ma_state *sib, struct ma_state *mas,
struct maple_copy *cp)
{
- unsigned char space;
unsigned char new_data;
- unsigned char end;
enum maple_type type;
- void __rcu **slots;
+ unsigned char space;
+ unsigned char end;
type = mte_node_type(mas->node);
space = 2 * mt_slots[type];
* to reduce jitter.
*/
-#if 1
if (ma_is_leaf(type)) {
if (new_data < space)
}
return false;
-#else
- /* Leave some room to reduce jitter. */
- if (new_data < space - 1)
- return true;
-
- /* Leave some room to reduce jitter. */
- if (!ma_is_leaf(type))
- return false;
- /*
- * new_data == space, an exact fit can be foiled by a NULL at the split
- * location.
- */
- if (sib->max < mas->min) {
- printk("Trying left\n");
- /*
- * Pushing to left, there must be room so the last slot is not
- * occupied.
- *
- * The new data is causing the two nodes to equate to exactly 32
- * in size, so the left must either have 1 or 2 slots empty.
- */
- new_data = mt_slots[type] - end - 2;
- if (mas->offset == new_data ||
- mas->offset + cp->end == new_data) {
- printk("use cp ");
- new_data -= mas->offset;
- slots = cp->slot;
- } else {
- printk("use mas ");
- slots = ma_slots(mas_mn(mas), type);
- }
- printk("Check slot %u\n", new_data);
- } else {
- unsigned char split;
- /*
- * Pushing to right, there must be an overflow of data into sib,
- * which is almost full itself.
- *
- * The new data can add 1 or 2 entries in this case.
- * The split must fall either in the new data or the end of the
- * existing mas node.
- */
- printk("Trying right\n");
- printk("data is %u end is %u\n", cp->data, end);
- /* size - size to index (-1) */
- split = (new_data - 1) / 2;
- printk("split will be %u\n", split);
-
- if (split >= mas->offset &&
- split <= mas->offset + cp->end + 1) {
- new_data = split - mas->offset;
- slots = cp->slot;
- printk("Check new data %u\n", new_data);
- } else {
- if (mas->offset < split) {
- printk("offset is smaller than expected split\n");
- printk("new_data %u offset %u end %u\n", new_data, mas->offset, cp->end);
- /*
- * The last slot in the previous node is the one
- * before the overflow.
- * The total is 32 here, so we know that it will
- * be 16/16 split.
- */
-
- //new_data = mas->end - (split - end);
- new_data = mas->end - (cp->data - 1 - split);
- }
- slots = ma_slots(mas_mn(mas), type);
- printk("Check mas %u\n", new_data);
- }
- }
-
- fflush(stdout);
- printk("Check %u\n", new_data);
- if (slots[new_data])
- return true;
-
- return false;
-#endif
}
static void push_data_sib(struct maple_copy *cp, struct ma_state *mas,