Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'bcachefs-2025-07-03' of git://evilpiepirate.org/bcachefs

Pull bcachefs fixes from Kent Overstreet:
"The 'opts.casefold_disabled' patch is non critical, but would be a
6.15 backport; it's to address the casefolding + overlayfs
incompatibility that was discovvered late.

It's late because I was hoping that this would be addressed on the
overlayfs side (and will be in 6.17), but user reports keep coming in
on this one (lots of people are using docker these days)"

* tag 'bcachefs-2025-07-03' of git://evilpiepirate.org/bcachefs:
bcachefs: opts.casefold_disabled
bcachefs: Work around deadlock to btree node rewrites in journal replay
bcachefs: Fix incorrect transaction restart handling
bcachefs: fix btree_trans_peek_prev_journal()
bcachefs: mark invalid_btree_id autofix

+92 -53
+9 -2
fs/bcachefs/bcachefs.h
··· 863 863 DARRAY(enum bcachefs_metadata_version) 864 864 incompat_versions_requested; 865 865 866 - #ifdef CONFIG_UNICODE 867 866 struct unicode_map *cf_encoding; 868 - #endif 869 867 870 868 struct bch_sb_handle disk_sb; 871 869 ··· 1281 1283 return test_bit(BCH_FS_discard_mount_opt_set, &c->flags) 1282 1284 ? c->opts.discard 1283 1285 : ca->mi.discard; 1286 + } 1287 + 1288 + static inline bool bch2_fs_casefold_enabled(struct bch_fs *c) 1289 + { 1290 + #ifdef CONFIG_UNICODE 1291 + return !c->opts.casefold_disabled; 1292 + #else 1293 + return false; 1294 + #endif 1284 1295 } 1285 1296 1286 1297 #endif /* _BCACHEFS_H */
+34 -7
fs/bcachefs/btree_io.c
··· 1337 1337 1338 1338 btree_node_reset_sib_u64s(b); 1339 1339 1340 - scoped_guard(rcu) 1341 - bkey_for_each_ptr(bch2_bkey_ptrs(bkey_i_to_s(&b->key)), ptr) { 1342 - struct bch_dev *ca2 = bch2_dev_rcu(c, ptr->dev); 1340 + /* 1341 + * XXX: 1342 + * 1343 + * We deadlock if too many btree updates require node rewrites while 1344 + * we're still in journal replay. 1345 + * 1346 + * This is because btree node rewrites generate more updates for the 1347 + * interior updates (alloc, backpointers), and if those updates touch 1348 + * new nodes and generate more rewrites - well, you see the problem. 1349 + * 1350 + * The biggest cause is that we don't use the btree write buffer (for 1351 + * the backpointer updates - this needs some real thought on locking in 1352 + * order to fix. 1353 + * 1354 + * The problem with this workaround (not doing the rewrite for degraded 1355 + * nodes in journal replay) is that those degraded nodes persist, and we 1356 + * don't want that (this is a real bug when a btree node write completes 1357 + * with fewer replicas than we wanted and leaves a degraded node due to 1358 + * device _removal_, i.e. the device went away mid write). 1359 + * 1360 + * It's less of a bug here, but still a problem because we don't yet 1361 + * have a way of tracking degraded data - we another index (all 1362 + * extents/btree nodes, by replicas entry) in order to fix properly 1363 + * (re-replicate degraded data at the earliest possible time). 1364 + */ 1365 + if (c->recovery.passes_complete & BIT_ULL(BCH_RECOVERY_PASS_journal_replay)) { 1366 + scoped_guard(rcu) 1367 + bkey_for_each_ptr(bch2_bkey_ptrs(bkey_i_to_s(&b->key)), ptr) { 1368 + struct bch_dev *ca2 = bch2_dev_rcu(c, ptr->dev); 1343 1369 1344 - if (!ca2 || ca2->mi.state != BCH_MEMBER_STATE_rw) { 1345 - set_btree_node_need_rewrite(b); 1346 - set_btree_node_need_rewrite_degraded(b); 1370 + if (!ca2 || ca2->mi.state != BCH_MEMBER_STATE_rw) { 1371 + set_btree_node_need_rewrite(b); 1372 + set_btree_node_need_rewrite_degraded(b); 1373 + } 1347 1374 } 1348 - } 1375 + } 1349 1376 1350 1377 if (!ptr_written) { 1351 1378 set_btree_node_need_rewrite(b);
+1 -1
fs/bcachefs/btree_iter.c
··· 2189 2189 struct btree_path *path = btree_iter_path(trans, iter); 2190 2190 struct bkey_i *next_journal = 2191 2191 bch2_btree_journal_peek_prev(trans, iter, search_key, 2192 - k->k ? k->k->p : path_l(path)->b->key.k.p); 2192 + k->k ? k->k->p : path_l(path)->b->data->min_key); 2193 2193 2194 2194 if (next_journal) { 2195 2195 iter->k = next_journal->k;
+9 -10
fs/bcachefs/dirent.c
··· 18 18 { 19 19 *out_cf = (struct qstr) QSTR_INIT(NULL, 0); 20 20 21 - #ifdef CONFIG_UNICODE 21 + if (!bch2_fs_casefold_enabled(trans->c)) 22 + return -EOPNOTSUPP; 23 + 22 24 unsigned char *buf = bch2_trans_kmalloc(trans, BCH_NAME_MAX + 1); 23 25 int ret = PTR_ERR_OR_ZERO(buf); 24 26 if (ret) ··· 32 30 33 31 *out_cf = (struct qstr) QSTR_INIT(buf, ret); 34 32 return 0; 35 - #else 36 - return -EOPNOTSUPP; 37 - #endif 38 33 } 39 34 40 35 static unsigned bch2_dirent_name_bytes(struct bkey_s_c_dirent d) ··· 230 231 prt_printf(out, " type %s", bch2_d_type_str(d.v->d_type)); 231 232 } 232 233 233 - int bch2_dirent_init_name(struct bkey_i_dirent *dirent, 234 + int bch2_dirent_init_name(struct bch_fs *c, 235 + struct bkey_i_dirent *dirent, 234 236 const struct bch_hash_info *hash_info, 235 237 const struct qstr *name, 236 238 const struct qstr *cf_name) ··· 251 251 offsetof(struct bch_dirent, d_name) - 252 252 name->len); 253 253 } else { 254 - #ifdef CONFIG_UNICODE 254 + if (!bch2_fs_casefold_enabled(c)) 255 + return -EOPNOTSUPP; 256 + 255 257 memcpy(&dirent->v.d_cf_name_block.d_names[0], name->name, name->len); 256 258 257 259 char *cf_out = &dirent->v.d_cf_name_block.d_names[name->len]; ··· 279 277 dirent->v.d_cf_name_block.d_cf_name_len = cpu_to_le16(cf_len); 280 278 281 279 EBUG_ON(bch2_dirent_get_casefold_name(dirent_i_to_s_c(dirent)).len != cf_len); 282 - #else 283 - return -EOPNOTSUPP; 284 - #endif 285 280 } 286 281 287 282 unsigned u64s = dirent_val_u64s(name->len, cf_len); ··· 312 313 dirent->v.d_type = type; 313 314 dirent->v.d_unused = 0; 314 315 315 - int ret = bch2_dirent_init_name(dirent, hash_info, name, cf_name); 316 + int ret = bch2_dirent_init_name(trans->c, dirent, hash_info, name, cf_name); 316 317 if (ret) 317 318 return ERR_PTR(ret); 318 319
+2 -1
fs/bcachefs/dirent.h
··· 59 59 dst->v.d_type = src.v->d_type; 60 60 } 61 61 62 - int bch2_dirent_init_name(struct bkey_i_dirent *, 62 + int bch2_dirent_init_name(struct bch_fs *, 63 + struct bkey_i_dirent *, 63 64 const struct bch_hash_info *, 64 65 const struct qstr *, 65 66 const struct qstr *);
+3 -4
fs/bcachefs/fs.c
··· 722 722 if (IS_ERR(inode)) 723 723 inode = NULL; 724 724 725 - #ifdef CONFIG_UNICODE 726 725 if (!inode && IS_CASEFOLDED(vdir)) { 727 726 /* 728 727 * Do not cache a negative dentry in casefolded directories ··· 736 737 */ 737 738 return NULL; 738 739 } 739 - #endif 740 740 741 741 return d_splice_alias(&inode->v, dentry); 742 742 } ··· 2564 2566 sb->s_shrink->seeks = 0; 2565 2567 2566 2568 #ifdef CONFIG_UNICODE 2567 - sb->s_encoding = c->cf_encoding; 2568 - #endif 2569 + if (bch2_fs_casefold_enabled(c)) 2570 + sb->s_encoding = c->cf_encoding; 2569 2571 generic_set_sb_d_ops(sb); 2572 + #endif 2570 2573 2571 2574 vinode = bch2_vfs_inode_get(c, BCACHEFS_ROOT_SUBVOL_INUM); 2572 2575 ret = PTR_ERR_OR_ZERO(vinode);
+1 -3
fs/bcachefs/fsck.c
··· 2302 2302 *hash_info = bch2_hash_info_init(c, &i->inode); 2303 2303 dir->first_this_inode = false; 2304 2304 2305 - #ifdef CONFIG_UNICODE 2306 2305 hash_info->cf_encoding = bch2_inode_casefold(c, &i->inode) ? c->cf_encoding : NULL; 2307 - #endif 2308 2306 2309 2307 ret = bch2_str_hash_check_key(trans, s, &bch2_dirent_hash_desc, hash_info, 2310 2308 iter, k, need_second_pass); ··· 2817 2819 ret = remove_backpointer(trans, &inode); 2818 2820 bch_err_msg(c, ret, "removing dirent"); 2819 2821 if (ret) 2820 - break; 2822 + goto out; 2821 2823 2822 2824 ret = reattach_inode(trans, &inode); 2823 2825 bch_err_msg(c, ret, "reattaching inode %llu", inode.bi_inum);
+8 -5
fs/bcachefs/inode.c
··· 1265 1265 { 1266 1266 struct bch_fs *c = trans->c; 1267 1267 1268 - #ifdef CONFIG_UNICODE 1268 + #ifndef CONFIG_UNICODE 1269 + bch_err(c, "Cannot use casefolding on a kernel without CONFIG_UNICODE"); 1270 + return -EOPNOTSUPP; 1271 + #endif 1272 + 1273 + if (c->opts.casefold_disabled) 1274 + return -EOPNOTSUPP; 1275 + 1269 1276 int ret = 0; 1270 1277 /* Not supported on individual files. */ 1271 1278 if (!S_ISDIR(bi->bi_mode)) ··· 1296 1289 bi->bi_fields_set |= BIT(Inode_opt_casefold); 1297 1290 1298 1291 return bch2_maybe_propagate_has_case_insensitive(trans, inum, bi); 1299 - #else 1300 - bch_err(c, "Cannot use casefolding on a kernel without CONFIG_UNICODE"); 1301 - return -EOPNOTSUPP; 1302 - #endif 1303 1292 } 1304 1293 1305 1294 static noinline int __bch2_inode_rm_snapshot(struct btree_trans *trans, u64 inum, u32 snapshot)
+5
fs/bcachefs/opts.h
··· 234 234 OPT_BOOL(), \ 235 235 BCH_SB_CASEFOLD, false, \ 236 236 NULL, "Dirent lookups are casefolded") \ 237 + x(casefold_disabled, u8, \ 238 + OPT_FS|OPT_MOUNT, \ 239 + OPT_BOOL(), \ 240 + BCH2_NO_SB_OPT, false, \ 241 + NULL, "Disable casefolding filesystem wide") \ 237 242 x(inodes_32bit, u8, \ 238 243 OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \ 239 244 OPT_BOOL(), \
+1 -1
fs/bcachefs/sb-errors_format.h
··· 314 314 x(accounting_mismatch, 272, FSCK_AUTOFIX) \ 315 315 x(accounting_replicas_not_marked, 273, 0) \ 316 316 x(accounting_to_invalid_device, 289, 0) \ 317 - x(invalid_btree_id, 274, 0) \ 317 + x(invalid_btree_id, 274, FSCK_AUTOFIX) \ 318 318 x(alloc_key_io_time_bad, 275, 0) \ 319 319 x(alloc_key_fragmentation_lru_wrong, 276, FSCK_AUTOFIX) \ 320 320 x(accounting_key_junk_at_end, 277, FSCK_AUTOFIX) \
+3 -2
fs/bcachefs/str_hash.c
··· 38 38 struct bkey_s_c_dirent old, 39 39 bool *updated_before_k_pos) 40 40 { 41 + struct bch_fs *c = trans->c; 41 42 struct qstr old_name = bch2_dirent_get_name(old); 42 43 struct bkey_i_dirent *new = bch2_trans_kmalloc(trans, BKEY_U64s_MAX * sizeof(u64)); 43 44 int ret = PTR_ERR_OR_ZERO(new); ··· 61 60 sprintf(renamed_buf, "%.*s.fsck_renamed-%u", 62 61 old_name.len, old_name.name, i)); 63 62 64 - ret = bch2_dirent_init_name(new, hash_info, &renamed_name, NULL); 63 + ret = bch2_dirent_init_name(c, new, hash_info, &renamed_name, NULL); 65 64 if (ret) 66 65 return ret; 67 66 ··· 80 79 } 81 80 82 81 ret = ret ?: bch2_fsck_update_backpointers(trans, s, desc, hash_info, &new->k_i); 83 - bch_err_fn(trans->c, ret); 82 + bch_err_fn(c, ret); 84 83 return ret; 85 84 } 86 85
-2
fs/bcachefs/str_hash.h
··· 48 48 struct bch_hash_info info = { 49 49 .inum_snapshot = bi->bi_snapshot, 50 50 .type = INODE_STR_HASH(bi), 51 - #ifdef CONFIG_UNICODE 52 51 .cf_encoding = bch2_inode_casefold(c, bi) ? c->cf_encoding : NULL, 53 - #endif 54 52 .siphash_key = { .k0 = bi->bi_hash_seed } 55 53 }; 56 54
+16 -15
fs/bcachefs/super.c
··· 1025 1025 } 1026 1026 1027 1027 #ifdef CONFIG_UNICODE 1028 - /* Default encoding until we can potentially have more as an option. */ 1029 - c->cf_encoding = utf8_load(BCH_FS_DEFAULT_UTF8_ENCODING); 1030 - if (IS_ERR(c->cf_encoding)) { 1031 - printk(KERN_ERR "Cannot load UTF-8 encoding for filesystem. Version: %u.%u.%u", 1032 - unicode_major(BCH_FS_DEFAULT_UTF8_ENCODING), 1033 - unicode_minor(BCH_FS_DEFAULT_UTF8_ENCODING), 1034 - unicode_rev(BCH_FS_DEFAULT_UTF8_ENCODING)); 1035 - ret = -EINVAL; 1036 - goto err; 1028 + if (bch2_fs_casefold_enabled(c)) { 1029 + /* Default encoding until we can potentially have more as an option. */ 1030 + c->cf_encoding = utf8_load(BCH_FS_DEFAULT_UTF8_ENCODING); 1031 + if (IS_ERR(c->cf_encoding)) { 1032 + printk(KERN_ERR "Cannot load UTF-8 encoding for filesystem. Version: %u.%u.%u", 1033 + unicode_major(BCH_FS_DEFAULT_UTF8_ENCODING), 1034 + unicode_minor(BCH_FS_DEFAULT_UTF8_ENCODING), 1035 + unicode_rev(BCH_FS_DEFAULT_UTF8_ENCODING)); 1036 + ret = -EINVAL; 1037 + goto err; 1038 + } 1037 1039 } 1038 1040 #else 1039 1041 if (c->sb.features & BIT_ULL(BCH_FEATURE_casefolding)) { ··· 1162 1160 1163 1161 print_mount_opts(c); 1164 1162 1165 - #ifdef CONFIG_UNICODE 1166 - bch_info(c, "Using encoding defined by superblock: utf8-%u.%u.%u", 1167 - unicode_major(BCH_FS_DEFAULT_UTF8_ENCODING), 1168 - unicode_minor(BCH_FS_DEFAULT_UTF8_ENCODING), 1169 - unicode_rev(BCH_FS_DEFAULT_UTF8_ENCODING)); 1170 - #endif 1163 + if (c->cf_encoding) 1164 + bch_info(c, "Using encoding defined by superblock: utf8-%u.%u.%u", 1165 + unicode_major(BCH_FS_DEFAULT_UTF8_ENCODING), 1166 + unicode_minor(BCH_FS_DEFAULT_UTF8_ENCODING), 1167 + unicode_rev(BCH_FS_DEFAULT_UTF8_ENCODING)); 1171 1168 1172 1169 if (!bch2_fs_may_start(c)) 1173 1170 return bch_err_throw(c, insufficient_devices_to_start);