diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-02-20 19:09:53 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:55 -0400 |
commit | 79f88eba01b1aafdec1fbf453954f5cd00dd56c1 (patch) | |
tree | 5f74bc95a8c75e8458d5422182852930986e0c59 | |
parent | c052cf82f3d66ad5b680003cfacf67cbe0e9b1bb (diff) | |
download | linux-79f88eba01b1aafdec1fbf453954f5cd00dd56c1.tar.gz linux-79f88eba01b1aafdec1fbf453954f5cd00dd56c1.tar.bz2 linux-79f88eba01b1aafdec1fbf453954f5cd00dd56c1.zip |
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>
-rw-r--r-- | fs/bcachefs/bcachefs_format.h | 18 | ||||
-rw-r--r-- | fs/bcachefs/bkey.h | 21 | ||||
-rw-r--r-- | fs/bcachefs/bkey_methods.c | 6 | ||||
-rw-r--r-- | fs/bcachefs/dirent.c | 4 | ||||
-rw-r--r-- | fs/bcachefs/fsck.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/str_hash.h | 8 |
6 files changed, 30 insertions, 29 deletions
diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h index dff49ab7e93d..1df6b7c6e4d7 100644 --- a/fs/bcachefs/bcachefs_format.h +++ b/fs/bcachefs/bcachefs_format.h @@ -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 */ /* diff --git a/fs/bcachefs/bkey.h b/fs/bcachefs/bkey.h index 9fd752b5c2f5..25cb5e985109 100644 --- a/fs/bcachefs/bkey.h +++ b/fs/bcachefs/bkey.h @@ -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 */ diff --git a/fs/bcachefs/bkey_methods.c b/fs/bcachefs/bkey_methods.c index f5779795a4b2..756bf5aeee9b 100644 --- a/fs/bcachefs/bkey_methods.c +++ b/fs/bcachefs/bkey_methods.c @@ -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 }, }; diff --git a/fs/bcachefs/dirent.c b/fs/bcachefs/dirent.c index f34bfda8ab0d..d2ebf1e5819d 100644 --- a/fs/bcachefs/dirent.c +++ b/fs/bcachefs/dirent.c @@ -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; } } diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 66c9dad2ef3e..7f78edcfe565 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -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) diff --git a/fs/bcachefs/str_hash.h b/fs/bcachefs/str_hash.h index f6b694b9346b..952b146af750 100644 --- a/fs/bcachefs/str_hash.h +++ b/fs/bcachefs/str_hash.h @@ -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; |