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: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
c052cf82f3
commit
79f88eba01
|
@ -330,7 +330,7 @@ static inline void bkey_init(struct bkey *k)
|
|||
x(discard, 1) \
|
||||
x(error, 2) \
|
||||
x(cookie, 3) \
|
||||
x(whiteout, 4) \
|
||||
x(hash_whiteout, 4) \
|
||||
x(btree_ptr, 5) \
|
||||
x(extent, 6) \
|
||||
x(reservation, 7) \
|
||||
|
@ -355,11 +355,27 @@ enum bch_bkey_type {
|
|||
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_val v;
|
||||
__le64 cookie;
|
||||
};
|
||||
|
||||
struct bch_hash_whiteout {
|
||||
struct bch_val v;
|
||||
};
|
||||
|
||||
/* Extents */
|
||||
|
||||
/*
|
||||
|
|
|
@ -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
|
||||
* functions.
|
||||
*/
|
||||
#define BKEY_VAL_ACCESSORS(name) \
|
||||
#define x(name, ...) \
|
||||
struct bkey_i_##name { \
|
||||
union { \
|
||||
struct bkey k; \
|
||||
|
@ -522,23 +522,8 @@ static inline struct bkey_i_##name *bkey_##name##_init(struct bkey_i *_k)\
|
|||
return k; \
|
||||
}
|
||||
|
||||
BKEY_VAL_ACCESSORS(cookie);
|
||||
BKEY_VAL_ACCESSORS(btree_ptr);
|
||||
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);
|
||||
BCH_BKEY_TYPES();
|
||||
#undef x
|
||||
|
||||
/* byte order helpers */
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ static const char *key_type_cookie_invalid(const struct bch_fs *c,
|
|||
.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, \
|
||||
}
|
||||
|
||||
|
@ -270,9 +270,9 @@ static const struct old_bkey_type {
|
|||
{BKEY_TYPE_INODES, 128, KEY_TYPE_inode },
|
||||
{BKEY_TYPE_INODES, 130, KEY_TYPE_inode_generation },
|
||||
{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, 129, KEY_TYPE_whiteout },
|
||||
{BKEY_TYPE_XATTRS, 129, KEY_TYPE_hash_whiteout },
|
||||
{BKEY_TYPE_ALLOC, 128, KEY_TYPE_alloc },
|
||||
{BKEY_TYPE_QUOTAS, 128, KEY_TYPE_quota },
|
||||
};
|
||||
|
|
|
@ -262,7 +262,7 @@ int bch2_dirent_rename(struct btree_trans *trans,
|
|||
* overwrite old_dst - just make sure to use a
|
||||
* whiteout when deleting src:
|
||||
*/
|
||||
new_src->k.type = KEY_TYPE_whiteout;
|
||||
new_src->k.type = KEY_TYPE_hash_whiteout;
|
||||
}
|
||||
} else {
|
||||
/* Check if we need a whiteout to delete src: */
|
||||
|
@ -272,7 +272,7 @@ int bch2_dirent_rename(struct btree_trans *trans,
|
|||
goto out;
|
||||
|
||||
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,
|
|||
struct hash_check *h,
|
||||
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);
|
||||
|
||||
if (hole || k.k->p.offset > h->chain_end + 1)
|
||||
|
|
|
@ -156,7 +156,7 @@ bch2_hash_lookup(struct btree_trans *trans,
|
|||
if (k.k->type == desc.key_type) {
|
||||
if (!desc.cmp_key(k, key))
|
||||
return iter;
|
||||
} else if (k.k->type == KEY_TYPE_whiteout) {
|
||||
} else if (k.k->type == KEY_TYPE_hash_whiteout) {
|
||||
;
|
||||
} else {
|
||||
/* hole, not found */
|
||||
|
@ -210,7 +210,7 @@ int bch2_hash_needs_whiteout(struct btree_trans *trans,
|
|||
|
||||
for_each_btree_key_continue(iter, BTREE_ITER_SLOTS, k, ret) {
|
||||
if (k.k->type != desc.key_type &&
|
||||
k.k->type != KEY_TYPE_whiteout)
|
||||
k.k->type != KEY_TYPE_hash_whiteout)
|
||||
break;
|
||||
|
||||
if (k.k->type == desc.key_type &&
|
||||
|
@ -254,7 +254,7 @@ int bch2_hash_set(struct btree_trans *trans,
|
|||
!(flags & BCH_HASH_SET_MUST_REPLACE))
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ int bch2_hash_delete_at(struct btree_trans *trans,
|
|||
|
||||
bkey_init(&delete->k);
|
||||
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);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue