Skip to content

Commit 9cdde3c

Browse files
author
Kent Overstreet
committed
bcachefs: Fix casefold lookups
Add casefolding to bch2_lookup_trans: During the delay between when casefolding was written and when it was merged, the main filesystem lookup path grew self healing - which meant it was no longer using bch2_dirent_lookup_trans(), where casefolding on lookups happens. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent b9e1f87 commit 9cdde3c

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

fs/bcachefs/dirent.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
#include <linux/dcache.h>
1515

16-
static int bch2_casefold(struct btree_trans *trans, const struct bch_hash_info *info,
17-
const struct qstr *str, struct qstr *out_cf)
16+
int bch2_casefold(struct btree_trans *trans, const struct bch_hash_info *info,
17+
const struct qstr *str, struct qstr *out_cf)
1818
{
1919
*out_cf = (struct qstr) QSTR_INIT(NULL, 0);
2020

@@ -35,18 +35,6 @@ static int bch2_casefold(struct btree_trans *trans, const struct bch_hash_info *
3535
#endif
3636
}
3737

38-
static inline int bch2_maybe_casefold(struct btree_trans *trans,
39-
const struct bch_hash_info *info,
40-
const struct qstr *str, struct qstr *out_cf)
41-
{
42-
if (likely(!info->cf_encoding)) {
43-
*out_cf = *str;
44-
return 0;
45-
} else {
46-
return bch2_casefold(trans, info, str, out_cf);
47-
}
48-
}
49-
5038
static unsigned bch2_dirent_name_bytes(struct bkey_s_c_dirent d)
5139
{
5240
if (bkey_val_bytes(d.k) < offsetof(struct bch_dirent, d_name))

fs/bcachefs/dirent.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ struct bch_fs;
2323
struct bch_hash_info;
2424
struct bch_inode_info;
2525

26+
int bch2_casefold(struct btree_trans *, const struct bch_hash_info *,
27+
const struct qstr *, struct qstr *);
28+
29+
static inline int bch2_maybe_casefold(struct btree_trans *trans,
30+
const struct bch_hash_info *info,
31+
const struct qstr *str, struct qstr *out_cf)
32+
{
33+
if (likely(!info->cf_encoding)) {
34+
*out_cf = *str;
35+
return 0;
36+
} else {
37+
return bch2_casefold(trans, info, str, out_cf);
38+
}
39+
}
40+
2641
struct qstr bch2_dirent_get_name(struct bkey_s_c_dirent d);
2742

2843
static inline unsigned dirent_val_u64s(unsigned len, unsigned cf_len)

fs/bcachefs/fs.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,13 +648,18 @@ static struct bch_inode_info *bch2_lookup_trans(struct btree_trans *trans,
648648
const struct qstr *name)
649649
{
650650
struct bch_fs *c = trans->c;
651-
struct btree_iter dirent_iter = {};
652651
subvol_inum inum = {};
653652
struct printbuf buf = PRINTBUF;
654653

654+
struct qstr lookup_name;
655+
int ret = bch2_maybe_casefold(trans, dir_hash_info, name, &lookup_name);
656+
if (ret)
657+
return ERR_PTR(ret);
658+
659+
struct btree_iter dirent_iter = {};
655660
struct bkey_s_c k = bch2_hash_lookup(trans, &dirent_iter, bch2_dirent_hash_desc,
656-
dir_hash_info, dir, name, 0);
657-
int ret = bkey_err(k);
661+
dir_hash_info, dir, &lookup_name, 0);
662+
ret = bkey_err(k);
658663
if (ret)
659664
return ERR_PTR(ret);
660665

0 commit comments

Comments
 (0)