diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-04-03 21:50:25 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:30 -0400 |
commit | 275c8426fb8fd475e9991b3aa1b20f66069e594f (patch) | |
tree | f3e085040653dd86977f3fe73ce87730ab699556 /fs/bcachefs/bkey_methods.c | |
parent | e1effd42a1cb40048002f594c12e823b5e33ed5d (diff) |
bcachefs: Add rw to .key_invalid()
This adds a new parameter to .key_invalid() methods for whether the key
is being read or written; the idea being that methods can do more
aggressive checks when a key is newly created and being written, when we
wouldn't want to delete the key because of those checks.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/bkey_methods.c')
-rw-r--r-- | fs/bcachefs/bkey_methods.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/fs/bcachefs/bkey_methods.c b/fs/bcachefs/bkey_methods.c index 0351cbe7d48e..62ce1264731a 100644 --- a/fs/bcachefs/bkey_methods.c +++ b/fs/bcachefs/bkey_methods.c @@ -23,7 +23,7 @@ const char * const bch2_bkey_types[] = { }; static int deleted_key_invalid(const struct bch_fs *c, struct bkey_s_c k, - struct printbuf *err) + int rw, struct printbuf *err) { return 0; } @@ -37,7 +37,7 @@ static int deleted_key_invalid(const struct bch_fs *c, struct bkey_s_c k, } static int empty_val_key_invalid(const struct bch_fs *c, struct bkey_s_c k, - struct printbuf *err) + int rw, struct printbuf *err) { if (bkey_val_bytes(k.k)) { pr_buf(err, "incorrect value size (%zu != 0)", @@ -53,7 +53,7 @@ static int empty_val_key_invalid(const struct bch_fs *c, struct bkey_s_c k, } static int key_type_cookie_invalid(const struct bch_fs *c, struct bkey_s_c k, - struct printbuf *err) + int rw, struct printbuf *err) { if (bkey_val_bytes(k.k) != sizeof(struct bch_cookie)) { pr_buf(err, "incorrect value size (%zu != %zu)", @@ -73,7 +73,7 @@ static int key_type_cookie_invalid(const struct bch_fs *c, struct bkey_s_c k, } static int key_type_inline_data_invalid(const struct bch_fs *c, struct bkey_s_c k, - struct printbuf *err) + int rw, struct printbuf *err) { return 0; } @@ -94,7 +94,7 @@ static void key_type_inline_data_to_text(struct printbuf *out, struct bch_fs *c, } static int key_type_set_invalid(const struct bch_fs *c, struct bkey_s_c k, - struct printbuf *err) + int rw, struct printbuf *err) { if (bkey_val_bytes(k.k)) { pr_buf(err, "incorrect value size (%zu != %zu)", @@ -122,14 +122,15 @@ const struct bkey_ops bch2_bkey_ops[] = { #undef x }; -int bch2_bkey_val_invalid(struct bch_fs *c, struct bkey_s_c k, struct printbuf *err) +int bch2_bkey_val_invalid(struct bch_fs *c, struct bkey_s_c k, + int rw, struct printbuf *err) { if (k.k->type >= KEY_TYPE_MAX) { pr_buf(err, "invalid type (%u >= %u)", k.k->type, KEY_TYPE_MAX); return -EINVAL; } - return bch2_bkey_ops[k.k->type].key_invalid(c, k, err); + return bch2_bkey_ops[k.k->type].key_invalid(c, k, rw, err); } static unsigned bch2_key_types_allowed[] = { @@ -198,7 +199,7 @@ static unsigned bch2_key_types_allowed[] = { int __bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k, enum btree_node_type type, - struct printbuf *err) + int rw, struct printbuf *err) { if (k.k->u64s < BKEY_U64s) { pr_buf(err, "u64s too small (%u < %zu)", k.k->u64s, BKEY_U64s); @@ -254,10 +255,10 @@ int __bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k, int bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k, enum btree_node_type type, - struct printbuf *err) + int rw, struct printbuf *err) { - return __bch2_bkey_invalid(c, k, type, err) ?: - bch2_bkey_val_invalid(c, k, err); + return __bch2_bkey_invalid(c, k, type, rw, err) ?: + bch2_bkey_val_invalid(c, k, rw, err); } int bch2_bkey_in_btree_node(struct btree *b, struct bkey_s_c k, |