- iam_ptr_t new_blknr)
-{
- struct iam_path *path;
- struct iam_leaf_head *hdr;
- const struct iam_ikey *pivot;
- struct buffer_head *new_leaf;
-
- unsigned count;
- unsigned split;
-
- void *start;
- void *finis;
-
- new_leaf = *bh;
- path = iam_leaf_path(l);
-
- hdr = (void *)new_leaf->b_data;
-
- count = lentry_count_get(l);
- split = count / 2;
-
- start = iam_lfix_shift(l, iam_get_lentries(l), split);
- finis = iam_lfix_shift(l, iam_get_lentries(l), count);
-
- pivot = (const struct iam_ikey *)iam_leaf_key_at(start);
-
- memmove(iam_entries(new_leaf), start, finis - start);
- hdr->ill_count = count - split;
- lentry_count_set(l, split);
- if ((void *)l->il_at >= start) {
- /*
- * insertion point moves into new leaf.
- */
- int shift;
- int result;
-
- shift = iam_lfix_diff(l, l->il_at, start);
- *bh = l->il_bh;
- l->il_bh = new_leaf;
- l->il_curidx = new_blknr;
- result = iam_lfix_init(l);
- /*
- * init cannot fail, as node was just initialized.
- */
- assert_corr(result == 0);
- l->il_at = iam_lfix_shift(l, iam_get_lentries(l), shift);
- }
- /*
- * Insert pointer to the new node (together with the least key in
- * the node) into index node.
- */
- iam_insert_key_lock(path, path->ip_frame, pivot, new_blknr);
+ iam_ptr_t new_blknr)
+{
+ struct iam_path *path;
+ struct iam_leaf_head *hdr;
+ const struct iam_ikey *pivot;
+ struct buffer_head *new_leaf;
+
+ unsigned int count;
+ unsigned int split;
+
+ void *start;
+ void *finis;
+
+ new_leaf = *bh;
+ path = iam_leaf_path(l);
+
+ hdr = (void *)new_leaf->b_data;
+
+ count = lentry_count_get(l);
+ split = count / 2;
+
+ start = iam_lfix_shift(l, iam_get_lentries(l), split);
+ finis = iam_lfix_shift(l, iam_get_lentries(l), count);
+
+ pivot = (const struct iam_ikey *)iam_leaf_key_at(start);
+
+ memmove(iam_entries(new_leaf), start, finis - start);
+ hdr->ill_count = cpu_to_le16(count - split);
+ lentry_count_set(l, split);
+ if ((void *)l->il_at >= start) {
+ /*
+ * insertion point moves into new leaf.
+ */
+ int shift;
+
+ shift = iam_lfix_diff(l, l->il_at, start);
+ *bh = l->il_bh;
+ l->il_bh = new_leaf;
+ l->il_curidx = new_blknr;
+ iam_lfix_init(l);
+ /*
+ * init cannot fail, as node was just initialized.
+ */
+ assert_corr(result == 0);
+ l->il_at = iam_lfix_shift(l, iam_get_lentries(l), shift);
+ }
+ /*
+ * Insert pointer to the new node (together with the least key in
+ * the node) into index node.
+ */
+ iam_insert_key_lock(path, path->ip_frame, pivot, new_blknr);