- if (namelen == 0)
- return 0;
- if (strncmp(name, ".", 1) == 0 && namelen == 1)
- return 1;
- if (strncmp(name, "..", 2) == 0 && namelen == 2)
- return 2;
-
- if (LVAR_HASH_PREFIX) {
- result = 0;
- strncpy((void *)&result,
- name, min(namelen, (int)sizeof result));
- } else {
- struct ldiskfs_dx_hash_info hinfo;
-
- hinfo.hash_version = LDISKFS_DX_HASH_TEA;
+ if (namelen == 0)
+ return 0;
+ if (strncmp(name, ".", 1) == 0 && namelen == 1)
+ return 1;
+ if (strncmp(name, "..", 2) == 0 && namelen == 2)
+ return 2;
+
+ if (LVAR_HASH_PREFIX) {
+ result = 0;
+ strncpy((void *)&result,
+ name, min_t(int, namelen, sizeof(result)));
+ } else {
+ struct ldiskfs_dx_hash_info hinfo;
+
+ hinfo.hash_version = LDISKFS_DX_HASH_TEA;
- struct iam_path *path;
- struct lvar_leaf_entry *scan;
- struct lvar_leaf_entry *end;
- lvar_hash_t hash;
- lvar_hash_t nexthash;
- lvar_hash_t starthash;
-
- end = n_end(leaf);
- hash = 0;
- path = leaf->il_path;
-
- if (h_used(n_head(leaf)) > blocksize(leaf))
- return 0;
-
- /*
- * Delimiting key in the parent index node. Clear least bit to account
- * for hash collision marker.
- */
- starthash = *(lvar_hash_t *)iam_ikey_at(path, path->ip_frame->at) & ~1;
- for (scan = n_start(leaf); scan < end; scan = e_next(leaf, scan)) {
- nexthash = e_hash(scan);
- if (nexthash != get_hash(iam_leaf_container(leaf),
- e_char(scan), e_keysize(scan))) {
- BREAKPOINT();
- return 0;
- }
- if (0 && nexthash < starthash) {
- /*
- * Unfortunately this useful invariant cannot be
- * reliably checked as parent node is nor necessarily
- * locked.
- */
- n_print(leaf);
- printk("%#x < %#x\n", nexthash, starthash);
- dump_stack();
- return 0;
- }
- if (nexthash < hash) {
- BREAKPOINT();
- return 0;
- }
- hash = nexthash;
- }
- if (scan != end) {
- BREAKPOINT();
- return 0;
- }
- return 1;
+ struct iam_path *path;
+ struct lvar_leaf_entry *scan;
+ struct lvar_leaf_entry *end;
+ lvar_hash_t hash;
+ lvar_hash_t nexthash;
+ lvar_hash_t starthash;
+
+ end = n_end(leaf);
+ hash = 0;
+ path = leaf->il_path;
+
+ if (h_used(n_head(leaf)) > blocksize(leaf))
+ return 0;
+
+ /*
+ * Delimiting key in the parent index node. Clear least bit to account
+ * for hash collision marker.
+ */
+ starthash = *(lvar_hash_t *)iam_ikey_at(path, path->ip_frame->at) & ~1;
+ for (scan = n_start(leaf); scan < end; scan = e_next(leaf, scan)) {
+ nexthash = e_hash(scan);
+ if (nexthash != get_hash(iam_leaf_container(leaf),
+ e_char(scan), e_keysize(scan))) {
+ BREAKPOINT();
+ return 0;
+ }
+ if (0 && nexthash < starthash) {
+ /*
+ * Unfortunately this useful invariant cannot be
+ * reliably checked as parent node is not necessarily
+ * locked.
+ */
+ n_print(leaf);
+ CERROR("%#x < %#x\n", nexthash, starthash);
+ dump_stack();
+ return 0;
+ }
+ if (nexthash < hash) {
+ BREAKPOINT();
+ return 0;
+ }
+ hash = nexthash;
+ }
+ if (scan != end) {
+ BREAKPOINT();
+ return 0;
+ }
+ return 1;
- used <= blocksize(l)) {
- l->il_at = l->il_entries = lvar_lentry(n_start(l));
- result = 0;
- } else {
- struct inode *obj;
-
- obj = iam_leaf_container(l)->ic_object;
- CERROR("Wrong magic in node %llu (#%lu): %#x != %#x or "
- "wrong used: %d\n",
- (unsigned long long)l->il_bh->b_blocknr, obj->i_ino,
- le16_to_cpu(head->vlh_magic), IAM_LVAR_LEAF_MAGIC,
- used);
+ used <= blocksize(l)) {
+ l->il_at = l->il_entries = lvar_lentry(n_start(l));
+ result = 0;
+ } else {
+ struct inode *obj;
+
+ obj = iam_leaf_container(l)->ic_object;
+ CERROR(
+ "Bad magic in node %llu (#%lu): %#x != %#x or wrong used: %d\n",
+ (unsigned long long)l->il_bh->b_blocknr, obj->i_ino,
+ le16_to_cpu(head->vlh_magic), IAM_LVAR_LEAF_MAGIC,
+ used);
- struct lvar_leaf_entry *found;
- struct lvar_leaf_entry *scan;
- struct lvar_leaf_entry *end;
- int result;
- const char *name;
- int namelen;
- int found_equal;
- lvar_hash_t hash;
- int last;
-
- assert_inv(n_invariant(leaf));
- end = n_end(leaf);
-
- name = kchar(k);
- namelen = strlen(name);
- hash = get_hash(iam_leaf_container(leaf), name, namelen);
- found = NULL;
- found_equal = 0;
- last = 1;
-
- for (scan = n_start(leaf); scan < end; scan = e_next(leaf, scan)) {
- lvar_hash_t scan_hash;
-
- scan_hash = e_hash(scan);
- if (scan_hash < hash)
- found = scan;
- else if (scan_hash == hash) {
- if (e_eq(scan, name, namelen)) {
- /*
- * perfect match
- */
- leaf->il_at = lvar_lentry(scan);
- return IAM_LOOKUP_EXACT;
- } else if (!found_equal) {
- found = scan;
- found_equal = 1;
- }
- } else {
- last = 0;
- break;
- }
- }
- if (found == NULL) {
- /*
- * @k is less than all hashes in the leaf.
- */
- lvar_start(leaf);
- result = IAM_LOOKUP_BEFORE;
- } else {
- leaf->il_at = lvar_lentry(found);
- result = IAM_LOOKUP_OK;
- assert_corr(n_at_rec(leaf));
- }
- if (last)
- result |= IAM_LOOKUP_LAST;
- assert_inv(n_invariant(leaf));
-
- return result;
+ struct lvar_leaf_entry *found;
+ struct lvar_leaf_entry *scan;
+ struct lvar_leaf_entry *end;
+ int result;
+ const char *name;
+ int namelen;
+ int found_equal;
+ lvar_hash_t hash;
+ int last;
+
+ assert_inv(n_invariant(leaf));
+ end = n_end(leaf);
+
+ name = kchar(k);
+ namelen = strlen(name);
+ hash = get_hash(iam_leaf_container(leaf), name, namelen);
+ found = NULL;
+ found_equal = 0;
+ last = 1;
+
+ for (scan = n_start(leaf); scan < end; scan = e_next(leaf, scan)) {
+ lvar_hash_t scan_hash;
+
+ scan_hash = e_hash(scan);
+ if (scan_hash < hash)
+ found = scan;
+ else if (scan_hash == hash) {
+ if (e_eq(scan, name, namelen)) {
+ /*
+ * perfect match
+ */
+ leaf->il_at = lvar_lentry(scan);
+ return IAM_LOOKUP_EXACT;
+ } else if (!found_equal) {
+ found = scan;
+ found_equal = 1;
+ }
+ } else {
+ last = 0;
+ break;
+ }
+ }
+ if (found == NULL) {
+ /*
+ * @k is less than all hashes in the leaf.
+ */
+ lvar_start(leaf);
+ result = IAM_LOOKUP_BEFORE;
+ } else {
+ leaf->il_at = lvar_lentry(found);
+ result = IAM_LOOKUP_OK;
+ assert_corr(n_at_rec(leaf));
+ }
+ if (last)
+ result |= IAM_LOOKUP_LAST;
+ assert_inv(n_invariant(leaf));
+
+ return result;
- struct lvar_leaf_entry *scan;
- struct lvar_leaf_entry *end;
- lvar_hash_t hash;
-
- assert_inv(n_invariant(leaf));
- end = n_end(leaf);
- hash = *(const lvar_hash_t *)ik;
-
- lvar_start(leaf);
- for (scan = n_start(leaf); scan < end; scan = e_next(leaf, scan)) {
- lvar_hash_t scan_hash;
-
- scan_hash = e_hash(scan);
- if (scan_hash > hash)
- return scan == n_start(leaf) ?
- IAM_LOOKUP_BEFORE : IAM_LOOKUP_OK;
- leaf->il_at = lvar_lentry(scan);
- if (scan_hash == hash)
- return IAM_LOOKUP_EXACT;
- }
- assert_inv(n_invariant(leaf));
- /*
- * @ik is greater than any key in the node. Return last record in the
- * node.
- */
- return IAM_LOOKUP_OK;
+ struct lvar_leaf_entry *scan;
+ struct lvar_leaf_entry *end;
+ lvar_hash_t hash;
+
+ assert_inv(n_invariant(leaf));
+ end = n_end(leaf);
+ hash = *(const lvar_hash_t *)ik;
+
+ lvar_start(leaf);
+ for (scan = n_start(leaf); scan < end; scan = e_next(leaf, scan)) {
+ lvar_hash_t scan_hash;
+
+ scan_hash = e_hash(scan);
+ if (scan_hash > hash)
+ return scan == n_start(leaf) ?
+ IAM_LOOKUP_BEFORE : IAM_LOOKUP_OK;
+ leaf->il_at = lvar_lentry(scan);
+ if (scan_hash == hash)
+ return IAM_LOOKUP_EXACT;
+ }
+ assert_inv(n_invariant(leaf));
+ /*
+ * @ik is greater than any key in the node. Return last record in the
+ * node.
+ */
+ return IAM_LOOKUP_OK;
- const struct iam_key *k, const struct iam_rec *r)
-{
- const char *key;
- int ksize;
- int shift;
- void *end;
- void *start;
- ptrdiff_t diff;
-
- assert_corr(lvar_can_add(leaf, k, r));
- assert_inv(n_invariant(leaf));
- assert_corr(iam_leaf_is_locked(leaf));
-
- key = kchar(k);
- ksize = strlen(key);
- shift = getsize(leaf, ksize, rec_size(r));
-
- if (!lvar_at_end(leaf)) {
- assert_corr(n_cur(leaf) < n_end(leaf));
- end = n_end(leaf);
- if (lvar_key_cmp(leaf, k) <= 0)
- lvar_next(leaf);
- else
- /*
- * Another exceptional case: insertion with the key
- * less than least key in the leaf.
- */
- assert_corr(leaf->il_at == leaf->il_entries);
-
- start = leaf->il_at;
- diff = PDIFF(end, start);
- assert_corr(diff >= 0);
- memmove(start + shift, start, diff);
- }
- h_used_adj(leaf, n_head(leaf), shift);
- n_cur(leaf)->vle_keysize = cpu_to_le16(ksize);
- n_cur(leaf)->vle_hash = cpu_to_le32(get_hash(iam_leaf_container(leaf),
- key, ksize));
- __lvar_key_set(leaf, k);
- __lvar_rec_set(leaf, r);
- assert_corr(n_at_rec(leaf));
- assert_inv(n_invariant(leaf));
+ const struct iam_key *k, const struct iam_rec *r)
+{
+ const char *key;
+ int ksize;
+ int shift;
+ void *end;
+ void *start;
+ ptrdiff_t diff;
+
+ assert_corr(lvar_can_add(leaf, k, r));
+ assert_inv(n_invariant(leaf));
+ assert_corr(iam_leaf_is_locked(leaf));
+
+ key = kchar(k);
+ ksize = strlen(key);
+ shift = getsize(leaf, ksize, rec_size(r));
+
+ if (!lvar_at_end(leaf)) {
+ assert_corr(n_cur(leaf) < n_end(leaf));
+ end = n_end(leaf);
+ if (lvar_key_cmp(leaf, k) <= 0)
+ lvar_next(leaf);
+ else
+ /*
+ * Another exceptional case: insertion with the key
+ * less than least key in the leaf.
+ */
+ assert_corr(leaf->il_at == leaf->il_entries);
+
+ start = leaf->il_at;
+ diff = PDIFF(end, start);
+ assert_corr(diff >= 0);
+ memmove(start + shift, start, diff);
+ }
+ h_used_adj(leaf, n_head(leaf), shift);
+ n_cur(leaf)->vle_keysize = cpu_to_le16(ksize);
+ n_cur(leaf)->vle_hash = cpu_to_le32(get_hash(iam_leaf_container(leaf),
+ key, ksize));
+ __lvar_key_set(leaf, k);
+ __lvar_rec_set(leaf, r);
+ assert_corr(n_at_rec(leaf));
+ assert_inv(n_invariant(leaf));
- end = n_end(leaf);
- next = e_next(leaf, n_cur(leaf));
- nob = e_size(leaf, n_cur(leaf));
- memmove(leaf->il_at, next, end - next);
- h_used_adj(leaf, n_head(leaf), -nob);
- assert_inv(n_invariant(leaf));
+ end = n_end(leaf);
+ next = e_next(leaf, n_cur(leaf));
+ nob = e_size(leaf, n_cur(leaf));
+ memmove(leaf->il_at, next, end - next);
+ h_used_adj(leaf, n_head(leaf), -nob);
+ assert_inv(n_invariant(leaf));
- iam_ptr_t new_blknr)
-{
- struct lvar_leaf_entry *first_to_move;
- struct lvar_leaf_entry *last_to_stay;
- struct iam_path *path;
- struct lvar_leaf_header *hdr;
- struct buffer_head *new_leaf;
-
- ptrdiff_t tomove;
- lvar_hash_t hash;
-
- assert_inv(n_invariant(leaf));
- assert_corr(iam_leaf_is_locked(leaf));
-
- new_leaf = *bh;
- path = iam_leaf_path(leaf);
-
- hdr = (void *)new_leaf->b_data;
-
- first_to_move = find_pivot(leaf, &last_to_stay);
- assert_corr(last_to_stay != NULL);
- assert_corr(e_next(leaf, last_to_stay) == first_to_move);
-
- hash = e_hash(first_to_move);
- if (hash == e_hash(last_to_stay))
- /*
- * Duplicate hash.
- */
- hash |= 1;
-
- tomove = PDIFF(n_end(leaf), first_to_move);
- memmove(hdr + 1, first_to_move, tomove);
-
- h_used_adj(leaf, hdr, tomove);
- h_used_adj(leaf, n_head(leaf), -tomove);
-
- assert_corr(n_end(leaf) == first_to_move);
-
- if (n_cur(leaf) >= first_to_move) {
- /*
- * insertion point moves into new leaf.
- */
- ptrdiff_t shift;
-
- shift = PDIFF(leaf->il_at, first_to_move);
- *bh = leaf->il_bh;
- leaf->il_bh = new_leaf;
- leaf->il_curidx = new_blknr;
-
- assert_corr(iam_leaf_is_locked(leaf));
- lvar_init(leaf);
- /*
- * init cannot fail, as node was just initialized.
- */
- assert_corr(result == 0);
- leaf->il_at = ((void *)leaf->il_at) + 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, (struct iam_ikey *)&hash,
- new_blknr);
- assert_corr(n_cur(leaf) < n_end(leaf));
- assert_inv(n_invariant(leaf));
+ iam_ptr_t new_blknr)
+{
+ struct lvar_leaf_entry *first_to_move;
+ struct lvar_leaf_entry *last_to_stay;
+ struct iam_path *path;
+ struct lvar_leaf_header *hdr;
+ struct buffer_head *new_leaf;
+ ptrdiff_t tomove;
+ lvar_hash_t hash;
+
+ assert_inv(n_invariant(leaf));
+ assert_corr(iam_leaf_is_locked(leaf));
+
+ new_leaf = *bh;
+ path = iam_leaf_path(leaf);
+
+ hdr = (void *)new_leaf->b_data;
+
+ first_to_move = find_pivot(leaf, &last_to_stay);
+ assert_corr(last_to_stay != NULL);
+ assert_corr(e_next(leaf, last_to_stay) == first_to_move);
+
+ hash = e_hash(first_to_move);
+ if (hash == e_hash(last_to_stay))
+ /*
+ * Duplicate hash.
+ */
+ hash |= 1;
+
+ tomove = PDIFF(n_end(leaf), first_to_move);
+ memmove(hdr + 1, first_to_move, tomove);
+
+ h_used_adj(leaf, hdr, tomove);
+ h_used_adj(leaf, n_head(leaf), -tomove);
+
+ assert_corr(n_end(leaf) == first_to_move);
+
+ if (n_cur(leaf) >= first_to_move) {
+ /*
+ * insertion point moves into new leaf.
+ */
+ ptrdiff_t shift;
+
+ shift = PDIFF(leaf->il_at, first_to_move);
+ *bh = leaf->il_bh;
+ leaf->il_bh = new_leaf;
+ leaf->il_curidx = new_blknr;
+
+ assert_corr(iam_leaf_is_locked(leaf));
+ lvar_init(leaf);
+ /*
+ * init cannot fail, as node was just initialized.
+ */
+ assert_corr(result == 0);
+ leaf->il_at = ((void *)leaf->il_at) + 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, (struct iam_ikey *)&hash,
+ new_blknr);
+ assert_corr(n_cur(leaf) < n_end(leaf));
+ assert_inv(n_invariant(leaf));
- .init = lvar_init,
- .init_new = lvar_init_new,
- .fini = lvar_fini,
- .start = lvar_start,
- .next = lvar_next,
- .key = lvar_key,
- .ikey = lvar_ikey,
- .rec = lvar_rec,
- .key_set = lvar_key_set,
- .key_cmp = lvar_key_cmp,
- .key_eq = lvar_key_eq,
- .key_size = lvar_key_size,
- .rec_set = lvar_rec_set,
+ .init = lvar_init,
+ .init_new = lvar_init_new,
+ .fini = lvar_fini,
+ .start = lvar_start,
+ .next = lvar_next,
+ .key = lvar_key,
+ .ikey = lvar_ikey,
+ .rec = lvar_rec,
+ .key_set = lvar_key_set,
+ .key_cmp = lvar_key_cmp,
+ .key_eq = lvar_key_eq,
+ .key_size = lvar_key_size,
+ .rec_set = lvar_rec_set,
- .rec_get = lvar_rec_get,
- .lookup = lvar_lookup,
- .ilookup = lvar_ilookup,
- .at_end = lvar_at_end,
- .rec_add = lvar_rec_add,
- .rec_del = lvar_rec_del,
- .can_add = lvar_can_add,
+ .rec_get = lvar_rec_get,
+ .lookup = lvar_lookup,
+ .ilookup = lvar_ilookup,
+ .at_end = lvar_at_end,
+ .rec_add = lvar_rec_add,
+ .rec_del = lvar_rec_del,
+ .can_add = lvar_can_add,
- root = (void *)frame->bh->b_data;
- assert_corr(le64_to_cpu(root->vr_magic) == IAM_LVAR_ROOT_MAGIC);
- root->vr_indirect_levels ++;
- frame->at = entries = iam_entry_shift(path, entries, 1);
- memset(iam_ikey_at(path, entries), 0,
- iam_path_descr(path)->id_ikey_size);
- return entries;
+ root = (void *)frame->bh->b_data;
+ assert_corr(le64_to_cpu(root->vr_magic) == IAM_LVAR_ROOT_MAGIC);
+ root->vr_indirect_levels++;
+ frame->at = entries = iam_entry_shift(path, entries, 1);
+ memset(iam_ikey_at(path, entries), 0,
+ iam_path_descr(path)->id_ikey_size);
+ return entries;
- root = data;
- name = kchar(path->ip_key_target);
- path->ip_indirect = root->vr_indirect_levels;
- if (path->ip_ikey_target == NULL) {
- path->ip_ikey_target = iam_path_ikey(path, 4);
- *(lvar_hash_t *)path->ip_ikey_target =
- get_hash(path->ip_container, name,
- strlen(name));
- }
- }
- frame->entries = frame->at = entries;
- return 0;
+ root = data;
+ name = kchar(path->ip_key_target);
+ path->ip_indirect = root->vr_indirect_levels;
+ if (path->ip_ikey_target == NULL) {
+ path->ip_ikey_target = iam_path_ikey(path, 4);
+ *(lvar_hash_t *)path->ip_ikey_target =
+ get_hash(path->ip_container, name,
+ strlen(name));
+ }
+ }
+ frame->entries = frame->at = entries;
+ return 0;
- int blocksize, int keysize, int ptrsize, int recsize)
-{
- struct lvar_root *root;
- struct dx_countlimit *limit;
- void *entry;
- int isize;
-
- isize = sizeof(lvar_hash_t) + ptrsize;
- root = buf;
- *root = (typeof(*root)) {
- .vr_magic = cpu_to_le32(IAM_LVAR_ROOT_MAGIC),
- .vr_recsize = cpu_to_le16(recsize),
- .vr_ptrsize = cpu_to_le16(ptrsize),
- .vr_indirect_levels = 0
- };
-
- limit = (void *)(root + 1);
- *limit = (typeof(*limit)){
- /*
- * limit itself + one pointer to the leaf.
- */
- .count = cpu_to_le16(2),
- .limit = iam_root_limit(sizeof(struct lvar_root), blocksize,
- sizeof (lvar_hash_t) + ptrsize)
- };
+ int blocksize, int keysize, int ptrsize, int recsize)
+{
+ struct lvar_root *root;
+ struct dx_countlimit *limit;
+ void *entry;
+ int isize;
+
+ isize = sizeof(lvar_hash_t) + ptrsize;
+ root = buf;
+ *root = (typeof(*root)) {
+ .vr_magic = cpu_to_le32(IAM_LVAR_ROOT_MAGIC),
+ .vr_recsize = cpu_to_le16(recsize),
+ .vr_ptrsize = cpu_to_le16(ptrsize),
+ .vr_indirect_levels = 0
+ };
+
+ limit = (void *)(root + 1);
+ *limit = (typeof(*limit)){
+ /*
+ * limit itself + one pointer to the leaf.
+ */
+ .count = cpu_to_le16(2),
+ .limit = iam_root_limit(sizeof(struct lvar_root), blocksize,
+ sizeof(lvar_hash_t) + ptrsize)
+ };
- /*
- * Entry format is <key> followed by <ptr>. In the minimal tree
- * consisting of a root and single node, <key> is a minimal possible
- * key.
- */
- *(lvar_hash_t *)entry = 0;
- entry += sizeof(lvar_hash_t);
- /* now @entry points to <ptr> */
- if (ptrsize == 4)
- *(u_int32_t *)entry = cpu_to_le32(1);
- else
- *(u_int64_t *)entry = cpu_to_le64(1);
+ /*
+ * Entry format is <key> followed by <ptr>. In the minimal tree
+ * consisting of a root and single node, <key> is a minimal possible
+ * key.
+ */
+ *(lvar_hash_t *)entry = 0;
+ entry += sizeof(lvar_hash_t);
+ /* now @entry points to <ptr> */
+ if (ptrsize == 4)
+ *(u_int32_t *)entry = cpu_to_le32(1);
+ else
+ *(u_int64_t *)entry = cpu_to_le64(1);
- int blocksize, int keysize, int ptrsize, int recsize)
-{
- struct lvar_leaf_header *head;
- struct lvar_leaf_entry *entry;
-
- /* form leaf */
- head = buf;
- *head = (typeof(*head)) {
- .vlh_magic = cpu_to_le16(IAM_LVAR_LEAF_MAGIC),
- .vlh_used = cpu_to_le16(sizeof *head + lvar_esize(0, recsize))
- };
- entry = (void *)(head + 1);
- *entry = (typeof(*entry)) {
- .vle_hash = 0,
- .vle_keysize = 0
- };
- memset(e_rec(entry), 0, recsize);
- *(char *)e_rec(entry) = recsize;
+ int blocksize, int keysize, int ptrsize, int recsize)
+{
+ struct lvar_leaf_header *head;
+ struct lvar_leaf_entry *entry;
+
+ /* form leaf */
+ head = buf;
+ *head = (typeof(*head)) {
+ .vlh_magic = cpu_to_le16(IAM_LVAR_LEAF_MAGIC),
+ .vlh_used = cpu_to_le16(sizeof(*head) + lvar_esize(0, recsize))
+ };
+ entry = (void *)(head + 1);
+ *entry = (typeof(*entry)) {
+ .vle_hash = 0,
+ .vle_keysize = 0
+ };
+ memset(e_rec(entry), 0, recsize);
+ *(char *)e_rec(entry) = recsize;
- .id_root_ptr = lvar_root_ptr,
- .id_node_read = iam_node_read,
- .id_node_init = lvar_node_init,
- .id_node_check = lvar_node_check,
- .id_node_load = lvar_node_load,
- .id_ikeycmp = lvar_ikeycmp,
- .id_root_inc = lvar_root_inc,
- .id_ipd_alloc = lvar_ipd_alloc,
- .id_ipd_free = iam_ipd_free,
- .id_name = "lvar"
+ .id_root_ptr = lvar_root_ptr,
+ .id_node_read = iam_node_read,
+ .id_node_init = lvar_node_init,
+ .id_node_check = lvar_node_check,
+ .id_node_load = lvar_node_load,
+ .id_ikeycmp = lvar_ikeycmp,
+ .id_root_inc = lvar_root_inc,
+ .id_ipd_alloc = lvar_ipd_alloc,
+ .id_ipd_free = iam_ipd_free,
+ .id_name = "lvar"
- result = iam_node_read(c, lvar_root_ptr(c), NULL, &bh);
- if (result == 0) {
- root = (void *)bh->b_data;
- if (le32_to_cpu(root->vr_magic) == IAM_LVAR_ROOT_MAGIC) {
- struct iam_descr *descr;
-
- descr = c->ic_descr;
- descr->id_key_size = LDISKFS_NAME_LEN;
- descr->id_ikey_size = sizeof (lvar_hash_t);
- descr->id_rec_size = le16_to_cpu(root->vr_recsize);
- descr->id_ptr_size = le16_to_cpu(root->vr_ptrsize);
- descr->id_root_gap = sizeof *root;
- descr->id_node_gap = 0;
- descr->id_ops = &lvar_ops;
- descr->id_leaf_ops = &lvar_leaf_ops;
+ result = iam_node_read(c, lvar_root_ptr(c), NULL, &bh);
+ if (result == 0) {
+ root = (void *)bh->b_data;