summaryrefslogtreecommitdiff
path: root/fs/bcachefs/bkey_methods.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-04-04 04:50:25 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:30 +0300
commit275c8426fb8fd475e9991b3aa1b20f66069e594f (patch)
treef3e085040653dd86977f3fe73ce87730ab699556 /fs/bcachefs/bkey_methods.h
parente1effd42a1cb40048002f594c12e823b5e33ed5d (diff)
downloadlinux-275c8426fb8fd475e9991b3aa1b20f66069e594f.tar.xz
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.h')
-rw-r--r--fs/bcachefs/bkey_methods.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/fs/bcachefs/bkey_methods.h b/fs/bcachefs/bkey_methods.h
index 4b90d0873be6..5c55e8bfe158 100644
--- a/fs/bcachefs/bkey_methods.h
+++ b/fs/bcachefs/bkey_methods.h
@@ -12,10 +12,16 @@ enum btree_node_type;
extern const char * const bch2_bkey_types[];
+/*
+ * key_invalid: checks validity of @k, returns 0 if good or -EINVAL if bad. If
+ * invalid, entire key will be deleted.
+ *
+ * When invalid, error string is returned via @err. @rw indicates whether key is
+ * being read or written; more aggressive checks can be enabled when rw == WRITE.
+*/
struct bkey_ops {
- /* Returns reason for being invalid if invalid, else NULL: */
- int (*key_invalid)(const struct bch_fs *, struct bkey_s_c,
- struct printbuf *);
+ int (*key_invalid)(const struct bch_fs *c, struct bkey_s_c k,
+ int rw, struct printbuf *err);
void (*val_to_text)(struct printbuf *, struct bch_fs *,
struct bkey_s_c);
void (*swab)(struct bkey_s);
@@ -32,11 +38,11 @@ struct bkey_ops {
extern const struct bkey_ops bch2_bkey_ops[];
-int bch2_bkey_val_invalid(struct bch_fs *, struct bkey_s_c, struct printbuf *);
+int bch2_bkey_val_invalid(struct bch_fs *, struct bkey_s_c, int, struct printbuf *);
int __bch2_bkey_invalid(struct bch_fs *, struct bkey_s_c,
- enum btree_node_type, struct printbuf *);
+ enum btree_node_type, int, struct printbuf *);
int bch2_bkey_invalid(struct bch_fs *, struct bkey_s_c,
- enum btree_node_type, struct printbuf *);
+ enum btree_node_type, int, struct printbuf *);
int bch2_bkey_in_btree_node(struct btree *, struct bkey_s_c, struct printbuf *);
void bch2_bpos_to_text(struct printbuf *, struct bpos);