1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_BKEY_ON_STACK_H
3 #define _BCACHEFS_BKEY_ON_STACK_H
12 static inline void bkey_on_stack_realloc(struct bkey_on_stack *s,
13 struct bch_fs *c, unsigned u64s)
15 if (s->k == (void *) s->onstack &&
16 u64s > ARRAY_SIZE(s->onstack)) {
17 s->k = mempool_alloc(&c->large_bkey_pool, GFP_NOFS);
18 memcpy(s->k, s->onstack, sizeof(s->onstack));
22 static inline void bkey_on_stack_init(struct bkey_on_stack *s)
24 s->k = (void *) s->onstack;
27 static inline void bkey_on_stack_exit(struct bkey_on_stack *s,
30 if (s->k != (void *) s->onstack)
31 mempool_free(s->k, &c->large_bkey_pool);
35 #endif /* _BCACHEFS_BKEY_ON_STACK_H */