diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2016-01-25 14:54:45 -0900 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2016-10-07 12:35:23 -0800 |
commit | d76f59b5f9ca8f1ead176014160f35ebc1b70a23 (patch) | |
tree | 939cc4780cb33dca465d54b4393b730763781cc1 | |
parent | 04caca85526c70fa1eee1ad8aefd1cbc53f4ad75 (diff) |
bcache: Clean up some constants
-rw-r--r-- | drivers/md/bcache/bset.h | 21 | ||||
-rw-r--r-- | drivers/md/bcache/btree_gc.c | 2 | ||||
-rw-r--r-- | drivers/md/bcache/btree_update.c | 2 | ||||
-rw-r--r-- | drivers/md/bcache/extents.c | 2 | ||||
-rw-r--r-- | drivers/md/bcache/io.c | 2 | ||||
-rw-r--r-- | drivers/md/bcache/io_types.h | 2 | ||||
-rw-r--r-- | drivers/md/bcache/journal.c | 2 | ||||
-rw-r--r-- | drivers/md/bcache/keylist.c | 2 | ||||
-rw-r--r-- | drivers/md/bcache/keylist.h | 6 | ||||
-rw-r--r-- | drivers/md/bcache/keylist_types.h | 4 | ||||
-rw-r--r-- | drivers/md/bcache/tier.c | 2 | ||||
-rw-r--r-- | include/uapi/linux/bcache.h | 20 |
12 files changed, 33 insertions, 34 deletions
diff --git a/drivers/md/bcache/bset.h b/drivers/md/bcache/bset.h index 0ca13c51e3be..43298b81027b 100644 --- a/drivers/md/bcache/bset.h +++ b/drivers/md/bcache/bset.h @@ -346,27 +346,6 @@ static inline void btree_keys_account_key(struct btree_nr_keys *n, /* Bkey utility code */ -/* Amount of space we might need, in order to add a single pointer */ - -/* XXX: move constants to uapi/linux/bcache.h */ - -#define BKEY_EXTENT_PTR_MAX_U64s \ - ((sizeof(struct bch_extent_crc64) + \ - sizeof(struct bch_extent_ptr)) / sizeof(u64)) - -#if 0 -#define BKEY_EXTENT_VAL_U64s_MAX \ - ((sizeof(struct bch_extent_crc64) + - sizeof(struct bch_extent_ptr)) * BCH_REPLICAS_MAX) -#else -#define BKEY_EXTENT_VAL_U64s_MAX 8 -#endif - -#define BKEY_EXTENT_MAX_U64s (BKEY_U64s + BKEY_EXTENT_VAL_U64s_MAX) - -#define BKEY_BTREE_PTR_VAL_U64s_MAX BCH_REPLICAS_MAX -#define BKEY_BTREE_PTR_U64s_MAX (BKEY_U64s + BCH_REPLICAS_MAX) - #define BKEY_PADDED(key) __BKEY_PADDED(key, BKEY_EXTENT_VAL_U64s_MAX) #define __bkey_idx(_set, _offset) \ diff --git a/drivers/md/bcache/btree_gc.c b/drivers/md/bcache/btree_gc.c index a0fce4a155d5..709daaba52dd 100644 --- a/drivers/md/bcache/btree_gc.c +++ b/drivers/md/bcache/btree_gc.c @@ -488,7 +488,7 @@ static void bch_coalesce_nodes(struct btree *old_nodes[GC_MERGE_NODES], return; if (bch_keylist_realloc(&keylist, - (BKEY_U64s + BKEY_EXTENT_MAX_U64s) * nr_old_nodes)) { + (BKEY_U64s + BKEY_EXTENT_U64s_MAX) * nr_old_nodes)) { trace_bcache_btree_gc_coalesce_fail(c); goto out; } diff --git a/drivers/md/bcache/btree_update.c b/drivers/md/bcache/btree_update.c index 0136601841e8..379b0505f552 100644 --- a/drivers/md/bcache/btree_update.c +++ b/drivers/md/bcache/btree_update.c @@ -808,7 +808,7 @@ static bool __have_enough_space(struct cache_set *c, struct btree *b, * needs room for at least three keys to make forward * progress. */ - u64s = b->keys.ops->is_extents ? BKEY_EXTENT_MAX_U64s * 3 : u64s; + u64s = b->keys.ops->is_extents ? BKEY_EXTENT_U64s_MAX * 3 : u64s; return u64s <= bch_btree_keys_u64s_remaining(c, b); diff --git a/drivers/md/bcache/extents.c b/drivers/md/bcache/extents.c index 63acaa625df8..71b31a1474f2 100644 --- a/drivers/md/bcache/extents.c +++ b/drivers/md/bcache/extents.c @@ -1200,7 +1200,7 @@ bool bch_insert_fixup_extent(struct btree_iter *iter, struct btree *b, * room for three keys. */ needs_split = (bch_btree_keys_u64s_remaining(c, b) < - BKEY_EXTENT_MAX_U64s * 3); + BKEY_EXTENT_U64s_MAX * 3); res_full = journal_res_full(res, &insert->k); /* diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c index a4758effcd93..acc7f2df7731 100644 --- a/drivers/md/bcache/io.c +++ b/drivers/md/bcache/io.c @@ -837,7 +837,7 @@ static void __bch_write(struct closure *cl) /* for the device pointers and 1 for the chksum */ if (bch_keylist_realloc(&op->insert_keys, - BKEY_EXTENT_MAX_U64s)) + BKEY_EXTENT_U64s_MAX)) continue_at(cl, bch_write_index, op->c->wq); k = op->insert_keys.top; diff --git a/drivers/md/bcache/io_types.h b/drivers/md/bcache/io_types.h index e2c7ed099358..495743950af8 100644 --- a/drivers/md/bcache/io_types.h +++ b/drivers/md/bcache/io_types.h @@ -122,7 +122,7 @@ struct bch_write_op { struct keylist insert_keys; BKEY_PADDED(insert_key); struct bch_replace_info replace_info; - u64 inline_keys[BKEY_EXTENT_MAX_U64s * 2]; + u64 inline_keys[BKEY_EXTENT_U64s_MAX * 2]; }; struct bio_decompress_worker { diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c index 2c4675e7b01f..5201f254efa1 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c @@ -871,7 +871,7 @@ static void journal_entry_open(struct journal *j) * Btree roots, prio pointers don't get added until right before we do * the write: */ - u64s -= BTREE_ID_NR * (JSET_KEYS_U64s + BKEY_EXTENT_MAX_U64s); + u64s -= BTREE_ID_NR * (JSET_KEYS_U64s + BKEY_EXTENT_U64s_MAX); u64s -= JSET_KEYS_U64s + j->nr_prio_buckets; u64s = max_t(ssize_t, 0L, u64s); diff --git a/drivers/md/bcache/keylist.c b/drivers/md/bcache/keylist.c index a30055f69a93..d98a1c83382a 100644 --- a/drivers/md/bcache/keylist.c +++ b/drivers/md/bcache/keylist.c @@ -13,7 +13,7 @@ int bch_keylist_realloc_max(struct keylist *l, unsigned maxu64s) { size_t oldcap = bch_keylist_capacity(l); - size_t newsize = max(oldcap, BKEY_EXTENT_MAX_U64s) + needu64s; + size_t newsize = max(oldcap, BKEY_EXTENT_U64s_MAX) + needu64s; u64 *new_keys; if (bch_keylist_fits(l, needu64s)) diff --git a/drivers/md/bcache/keylist.h b/drivers/md/bcache/keylist.h index 4be552a27954..028552757527 100644 --- a/drivers/md/bcache/keylist.h +++ b/drivers/md/bcache/keylist.h @@ -17,7 +17,7 @@ static inline size_t bch_keylist_capacity(struct keylist *l) } /* - * XXX: why are we using BKEY_EXTENT_MAX_U64s here? keylists aren't used just + * XXX: why are we using BKEY_EXTENT_U64s_MAX here? keylists aren't used just * for extents, this doesn't make any sense */ @@ -25,7 +25,7 @@ static inline bool bch_keylist_fits(struct keylist *l, size_t u64s) { if (l->bot_p > l->top_p) return (l->bot_p - l->top_p) > u64s; - else if (l->top_p + u64s + BKEY_EXTENT_MAX_U64s > l->end_keys_p) + else if (l->top_p + u64s + BKEY_EXTENT_U64s_MAX > l->end_keys_p) return l->start_keys_p != l->bot_p; else return true; @@ -41,7 +41,7 @@ static inline struct bkey_i *__bch_keylist_next(struct keylist *l, if (k == l->top) return k; - if ((u64 *) k + BKEY_EXTENT_MAX_U64s > l->end_keys_p) + if ((u64 *) k + BKEY_EXTENT_U64s_MAX > l->end_keys_p) return l->start_keys; return k; diff --git a/drivers/md/bcache/keylist_types.h b/drivers/md/bcache/keylist_types.h index 16ae7560b59d..569cdc2480e2 100644 --- a/drivers/md/bcache/keylist_types.h +++ b/drivers/md/bcache/keylist_types.h @@ -13,12 +13,12 @@ * If @top == @bot, the keylist is empty. * * We always ensure there is room for a maximum-sized extent key at @top; - * that is, @top_p + BKEY_EXTENT_MAX_U64s <= @end_keys_p. + * that is, @top_p + BKEY_EXTENT_U64s_MAX <= @end_keys_p. * * If this invariant does not hold after enqueuing a key, we wrap @top back * to @start_keys_p. * - * If at any time, @top_p + BKEY_EXTENT_MAX_U64s >= @bot_p, the keylist is + * If at any time, @top_p + BKEY_EXTENT_U64s_MAX >= @bot_p, the keylist is * full. */ diff --git a/drivers/md/bcache/tier.c b/drivers/md/bcache/tier.c index c147f55f9545..f7484ec74819 100644 --- a/drivers/md/bcache/tier.c +++ b/drivers/md/bcache/tier.c @@ -30,7 +30,7 @@ static bool tiering_pred(struct scan_keylist *kl, struct bkey_s_c k) unsigned replicas = 0; /* Make sure we have room to add a new pointer: */ - if (bkey_val_u64s(e.k) + BKEY_EXTENT_PTR_MAX_U64s > + if (bkey_val_u64s(e.k) + BKEY_EXTENT_PTR_U64s_MAX > BKEY_EXTENT_VAL_U64s_MAX) return false; diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h index 0cf12fcb38de..8a9ff6695a1d 100644 --- a/include/uapi/linux/bcache.h +++ b/include/uapi/linux/bcache.h @@ -452,6 +452,26 @@ struct bch_extent { } __attribute__((packed, aligned(8))); BKEY_VAL_TYPE(extent, BCH_EXTENT); +/* Maximum size (in u64s) a single pointer could be: */ +#define BKEY_EXTENT_PTR_U64s_MAX\ + ((sizeof(struct bch_extent_crc64) + \ + sizeof(struct bch_extent_ptr)) / sizeof(u64)) + +/* Maximum possible size of an entire extent value: */ +#if 0 +/* There's a hack in the keylist code that needs to be fixed.. */ +#define BKEY_EXTENT_VAL_U64s_MAX \ + (BKEY_EXTENT_PTR_U64s_MAX * BCH_REPLICAS_MAX) +#else +#define BKEY_EXTENT_VAL_U64s_MAX 8 +#endif + +/* * Maximum possible size of an entire extent, key + value: */ +#define BKEY_EXTENT_U64s_MAX (BKEY_U64s + BKEY_EXTENT_VAL_U64s_MAX) + +#define BKEY_BTREE_PTR_VAL_U64s_MAX BCH_REPLICAS_MAX +#define BKEY_BTREE_PTR_U64s_MAX (BKEY_U64s + BCH_REPLICAS_MAX) + /* Inodes */ #define BLOCKDEV_INODE_MAX 4096 |