Skip to content

Commit 65eaf4e

Browse files
author
Kent Overstreet
committed
bcachefs: s/bkey_invalid_flags/bch_validate_flags
We're about to start using bch_validate_flags for superblock section validation - it's no longer bkey specific. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent d09a846 commit 65eaf4e

31 files changed

+110
-110
lines changed

fs/bcachefs/alloc_background.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static unsigned bch_alloc_v1_val_u64s(const struct bch_alloc *a)
195195
}
196196

197197
int bch2_alloc_v1_invalid(struct bch_fs *c, struct bkey_s_c k,
198-
enum bkey_invalid_flags flags,
198+
enum bch_validate_flags flags,
199199
struct printbuf *err)
200200
{
201201
struct bkey_s_c_alloc a = bkey_s_c_to_alloc(k);
@@ -211,7 +211,7 @@ int bch2_alloc_v1_invalid(struct bch_fs *c, struct bkey_s_c k,
211211
}
212212

213213
int bch2_alloc_v2_invalid(struct bch_fs *c, struct bkey_s_c k,
214-
enum bkey_invalid_flags flags,
214+
enum bch_validate_flags flags,
215215
struct printbuf *err)
216216
{
217217
struct bkey_alloc_unpacked u;
@@ -225,7 +225,7 @@ int bch2_alloc_v2_invalid(struct bch_fs *c, struct bkey_s_c k,
225225
}
226226

227227
int bch2_alloc_v3_invalid(struct bch_fs *c, struct bkey_s_c k,
228-
enum bkey_invalid_flags flags,
228+
enum bch_validate_flags flags,
229229
struct printbuf *err)
230230
{
231231
struct bkey_alloc_unpacked u;
@@ -239,7 +239,7 @@ int bch2_alloc_v3_invalid(struct bch_fs *c, struct bkey_s_c k,
239239
}
240240

241241
int bch2_alloc_v4_invalid(struct bch_fs *c, struct bkey_s_c k,
242-
enum bkey_invalid_flags flags, struct printbuf *err)
242+
enum bch_validate_flags flags, struct printbuf *err)
243243
{
244244
struct bkey_s_c_alloc_v4 a = bkey_s_c_to_alloc_v4(k);
245245
int ret = 0;
@@ -487,7 +487,7 @@ static unsigned alloc_gen(struct bkey_s_c k, unsigned offset)
487487
}
488488

489489
int bch2_bucket_gens_invalid(struct bch_fs *c, struct bkey_s_c k,
490-
enum bkey_invalid_flags flags,
490+
enum bch_validate_flags flags,
491491
struct printbuf *err)
492492
{
493493
int ret = 0;

fs/bcachefs/alloc_background.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "debug.h"
99
#include "super.h"
1010

11-
enum bkey_invalid_flags;
11+
enum bch_validate_flags;
1212

1313
/* How out of date a pointer gen is allowed to be: */
1414
#define BUCKET_GC_GEN_MAX 96U
@@ -205,13 +205,13 @@ struct bkey_i_alloc_v4 *bch2_alloc_to_v4_mut(struct btree_trans *, struct bkey_s
205205
int bch2_bucket_io_time_reset(struct btree_trans *, unsigned, size_t, int);
206206

207207
int bch2_alloc_v1_invalid(struct bch_fs *, struct bkey_s_c,
208-
enum bkey_invalid_flags, struct printbuf *);
208+
enum bch_validate_flags, struct printbuf *);
209209
int bch2_alloc_v2_invalid(struct bch_fs *, struct bkey_s_c,
210-
enum bkey_invalid_flags, struct printbuf *);
210+
enum bch_validate_flags, struct printbuf *);
211211
int bch2_alloc_v3_invalid(struct bch_fs *, struct bkey_s_c,
212-
enum bkey_invalid_flags, struct printbuf *);
212+
enum bch_validate_flags, struct printbuf *);
213213
int bch2_alloc_v4_invalid(struct bch_fs *, struct bkey_s_c,
214-
enum bkey_invalid_flags, struct printbuf *);
214+
enum bch_validate_flags, struct printbuf *);
215215
void bch2_alloc_v4_swab(struct bkey_s);
216216
void bch2_alloc_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
217217

@@ -245,7 +245,7 @@ void bch2_alloc_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
245245
})
246246

247247
int bch2_bucket_gens_invalid(struct bch_fs *, struct bkey_s_c,
248-
enum bkey_invalid_flags, struct printbuf *);
248+
enum bch_validate_flags, struct printbuf *);
249249
void bch2_bucket_gens_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
250250

251251
#define bch2_bkey_ops_bucket_gens ((struct bkey_ops) { \

fs/bcachefs/backpointers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static bool extent_matches_bp(struct bch_fs *c,
4848
}
4949

5050
int bch2_backpointer_invalid(struct bch_fs *c, struct bkey_s_c k,
51-
enum bkey_invalid_flags flags,
51+
enum bch_validate_flags flags,
5252
struct printbuf *err)
5353
{
5454
struct bkey_s_c_backpointer bp = bkey_s_c_to_backpointer(k);

fs/bcachefs/backpointers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static inline u64 swab40(u64 x)
1919
}
2020

2121
int bch2_backpointer_invalid(struct bch_fs *, struct bkey_s_c k,
22-
enum bkey_invalid_flags, struct printbuf *);
22+
enum bch_validate_flags, struct printbuf *);
2323
void bch2_backpointer_to_text(struct printbuf *, const struct bch_backpointer *);
2424
void bch2_backpointer_k_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
2525
void bch2_backpointer_swab(struct bkey_s);

fs/bcachefs/bkey.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ struct bkey_format bch2_bkey_format_done(struct bkey_format_state *s)
640640

641641
int bch2_bkey_format_invalid(struct bch_fs *c,
642642
struct bkey_format *f,
643-
enum bkey_invalid_flags flags,
643+
enum bch_validate_flags flags,
644644
struct printbuf *err)
645645
{
646646
unsigned i, bits = KEY_PACKED_BITS_START;

fs/bcachefs/bkey.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
#include "util.h"
1010
#include "vstructs.h"
1111

12-
enum bkey_invalid_flags {
13-
BKEY_INVALID_WRITE = (1U << 0),
14-
BKEY_INVALID_COMMIT = (1U << 1),
15-
BKEY_INVALID_JOURNAL = (1U << 2),
12+
enum bch_validate_flags {
13+
BCH_VALIDATE_write = (1U << 0),
14+
BCH_VALIDATE_commit = (1U << 1),
15+
BCH_VALIDATE_journal = (1U << 2),
1616
};
1717

1818
#if 0
@@ -598,7 +598,7 @@ static inline bool bch2_bkey_format_field_overflows(struct bkey_format *f, unsig
598598
}
599599

600600
int bch2_bkey_format_invalid(struct bch_fs *, struct bkey_format *,
601-
enum bkey_invalid_flags, struct printbuf *);
601+
enum bch_validate_flags, struct printbuf *);
602602
void bch2_bkey_format_to_text(struct printbuf *, const struct bkey_format *);
603603

604604
#endif /* _BCACHEFS_BKEY_H */

fs/bcachefs/bkey_methods.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const char * const bch2_bkey_types[] = {
2727
};
2828

2929
static int deleted_key_invalid(struct bch_fs *c, struct bkey_s_c k,
30-
enum bkey_invalid_flags flags, struct printbuf *err)
30+
enum bch_validate_flags flags, struct printbuf *err)
3131
{
3232
return 0;
3333
}
@@ -41,7 +41,7 @@ static int deleted_key_invalid(struct bch_fs *c, struct bkey_s_c k,
4141
})
4242

4343
static int empty_val_key_invalid(struct bch_fs *c, struct bkey_s_c k,
44-
enum bkey_invalid_flags flags, struct printbuf *err)
44+
enum bch_validate_flags flags, struct printbuf *err)
4545
{
4646
int ret = 0;
4747

@@ -58,7 +58,7 @@ static int empty_val_key_invalid(struct bch_fs *c, struct bkey_s_c k,
5858
})
5959

6060
static int key_type_cookie_invalid(struct bch_fs *c, struct bkey_s_c k,
61-
enum bkey_invalid_flags flags, struct printbuf *err)
61+
enum bch_validate_flags flags, struct printbuf *err)
6262
{
6363
return 0;
6464
}
@@ -82,7 +82,7 @@ static void key_type_cookie_to_text(struct printbuf *out, struct bch_fs *c,
8282
})
8383

8484
static int key_type_inline_data_invalid(struct bch_fs *c, struct bkey_s_c k,
85-
enum bkey_invalid_flags flags, struct printbuf *err)
85+
enum bch_validate_flags flags, struct printbuf *err)
8686
{
8787
return 0;
8888
}
@@ -123,7 +123,7 @@ const struct bkey_ops bch2_bkey_null_ops = {
123123
};
124124

125125
int bch2_bkey_val_invalid(struct bch_fs *c, struct bkey_s_c k,
126-
enum bkey_invalid_flags flags,
126+
enum bch_validate_flags flags,
127127
struct printbuf *err)
128128
{
129129
const struct bkey_ops *ops = bch2_bkey_type_ops(k.k->type);
@@ -159,7 +159,7 @@ const char *bch2_btree_node_type_str(enum btree_node_type type)
159159

160160
int __bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
161161
enum btree_node_type type,
162-
enum bkey_invalid_flags flags,
162+
enum bch_validate_flags flags,
163163
struct printbuf *err)
164164
{
165165
int ret = 0;
@@ -172,7 +172,7 @@ int __bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
172172
return 0;
173173

174174
bkey_fsck_err_on(k.k->type < KEY_TYPE_MAX &&
175-
(type == BKEY_TYPE_btree || (flags & BKEY_INVALID_COMMIT)) &&
175+
(type == BKEY_TYPE_btree || (flags & BCH_VALIDATE_commit)) &&
176176
!(bch2_key_types_allowed[type] & BIT_ULL(k.k->type)), c, err,
177177
bkey_invalid_type_for_btree,
178178
"invalid key type for btree %s (%s)",
@@ -224,7 +224,7 @@ int __bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
224224

225225
int bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
226226
enum btree_node_type type,
227-
enum bkey_invalid_flags flags,
227+
enum bch_validate_flags flags,
228228
struct printbuf *err)
229229
{
230230
return __bch2_bkey_invalid(c, k, type, flags, err) ?:

fs/bcachefs/bkey_methods.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extern const struct bkey_ops bch2_bkey_null_ops;
2222
*/
2323
struct bkey_ops {
2424
int (*key_invalid)(struct bch_fs *c, struct bkey_s_c k,
25-
enum bkey_invalid_flags flags, struct printbuf *err);
25+
enum bch_validate_flags flags, struct printbuf *err);
2626
void (*val_to_text)(struct printbuf *, struct bch_fs *,
2727
struct bkey_s_c);
2828
void (*swab)(struct bkey_s);
@@ -49,11 +49,11 @@ static inline const struct bkey_ops *bch2_bkey_type_ops(enum bch_bkey_type type)
4949
}
5050

5151
int bch2_bkey_val_invalid(struct bch_fs *, struct bkey_s_c,
52-
enum bkey_invalid_flags, struct printbuf *);
52+
enum bch_validate_flags, struct printbuf *);
5353
int __bch2_bkey_invalid(struct bch_fs *, struct bkey_s_c, enum btree_node_type,
54-
enum bkey_invalid_flags, struct printbuf *);
54+
enum bch_validate_flags, struct printbuf *);
5555
int bch2_bkey_invalid(struct bch_fs *, struct bkey_s_c, enum btree_node_type,
56-
enum bkey_invalid_flags, struct printbuf *);
56+
enum bch_validate_flags, struct printbuf *);
5757
int bch2_bkey_in_btree_node(struct bch_fs *, struct btree *,
5858
struct bkey_s_c, struct printbuf *);
5959

fs/bcachefs/btree_trans_commit.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ static noinline void bch2_drop_overwrites_from_journal(struct btree_trans *trans
790790
}
791791

792792
static noinline int bch2_trans_commit_bkey_invalid(struct btree_trans *trans,
793-
enum bkey_invalid_flags flags,
793+
enum bch_validate_flags flags,
794794
struct btree_insert_entry *i,
795795
struct printbuf *err)
796796
{
@@ -1025,10 +1025,10 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags)
10251025

10261026
trans_for_each_update(trans, i) {
10271027
struct printbuf buf = PRINTBUF;
1028-
enum bkey_invalid_flags invalid_flags = 0;
1028+
enum bch_validate_flags invalid_flags = 0;
10291029

10301030
if (!(flags & BCH_TRANS_COMMIT_no_journal_res))
1031-
invalid_flags |= BKEY_INVALID_WRITE|BKEY_INVALID_COMMIT;
1031+
invalid_flags |= BCH_VALIDATE_write|BCH_VALIDATE_commit;
10321032

10331033
if (unlikely(bch2_bkey_invalid(c, bkey_i_to_s_c(i->k),
10341034
i->bkey_type, invalid_flags, &buf)))
@@ -1043,10 +1043,10 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags)
10431043
for (struct jset_entry *i = trans->journal_entries;
10441044
i != (void *) ((u64 *) trans->journal_entries + trans->journal_entries_u64s);
10451045
i = vstruct_next(i)) {
1046-
enum bkey_invalid_flags invalid_flags = 0;
1046+
enum bch_validate_flags invalid_flags = 0;
10471047

10481048
if (!(flags & BCH_TRANS_COMMIT_no_journal_res))
1049-
invalid_flags |= BKEY_INVALID_WRITE|BKEY_INVALID_COMMIT;
1049+
invalid_flags |= BCH_VALIDATE_write|BCH_VALIDATE_commit;
10501050

10511051
if (unlikely(bch2_journal_entry_validate(c, NULL, i,
10521052
bcachefs_metadata_version_current,

fs/bcachefs/dirent.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const struct bch_hash_desc bch2_dirent_hash_desc = {
9898
};
9999

100100
int bch2_dirent_invalid(struct bch_fs *c, struct bkey_s_c k,
101-
enum bkey_invalid_flags flags,
101+
enum bch_validate_flags flags,
102102
struct printbuf *err)
103103
{
104104
struct bkey_s_c_dirent d = bkey_s_c_to_dirent(k);
@@ -118,7 +118,7 @@ int bch2_dirent_invalid(struct bch_fs *c, struct bkey_s_c k,
118118
* Check new keys don't exceed the max length
119119
* (older keys may be larger.)
120120
*/
121-
bkey_fsck_err_on((flags & BKEY_INVALID_COMMIT) && d_name.len > BCH_NAME_MAX, c, err,
121+
bkey_fsck_err_on((flags & BCH_VALIDATE_commit) && d_name.len > BCH_NAME_MAX, c, err,
122122
dirent_name_too_long,
123123
"dirent name too big (%u > %u)",
124124
d_name.len, BCH_NAME_MAX);

0 commit comments

Comments
 (0)