Lines Matching full:k
30 static int deleted_key_validate(struct bch_fs *c, struct bkey_s_c k, in deleted_key_validate() argument
44 static int empty_val_key_validate(struct bch_fs *c, struct bkey_s_c k, in empty_val_key_validate() argument
49 bkey_fsck_err_on(bkey_val_bytes(k.k), in empty_val_key_validate()
52 bkey_val_bytes(k.k)); in empty_val_key_validate()
61 static int key_type_cookie_validate(struct bch_fs *c, struct bkey_s_c k, in key_type_cookie_validate() argument
68 struct bkey_s_c k) in key_type_cookie_to_text() argument
70 struct bkey_s_c_cookie ck = bkey_s_c_to_cookie(k); in key_type_cookie_to_text()
85 static int key_type_inline_data_validate(struct bch_fs *c, struct bkey_s_c k, in key_type_inline_data_validate() argument
92 struct bkey_s_c k) in key_type_inline_data_to_text() argument
94 struct bkey_s_c_inline_data d = bkey_s_c_to_inline_data(k); in key_type_inline_data_to_text()
95 unsigned datalen = bkey_inline_data_bytes(k.k); in key_type_inline_data_to_text()
108 bch2_key_resize(l.k, l.k->size + r.k->size); in key_type_set_merge()
126 int bch2_bkey_val_validate(struct bch_fs *c, struct bkey_s_c k, in bch2_bkey_val_validate() argument
132 const struct bkey_ops *ops = bch2_bkey_type_ops(k.k->type); in bch2_bkey_val_validate()
135 bkey_fsck_err_on(bkey_val_bytes(k.k) < ops->min_val_size, in bch2_bkey_val_validate()
138 bkey_val_bytes(k.k), ops->min_val_size); in bch2_bkey_val_validate()
143 ret = ops->key_validate(c, k, flags); in bch2_bkey_val_validate()
163 int __bch2_bkey_validate(struct bch_fs *c, struct bkey_s_c k, in __bch2_bkey_validate() argument
172 bkey_fsck_err_on(k.k->u64s < BKEY_U64s, in __bch2_bkey_validate()
174 "u64s too small (%u < %zu)", k.k->u64s, BKEY_U64s); in __bch2_bkey_validate()
179 bkey_fsck_err_on(k.k->type < KEY_TYPE_MAX && in __bch2_bkey_validate()
181 !(bch2_key_types_allowed[type] & BIT_ULL(k.k->type)), in __bch2_bkey_validate()
185 k.k->type < KEY_TYPE_MAX in __bch2_bkey_validate()
186 ? bch2_bkey_types[k.k->type] in __bch2_bkey_validate()
189 if (btree_node_type_is_extents(type) && !bkey_whiteout(k.k)) { in __bch2_bkey_validate()
190 bkey_fsck_err_on(k.k->size == 0, in __bch2_bkey_validate()
194 bkey_fsck_err_on(k.k->size > k.k->p.offset, in __bch2_bkey_validate()
197 k.k->size, k.k->p.offset); in __bch2_bkey_validate()
199 bkey_fsck_err_on(k.k->size, in __bch2_bkey_validate()
208 bkey_fsck_err_on(!k.k->p.snapshot, in __bch2_bkey_validate()
212 bkey_fsck_err_on(k.k->p.snapshot, in __bch2_bkey_validate()
222 bkey_fsck_err_on(bkey_eq(k.k->p, POS_MAX), in __bch2_bkey_validate()
230 int bch2_bkey_validate(struct bch_fs *c, struct bkey_s_c k, in bch2_bkey_validate() argument
234 return __bch2_bkey_validate(c, k, type, flags) ?: in bch2_bkey_validate()
235 bch2_bkey_val_validate(c, k, flags); in bch2_bkey_validate()
239 struct bkey_s_c k, enum bch_validate_flags flags) in bch2_bkey_in_btree_node() argument
243 bkey_fsck_err_on(bpos_lt(k.k->p, b->data->min_key), in bch2_bkey_in_btree_node()
247 bkey_fsck_err_on(bpos_gt(k.k->p, b->data->max_key), in bch2_bkey_in_btree_node()
280 void bch2_bkey_to_text(struct printbuf *out, const struct bkey *k) in bch2_bkey_to_text() argument
282 if (k) { in bch2_bkey_to_text()
283 prt_printf(out, "u64s %u type ", k->u64s); in bch2_bkey_to_text()
285 if (k->type < KEY_TYPE_MAX) in bch2_bkey_to_text()
286 prt_printf(out, "%s ", bch2_bkey_types[k->type]); in bch2_bkey_to_text()
288 prt_printf(out, "%u ", k->type); in bch2_bkey_to_text()
290 bch2_bpos_to_text(out, k->p); in bch2_bkey_to_text()
292 prt_printf(out, " len %u ver %llu", k->size, k->bversion.lo); in bch2_bkey_to_text()
299 struct bkey_s_c k) in bch2_val_to_text() argument
301 const struct bkey_ops *ops = bch2_bkey_type_ops(k.k->type); in bch2_val_to_text()
304 ops->val_to_text(out, c, k); in bch2_val_to_text()
308 struct bkey_s_c k) in bch2_bkey_val_to_text() argument
310 bch2_bkey_to_text(out, k.k); in bch2_bkey_val_to_text()
312 if (bkey_val_bytes(k.k)) { in bch2_bkey_val_to_text()
314 bch2_val_to_text(out, c, k); in bch2_bkey_val_to_text()
318 void bch2_bkey_swab_val(struct bkey_s k) in bch2_bkey_swab_val() argument
320 const struct bkey_ops *ops = bch2_bkey_type_ops(k.k->type); in bch2_bkey_swab_val()
323 ops->swab(k); in bch2_bkey_swab_val()
326 bool bch2_bkey_normalize(struct bch_fs *c, struct bkey_s k) in bch2_bkey_normalize() argument
328 const struct bkey_ops *ops = bch2_bkey_type_ops(k.k->type); in bch2_bkey_normalize()
331 ? ops->key_normalize(c, k) in bch2_bkey_normalize()
337 const struct bkey_ops *ops = bch2_bkey_type_ops(l.k->type); in bch2_bkey_merge()
340 bch2_bkey_maybe_mergable(l.k, r.k) && in bch2_bkey_merge()
341 (u64) l.k->size + r.k->size <= KEY_SIZE_MAX && in bch2_bkey_merge()
366 struct bkey_packed *k, in bch2_bkey_renumber() argument
375 k->type == (write ? i->new : i->old)) { in bch2_bkey_renumber()
376 k->type = write ? i->old : i->new; in bch2_bkey_renumber()
385 struct bkey_packed *k) in __bch2_bkey_compat() argument
400 bch2_bkey_swab_key(f, k); in __bch2_bkey_compat()
402 bch2_bkey_swab_key(f, k); in __bch2_bkey_compat()
403 bch2_bkey_swab_key(f, k); in __bch2_bkey_compat()
408 bch2_bkey_renumber(__btree_node_type(level, btree_id), k, write); in __bch2_bkey_compat()
413 if (!bkey_packed(k)) { in __bch2_bkey_compat()
414 struct bkey_i *u = packed_to_bkey(k); in __bch2_bkey_compat()
416 swap(u->k.p.inode, u->k.p.offset); in __bch2_bkey_compat()
429 uk = __bch2_bkey_unpack_key(in, k); in __bch2_bkey_compat()
431 BUG_ON(!bch2_bkey_pack_key(k, &uk, out)); in __bch2_bkey_compat()
438 struct bkey_i *u = packed_to_bkey(k); in __bch2_bkey_compat()
441 u->k.p.snapshot = write in __bch2_bkey_compat()
448 uk = __bch2_bkey_unpack_key(f, k); in __bch2_bkey_compat()
452 BUG_ON(!bch2_bkey_pack_key(k, &uk, f)); in __bch2_bkey_compat()
460 if (!bkey_packed(k)) { in __bch2_bkey_compat()
461 u = bkey_i_to_s(packed_to_bkey(k)); in __bch2_bkey_compat()
463 uk = __bch2_bkey_unpack_key(f, k); in __bch2_bkey_compat()
464 u.k = &uk; in __bch2_bkey_compat()
465 u.v = bkeyp_val(f, k); in __bch2_bkey_compat()
471 ops = bch2_bkey_type_ops(k->type); in __bch2_bkey_compat()