@@ -18,7 +18,9 @@ int bch2_casefold(struct btree_trans *trans, const struct bch_hash_info *info,
1818{
1919 * out_cf = (struct qstr ) QSTR_INIT (NULL , 0 );
2020
21- #ifdef CONFIG_UNICODE
21+ if (!bch2_fs_casefold_enabled (trans -> c ))
22+ return - EOPNOTSUPP ;
23+
2224 unsigned char * buf = bch2_trans_kmalloc (trans , BCH_NAME_MAX + 1 );
2325 int ret = PTR_ERR_OR_ZERO (buf );
2426 if (ret )
@@ -30,9 +32,6 @@ int bch2_casefold(struct btree_trans *trans, const struct bch_hash_info *info,
3032
3133 * out_cf = (struct qstr ) QSTR_INIT (buf , ret );
3234 return 0 ;
33- #else
34- return - EOPNOTSUPP ;
35- #endif
3635}
3736
3837static unsigned bch2_dirent_name_bytes (struct bkey_s_c_dirent d )
@@ -231,7 +230,8 @@ void bch2_dirent_to_text(struct printbuf *out, struct bch_fs *c, struct bkey_s_c
231230 prt_printf (out , " type %s" , bch2_d_type_str (d .v -> d_type ));
232231}
233232
234- int bch2_dirent_init_name (struct bkey_i_dirent * dirent ,
233+ int bch2_dirent_init_name (struct bch_fs * c ,
234+ struct bkey_i_dirent * dirent ,
235235 const struct bch_hash_info * hash_info ,
236236 const struct qstr * name ,
237237 const struct qstr * cf_name )
@@ -251,7 +251,9 @@ int bch2_dirent_init_name(struct bkey_i_dirent *dirent,
251251 offsetof(struct bch_dirent , d_name ) -
252252 name -> len );
253253 } else {
254- #ifdef CONFIG_UNICODE
254+ if (!bch2_fs_casefold_enabled (c ))
255+ return - EOPNOTSUPP ;
256+
255257 memcpy (& dirent -> v .d_cf_name_block .d_names [0 ], name -> name , name -> len );
256258
257259 char * cf_out = & dirent -> v .d_cf_name_block .d_names [name -> len ];
@@ -277,9 +279,6 @@ int bch2_dirent_init_name(struct bkey_i_dirent *dirent,
277279 dirent -> v .d_cf_name_block .d_cf_name_len = cpu_to_le16 (cf_len );
278280
279281 EBUG_ON (bch2_dirent_get_casefold_name (dirent_i_to_s_c (dirent )).len != cf_len );
280- #else
281- return - EOPNOTSUPP ;
282- #endif
283282 }
284283
285284 unsigned u64s = dirent_val_u64s (name -> len , cf_len );
@@ -313,7 +312,7 @@ struct bkey_i_dirent *bch2_dirent_create_key(struct btree_trans *trans,
313312 dirent -> v .d_type = type ;
314313 dirent -> v .d_unused = 0 ;
315314
316- int ret = bch2_dirent_init_name (dirent , hash_info , name , cf_name );
315+ int ret = bch2_dirent_init_name (trans -> c , dirent , hash_info , name , cf_name );
317316 if (ret )
318317 return ERR_PTR (ret );
319318
0 commit comments