Lines Matching full:k
36 const struct bkey *k; member
44 struct bkey *k; member
53 static inline struct bkey_i *bkey_next(struct bkey_i *k) in bkey_next() argument
55 return (struct bkey_i *) ((u64 *) k->_data + k->k.u64s); in bkey_next()
60 static inline size_t bkey_val_bytes(const struct bkey *k) in bkey_val_bytes() argument
62 return bkey_val_u64s(k) * sizeof(u64); in bkey_val_bytes()
65 static inline void set_bkey_val_u64s(struct bkey *k, unsigned val_u64s) in set_bkey_val_u64s() argument
70 k->u64s = u64s; in set_bkey_val_u64s()
73 static inline void set_bkey_val_bytes(struct bkey *k, unsigned bytes) in set_bkey_val_bytes() argument
75 set_bkey_val_u64s(k, DIV_ROUND_UP(bytes, sizeof(u64))); in set_bkey_val_bytes()
78 #define bkey_val_end(_k) ((void *) (((u64 *) (_k).v) + bkey_val_u64s((_k).k)))
102 memcpy_u64s_small(dst, src, src->k.u64s); in bkey_copy()
277 static inline struct bkey_packed *bkey_to_packed(struct bkey_i *k) in bkey_to_packed() argument
279 return (struct bkey_packed *) k; in bkey_to_packed()
282 static inline const struct bkey_packed *bkey_to_packed_c(const struct bkey_i *k) in bkey_to_packed_c() argument
284 return (const struct bkey_packed *) k; in bkey_to_packed_c()
287 static inline struct bkey_i *packed_to_bkey(struct bkey_packed *k) in packed_to_bkey() argument
289 return bkey_packed(k) ? NULL : (struct bkey_i *) k; in packed_to_bkey()
292 static inline const struct bkey *packed_to_bkey_c(const struct bkey_packed *k) in packed_to_bkey_c() argument
294 return bkey_packed(k) ? NULL : (const struct bkey *) k; in packed_to_bkey_c()
346 static inline u64 bkey_start_offset(const struct bkey *k) in bkey_start_offset() argument
348 return k->p.offset - k->size; in bkey_start_offset()
351 static inline struct bpos bkey_start_pos(const struct bkey *k) in bkey_start_pos() argument
354 .inode = k->p.inode, in bkey_start_pos()
355 .offset = bkey_start_offset(k), in bkey_start_pos()
356 .snapshot = k->p.snapshot, in bkey_start_pos()
363 const struct bkey_packed *k) in bkeyp_key_u64s() argument
365 unsigned ret = bkey_packed(k) ? format->key_u64s : BKEY_U64s; in bkeyp_key_u64s()
367 EBUG_ON(k->u64s < ret); in bkeyp_key_u64s()
372 const struct bkey_packed *k) in bkeyp_key_bytes() argument
374 return bkeyp_key_u64s(format, k) * sizeof(u64); in bkeyp_key_bytes()
378 const struct bkey_packed *k) in bkeyp_val_u64s() argument
380 return k->u64s - bkeyp_key_u64s(format, k); in bkeyp_val_u64s()
384 const struct bkey_packed *k) in bkeyp_val_bytes() argument
386 return bkeyp_val_u64s(format, k) * sizeof(u64); in bkeyp_val_bytes()
390 struct bkey_packed *k, unsigned val_u64s) in set_bkeyp_val_u64s() argument
392 k->u64s = bkeyp_key_u64s(format, k) + val_u64s; in set_bkeyp_val_u64s()
511 const struct bkey_packed *k, in bkey_disassemble() argument
514 __bkey_unpack_key(b, u, k); in bkey_disassemble()
516 return (struct bkey_s_c) { u, bkeyp_val(&b->format, k), }; in bkey_disassemble()
521 struct bkey_packed *k, in __bkey_disassemble() argument
524 __bkey_unpack_key(b, u, k); in __bkey_disassemble()
526 return (struct bkey_s) { .k = u, .v = bkeyp_val(&b->format, k), }; in __bkey_disassemble()
552 dst->k = *src.k; in bkey_reassemble()
553 memcpy_u64s_small(&dst->v, src.v, bkey_val_u64s(src.k)); in bkey_reassemble()
556 #define bkey_s_null ((struct bkey_s) { .k = NULL })
557 #define bkey_s_c_null ((struct bkey_s_c) { .k = NULL })
559 #define bkey_s_err(err) ((struct bkey_s) { .k = ERR_PTR(err) })
560 #define bkey_s_c_err(err) ((struct bkey_s_c) { .k = ERR_PTR(err) })
562 static inline struct bkey_s bkey_to_s(struct bkey *k) in bkey_to_s() argument
564 return (struct bkey_s) { .k = k, .v = NULL }; in bkey_to_s()
567 static inline struct bkey_s_c bkey_to_s_c(const struct bkey *k) in bkey_to_s_c() argument
569 return (struct bkey_s_c) { .k = k, .v = NULL }; in bkey_to_s_c()
572 static inline struct bkey_s bkey_i_to_s(struct bkey_i *k) in bkey_i_to_s() argument
574 return (struct bkey_s) { .k = &k->k, .v = &k->v }; in bkey_i_to_s()
577 static inline struct bkey_s_c bkey_i_to_s_c(const struct bkey_i *k) in bkey_i_to_s_c() argument
579 return (struct bkey_s_c) { .k = &k->k, .v = &k->v }; in bkey_i_to_s_c()
594 struct bkey k; \
603 const struct bkey *k; \
613 struct bkey *k; \
622 static inline struct bkey_i_##name *bkey_i_to_##name(struct bkey_i *k) \
624 EBUG_ON(!IS_ERR_OR_NULL(k) && k->k.type != KEY_TYPE_##name); \
625 return container_of(&k->k, struct bkey_i_##name, k); \
629 bkey_i_to_##name##_c(const struct bkey_i *k) \
631 EBUG_ON(!IS_ERR_OR_NULL(k) && k->k.type != KEY_TYPE_##name); \
632 return container_of(&k->k, struct bkey_i_##name, k); \
635 static inline struct bkey_s_##name bkey_s_to_##name(struct bkey_s k) \
637 EBUG_ON(!IS_ERR_OR_NULL(k.k) && k.k->type != KEY_TYPE_##name); \
639 .k = k.k, \
640 .v = container_of(k.v, struct bch_##name, v), \
644 static inline struct bkey_s_c_##name bkey_s_c_to_##name(struct bkey_s_c k)\
646 EBUG_ON(!IS_ERR_OR_NULL(k.k) && k.k->type != KEY_TYPE_##name); \
648 .k = k.k, \
649 .v = container_of(k.v, struct bch_##name, v), \
653 static inline struct bkey_s_##name name##_i_to_s(struct bkey_i_##name *k)\
656 .k = &k->k, \
657 .v = &k->v, \
662 name##_i_to_s_c(const struct bkey_i_##name *k) \
665 .k = &k->k, \
666 .v = &k->v, \
670 static inline struct bkey_s_##name bkey_i_to_s_##name(struct bkey_i *k) \
672 EBUG_ON(!IS_ERR_OR_NULL(k) && k->k.type != KEY_TYPE_##name); \
674 .k = &k->k, \
675 .v = container_of(&k->v, struct bch_##name, v), \
680 bkey_i_to_s_c_##name(const struct bkey_i *k) \
682 EBUG_ON(!IS_ERR_OR_NULL(k) && k->k.type != KEY_TYPE_##name); \
684 .k = &k->k, \
685 .v = container_of(&k->v, struct bch_##name, v), \
691 struct bkey_i_##name *k = \
692 container_of(&_k->k, struct bkey_i_##name, k); \
694 bkey_init(&k->k); \
695 memset(&k->v, 0, sizeof(k->v)); \
696 k->k.type = KEY_TYPE_##name; \
697 set_bkey_val_bytes(&k->k, sizeof(k->v)); \
699 return k; \
731 #define high_word(f, k) ((u64 *) (k)->_data + high_word_offset(f)) argument
763 * Changes @format so that @k can be successfully packed with @format
765 static inline void bch2_bkey_format_add_key(struct bkey_format_state *s, const struct bkey *k) in bch2_bkey_format_add_key() argument
767 #define x(id, field) __bkey_format_add(s, id, k->field); in bch2_bkey_format_add_key()