bset.h (c052dd9a26f60bcf70c0c3fcc08e07abb60295cd) bset.h (dc9d98d621bdce0552997200ce855659875a5c9f)
1#ifndef _BCACHE_BSET_H
2#define _BCACHE_BSET_H
3
4#include <linux/slab.h>
5
6#include "util.h" /* for time_stats */
7
8/*

--- 179 unchanged lines hidden (view full) ---

188 bool (*sort_cmp)(struct btree_iter_set,
189 struct btree_iter_set);
190 struct bkey *(*sort_fixup)(struct btree_iter *, struct bkey *);
191 bool (*key_invalid)(struct btree_keys *,
192 const struct bkey *);
193 bool (*key_bad)(struct btree_keys *, const struct bkey *);
194 bool (*key_merge)(struct btree_keys *,
195 struct bkey *, struct bkey *);
1#ifndef _BCACHE_BSET_H
2#define _BCACHE_BSET_H
3
4#include <linux/slab.h>
5
6#include "util.h" /* for time_stats */
7
8/*

--- 179 unchanged lines hidden (view full) ---

188 bool (*sort_cmp)(struct btree_iter_set,
189 struct btree_iter_set);
190 struct bkey *(*sort_fixup)(struct btree_iter *, struct bkey *);
191 bool (*key_invalid)(struct btree_keys *,
192 const struct bkey *);
193 bool (*key_bad)(struct btree_keys *, const struct bkey *);
194 bool (*key_merge)(struct btree_keys *,
195 struct bkey *, struct bkey *);
196 void (*key_to_text)(char *, size_t, const struct bkey *);
197 void (*key_dump)(struct btree_keys *, const struct bkey *);
196
197 /*
198 * Only used for deciding whether to use START_KEY(k) or just the key
199 * itself in a couple places
200 */
201 bool is_extents;
202};
203

--- 34 unchanged lines hidden (view full) ---

238 return ((size_t) i) - ((size_t) b->set->data);
239}
240
241static inline unsigned bset_sector_offset(struct btree_keys *b, struct bset *i)
242{
243 return bset_byte_offset(b, i) >> 9;
244}
245
198
199 /*
200 * Only used for deciding whether to use START_KEY(k) or just the key
201 * itself in a couple places
202 */
203 bool is_extents;
204};
205

--- 34 unchanged lines hidden (view full) ---

240 return ((size_t) i) - ((size_t) b->set->data);
241}
242
243static inline unsigned bset_sector_offset(struct btree_keys *b, struct bset *i)
244{
245 return bset_byte_offset(b, i) >> 9;
246}
247
246static inline bool btree_keys_expensive_checks(struct btree_keys *b)
247{
248#ifdef CONFIG_BCACHE_DEBUG
249 return *b->expensive_debug_checks;
250#else
251 return false;
252#endif
253}
254
255#define __set_bytes(i, k) (sizeof(*(i)) + (k) * sizeof(uint64_t))
256#define set_bytes(i) __set_bytes(i, i->keys)
257
258#define __set_blocks(i, k, block_bytes) \
259 DIV_ROUND_UP(__set_bytes(i, k), block_bytes)
260#define set_blocks(i, block_bytes) \
261 __set_blocks(i, (i)->keys, block_bytes)
262

--- 178 unchanged lines hidden (view full) ---

441 return b->ops->key_invalid(b, k);
442}
443
444static inline bool bch_ptr_bad(struct btree_keys *b, const struct bkey *k)
445{
446 return b->ops->key_bad(b, k);
447}
448
248#define __set_bytes(i, k) (sizeof(*(i)) + (k) * sizeof(uint64_t))
249#define set_bytes(i) __set_bytes(i, i->keys)
250
251#define __set_blocks(i, k, block_bytes) \
252 DIV_ROUND_UP(__set_bytes(i, k), block_bytes)
253#define set_blocks(i, block_bytes) \
254 __set_blocks(i, (i)->keys, block_bytes)
255

--- 178 unchanged lines hidden (view full) ---

434 return b->ops->key_invalid(b, k);
435}
436
437static inline bool bch_ptr_bad(struct btree_keys *b, const struct bkey *k)
438{
439 return b->ops->key_bad(b, k);
440}
441
442static inline void bch_bkey_to_text(struct btree_keys *b, char *buf,
443 size_t size, const struct bkey *k)
444{
445 return b->ops->key_to_text(buf, size, k);
446}
447
449/* Keylists */
450
451struct keylist {
452 union {
453 struct bkey *keys;
454 uint64_t *keys_p;
455 };
456 union {

--- 47 unchanged lines hidden (view full) ---

504{
505 return bch_keylist_nkeys(l) * sizeof(uint64_t);
506}
507
508struct bkey *bch_keylist_pop(struct keylist *);
509void bch_keylist_pop_front(struct keylist *);
510int __bch_keylist_realloc(struct keylist *, unsigned);
511
448/* Keylists */
449
450struct keylist {
451 union {
452 struct bkey *keys;
453 uint64_t *keys_p;
454 };
455 union {

--- 47 unchanged lines hidden (view full) ---

503{
504 return bch_keylist_nkeys(l) * sizeof(uint64_t);
505}
506
507struct bkey *bch_keylist_pop(struct keylist *);
508void bch_keylist_pop_front(struct keylist *);
509int __bch_keylist_realloc(struct keylist *, unsigned);
510
512struct cache_set;
513const char *bch_ptr_status(struct cache_set *, const struct bkey *);
511/* Debug stuff */
514
512
513#ifdef CONFIG_BCACHE_DEBUG
514
515int __bch_count_data(struct btree_keys *);
516void __bch_check_keys(struct btree_keys *, const char *, ...);
517void bch_dump_bset(struct btree_keys *, struct bset *, unsigned);
518void bch_dump_bucket(struct btree_keys *);
519
520#else
521
522static inline int __bch_count_data(struct btree_keys *b) { return -1; }
523static inline void __bch_check_keys(struct btree_keys *b, const char *fmt, ...) {}
524static inline void bch_dump_bucket(struct btree_keys *b) {}
525void bch_dump_bset(struct btree_keys *, struct bset *, unsigned);
526
515#endif
527#endif
528
529static inline bool btree_keys_expensive_checks(struct btree_keys *b)
530{
531#ifdef CONFIG_BCACHE_DEBUG
532 return *b->expensive_debug_checks;
533#else
534 return false;
535#endif
536}
537
538static inline int bch_count_data(struct btree_keys *b)
539{
540 return btree_keys_expensive_checks(b) ? __bch_count_data(b) : -1;
541}
542
543#define bch_check_keys(b, ...) \
544do { \
545 if (btree_keys_expensive_checks(b)) \
546 __bch_check_keys(b, __VA_ARGS__); \
547} while (0)
548
549#endif