Commit 79f88eba authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Rename KEY_TYPE_whiteout -> KEY_TYPE_hash_whiteout

Snapshots are going to need a different whiteout key type. Also, switch
to using BCH_BKEY_TYPES() to define the bkey value accessors.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent c052cf82
...@@ -330,7 +330,7 @@ static inline void bkey_init(struct bkey *k) ...@@ -330,7 +330,7 @@ static inline void bkey_init(struct bkey *k)
x(discard, 1) \ x(discard, 1) \
x(error, 2) \ x(error, 2) \
x(cookie, 3) \ x(cookie, 3) \
x(whiteout, 4) \ x(hash_whiteout, 4) \
x(btree_ptr, 5) \ x(btree_ptr, 5) \
x(extent, 6) \ x(extent, 6) \
x(reservation, 7) \ x(reservation, 7) \
...@@ -355,11 +355,27 @@ enum bch_bkey_type { ...@@ -355,11 +355,27 @@ enum bch_bkey_type {
KEY_TYPE_MAX, KEY_TYPE_MAX,
}; };
struct bch_deleted {
struct bch_val v;
};
struct bch_discard {
struct bch_val v;
};
struct bch_error {
struct bch_val v;
};
struct bch_cookie { struct bch_cookie {
struct bch_val v; struct bch_val v;
__le64 cookie; __le64 cookie;
}; };
struct bch_hash_whiteout {
struct bch_val v;
};
/* Extents */ /* Extents */
/* /*
......
...@@ -411,7 +411,7 @@ static inline struct bkey_s_c bkey_i_to_s_c(const struct bkey_i *k) ...@@ -411,7 +411,7 @@ static inline struct bkey_s_c bkey_i_to_s_c(const struct bkey_i *k)
* bkey_i_extent to a bkey_i - since that's always safe, instead of conversion * bkey_i_extent to a bkey_i - since that's always safe, instead of conversion
* functions. * functions.
*/ */
#define BKEY_VAL_ACCESSORS(name) \ #define x(name, ...) \
struct bkey_i_##name { \ struct bkey_i_##name { \
union { \ union { \
struct bkey k; \ struct bkey k; \
...@@ -522,23 +522,8 @@ static inline struct bkey_i_##name *bkey_##name##_init(struct bkey_i *_k)\ ...@@ -522,23 +522,8 @@ static inline struct bkey_i_##name *bkey_##name##_init(struct bkey_i *_k)\
return k; \ return k; \
} }
BKEY_VAL_ACCESSORS(cookie); BCH_BKEY_TYPES();
BKEY_VAL_ACCESSORS(btree_ptr); #undef x
BKEY_VAL_ACCESSORS(extent);
BKEY_VAL_ACCESSORS(reservation);
BKEY_VAL_ACCESSORS(inode);
BKEY_VAL_ACCESSORS(inode_generation);
BKEY_VAL_ACCESSORS(dirent);
BKEY_VAL_ACCESSORS(xattr);
BKEY_VAL_ACCESSORS(alloc);
BKEY_VAL_ACCESSORS(quota);
BKEY_VAL_ACCESSORS(stripe);
BKEY_VAL_ACCESSORS(reflink_p);
BKEY_VAL_ACCESSORS(reflink_v);
BKEY_VAL_ACCESSORS(inline_data);
BKEY_VAL_ACCESSORS(btree_ptr_v2);
BKEY_VAL_ACCESSORS(indirect_inline_data);
BKEY_VAL_ACCESSORS(alloc_v2);
/* byte order helpers */ /* byte order helpers */
......
...@@ -59,7 +59,7 @@ static const char *key_type_cookie_invalid(const struct bch_fs *c, ...@@ -59,7 +59,7 @@ static const char *key_type_cookie_invalid(const struct bch_fs *c,
.key_invalid = key_type_cookie_invalid, \ .key_invalid = key_type_cookie_invalid, \
} }
#define bch2_bkey_ops_whiteout (struct bkey_ops) { \ #define bch2_bkey_ops_hash_whiteout (struct bkey_ops) { \
.key_invalid = empty_val_key_invalid, \ .key_invalid = empty_val_key_invalid, \
} }
...@@ -270,9 +270,9 @@ static const struct old_bkey_type { ...@@ -270,9 +270,9 @@ static const struct old_bkey_type {
{BKEY_TYPE_INODES, 128, KEY_TYPE_inode }, {BKEY_TYPE_INODES, 128, KEY_TYPE_inode },
{BKEY_TYPE_INODES, 130, KEY_TYPE_inode_generation }, {BKEY_TYPE_INODES, 130, KEY_TYPE_inode_generation },
{BKEY_TYPE_DIRENTS, 128, KEY_TYPE_dirent }, {BKEY_TYPE_DIRENTS, 128, KEY_TYPE_dirent },
{BKEY_TYPE_DIRENTS, 129, KEY_TYPE_whiteout }, {BKEY_TYPE_DIRENTS, 129, KEY_TYPE_hash_whiteout },
{BKEY_TYPE_XATTRS, 128, KEY_TYPE_xattr }, {BKEY_TYPE_XATTRS, 128, KEY_TYPE_xattr },
{BKEY_TYPE_XATTRS, 129, KEY_TYPE_whiteout }, {BKEY_TYPE_XATTRS, 129, KEY_TYPE_hash_whiteout },
{BKEY_TYPE_ALLOC, 128, KEY_TYPE_alloc }, {BKEY_TYPE_ALLOC, 128, KEY_TYPE_alloc },
{BKEY_TYPE_QUOTAS, 128, KEY_TYPE_quota }, {BKEY_TYPE_QUOTAS, 128, KEY_TYPE_quota },
}; };
......
...@@ -262,7 +262,7 @@ int bch2_dirent_rename(struct btree_trans *trans, ...@@ -262,7 +262,7 @@ int bch2_dirent_rename(struct btree_trans *trans,
* overwrite old_dst - just make sure to use a * overwrite old_dst - just make sure to use a
* whiteout when deleting src: * whiteout when deleting src:
*/ */
new_src->k.type = KEY_TYPE_whiteout; new_src->k.type = KEY_TYPE_hash_whiteout;
} }
} else { } else {
/* Check if we need a whiteout to delete src: */ /* Check if we need a whiteout to delete src: */
...@@ -272,7 +272,7 @@ int bch2_dirent_rename(struct btree_trans *trans, ...@@ -272,7 +272,7 @@ int bch2_dirent_rename(struct btree_trans *trans,
goto out; goto out;
if (ret) if (ret)
new_src->k.type = KEY_TYPE_whiteout; new_src->k.type = KEY_TYPE_hash_whiteout;
} }
} }
......
...@@ -257,7 +257,7 @@ static void hash_set_chain_start(struct btree_trans *trans, ...@@ -257,7 +257,7 @@ static void hash_set_chain_start(struct btree_trans *trans,
struct hash_check *h, struct hash_check *h,
struct btree_iter *k_iter, struct bkey_s_c k) struct btree_iter *k_iter, struct bkey_s_c k)
{ {
bool hole = (k.k->type != KEY_TYPE_whiteout && bool hole = (k.k->type != KEY_TYPE_hash_whiteout &&
k.k->type != desc.key_type); k.k->type != desc.key_type);
if (hole || k.k->p.offset > h->chain_end + 1) if (hole || k.k->p.offset > h->chain_end + 1)
......
...@@ -156,7 +156,7 @@ bch2_hash_lookup(struct btree_trans *trans, ...@@ -156,7 +156,7 @@ bch2_hash_lookup(struct btree_trans *trans,
if (k.k->type == desc.key_type) { if (k.k->type == desc.key_type) {
if (!desc.cmp_key(k, key)) if (!desc.cmp_key(k, key))
return iter; return iter;
} else if (k.k->type == KEY_TYPE_whiteout) { } else if (k.k->type == KEY_TYPE_hash_whiteout) {
; ;
} else { } else {
/* hole, not found */ /* hole, not found */
...@@ -210,7 +210,7 @@ int bch2_hash_needs_whiteout(struct btree_trans *trans, ...@@ -210,7 +210,7 @@ int bch2_hash_needs_whiteout(struct btree_trans *trans,
for_each_btree_key_continue(iter, BTREE_ITER_SLOTS, k, ret) { for_each_btree_key_continue(iter, BTREE_ITER_SLOTS, k, ret) {
if (k.k->type != desc.key_type && if (k.k->type != desc.key_type &&
k.k->type != KEY_TYPE_whiteout) k.k->type != KEY_TYPE_hash_whiteout)
break; break;
if (k.k->type == desc.key_type && if (k.k->type == desc.key_type &&
...@@ -254,7 +254,7 @@ int bch2_hash_set(struct btree_trans *trans, ...@@ -254,7 +254,7 @@ int bch2_hash_set(struct btree_trans *trans,
!(flags & BCH_HASH_SET_MUST_REPLACE)) !(flags & BCH_HASH_SET_MUST_REPLACE))
slot = bch2_trans_copy_iter(trans, iter); slot = bch2_trans_copy_iter(trans, iter);
if (k.k->type != KEY_TYPE_whiteout) if (k.k->type != KEY_TYPE_hash_whiteout)
goto not_found; goto not_found;
} }
...@@ -303,7 +303,7 @@ int bch2_hash_delete_at(struct btree_trans *trans, ...@@ -303,7 +303,7 @@ int bch2_hash_delete_at(struct btree_trans *trans,
bkey_init(&delete->k); bkey_init(&delete->k);
delete->k.p = iter->pos; delete->k.p = iter->pos;
delete->k.type = ret ? KEY_TYPE_whiteout : KEY_TYPE_deleted; delete->k.type = ret ? KEY_TYPE_hash_whiteout : KEY_TYPE_deleted;
bch2_trans_update(trans, iter, delete, 0); bch2_trans_update(trans, iter, delete, 0);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment