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-05-08' of git://evilpiepirate.org/bcachefs

Pull bcachefs fixes from Kent Overstreet:

- Some fixes to help with filesystem analysis: ensure superblock
error count gets written if we go ERO, don't discard the journal
aggressively (so it's available for list_journal -a)

- Fix lost wakeup on arm causing us to get stuck when reading btree
nodes

- Fix fsck failing to exit on ctrl-c

- An additional fix for filesystems with misaligned bucket sizes: we
now ensure that allocations are properly aligned

- Setting background target but not promote target will now leave that
data cached on the foreground target, as it used to

- Revert a change to when we allocate the VFS superblock, this was done
for implementing blk_holder_ops but ended up not being needed, and
allocating a superblock and not setting SB_BORN while we do recovery
caused sync() calls and other things to hang

- Assorted fixes for harmless error messages that caused concern to
users

* tag 'bcachefs-2025-05-08' of git://evilpiepirate.org/bcachefs:
bcachefs: Don't aggressively discard the journal
bcachefs: Ensure superblock gets written when we go ERO
bcachefs: Filter out harmless EROFS error messages
bcachefs: journal_shutdown is EROFS, not EIO
bcachefs: Call bch2_fs_start before getting vfs superblock
bcachefs: fix hung task timeout in journal read
bcachefs: Add missing barriers before wake_up_bit()
bcachefs: Ensure proper write alignment
bcachefs: Improve want_cached_ptr()
bcachefs: thread_with_stdio: fix spinning instead of exiting

+55 -19
+21 -1
fs/bcachefs/alloc_foreground.c
··· 1422 1422 1423 1423 wp->sectors_free = UINT_MAX; 1424 1424 1425 - open_bucket_for_each(c, &wp->ptrs, ob, i) 1425 + open_bucket_for_each(c, &wp->ptrs, ob, i) { 1426 + /* 1427 + * Ensure proper write alignment - either due to misaligned 1428 + * bucket sizes (from buggy bcachefs-tools), or writes that mix 1429 + * logical/physical alignment: 1430 + */ 1431 + struct bch_dev *ca = ob_dev(c, ob); 1432 + u64 offset = bucket_to_sector(ca, ob->bucket) + 1433 + ca->mi.bucket_size - 1434 + ob->sectors_free; 1435 + unsigned align = round_up(offset, block_sectors(c)) - offset; 1436 + 1437 + ob->sectors_free = max_t(int, 0, ob->sectors_free - align); 1438 + 1426 1439 wp->sectors_free = min(wp->sectors_free, ob->sectors_free); 1440 + } 1427 1441 1428 1442 wp->sectors_free = rounddown(wp->sectors_free, block_sectors(c)); 1443 + 1444 + /* Did alignment use up space in an open_bucket? */ 1445 + if (unlikely(!wp->sectors_free)) { 1446 + bch2_alloc_sectors_done(c, wp); 1447 + goto retry; 1448 + } 1429 1449 1430 1450 BUG_ON(!wp->sectors_free || wp->sectors_free == UINT_MAX); 1431 1451
+8 -1
fs/bcachefs/btree_io.c
··· 41 41 42 42 clear_btree_node_write_in_flight_inner(b); 43 43 clear_btree_node_write_in_flight(b); 44 + smp_mb__after_atomic(); 44 45 wake_up_bit(&b->flags, BTREE_NODE_write_in_flight); 45 46 } 46 47 ··· 1401 1400 1402 1401 printbuf_exit(&buf); 1403 1402 clear_btree_node_read_in_flight(b); 1403 + smp_mb__after_atomic(); 1404 1404 wake_up_bit(&b->flags, BTREE_NODE_read_in_flight); 1405 1405 } 1406 1406 ··· 1597 1595 printbuf_exit(&buf); 1598 1596 1599 1597 clear_btree_node_read_in_flight(b); 1598 + smp_mb__after_atomic(); 1600 1599 wake_up_bit(&b->flags, BTREE_NODE_read_in_flight); 1601 1600 } 1602 1601 ··· 1724 1721 set_btree_node_read_error(b); 1725 1722 bch2_btree_lost_data(c, b->c.btree_id); 1726 1723 clear_btree_node_read_in_flight(b); 1724 + smp_mb__after_atomic(); 1727 1725 wake_up_bit(&b->flags, BTREE_NODE_read_in_flight); 1728 1726 printbuf_exit(&buf); 1729 1727 return; ··· 2065 2061 2066 2062 if (new & (1U << BTREE_NODE_write_in_flight)) 2067 2063 __bch2_btree_node_write(c, b, BTREE_WRITE_ALREADY_STARTED|type); 2068 - else 2064 + else { 2065 + smp_mb__after_atomic(); 2069 2066 wake_up_bit(&b->flags, BTREE_NODE_write_in_flight); 2067 + } 2070 2068 } 2071 2069 2072 2070 static void btree_node_write_done(struct bch_fs *c, struct btree *b, u64 start_time) ··· 2181 2175 } 2182 2176 2183 2177 clear_btree_node_write_in_flight_inner(b); 2178 + smp_mb__after_atomic(); 2184 2179 wake_up_bit(&b->flags, BTREE_NODE_write_in_flight_inner); 2185 2180 INIT_WORK(&wb->work, btree_node_write_work); 2186 2181 queue_work(c->btree_io_complete_wq, &wb->work);
+1
fs/bcachefs/buckets.h
··· 44 44 BUILD_BUG_ON(!((union ulong_byte_assert) { .ulong = 1UL << BUCKET_LOCK_BITNR }).byte); 45 45 46 46 clear_bit_unlock(BUCKET_LOCK_BITNR, (void *) &b->lock); 47 + smp_mb__after_atomic(); 47 48 wake_up_bit((void *) &b->lock, BUCKET_LOCK_BITNR); 48 49 } 49 50
+1
fs/bcachefs/ec.h
··· 160 160 BUILD_BUG_ON(!((union ulong_byte_assert) { .ulong = 1UL << BUCKET_LOCK_BITNR }).byte); 161 161 162 162 clear_bit_unlock(BUCKET_LOCK_BITNR, (void *) &s->lock); 163 + smp_mb__after_atomic(); 163 164 wake_up_bit((void *) &s->lock, BUCKET_LOCK_BITNR); 164 165 } 165 166
+1 -1
fs/bcachefs/errcode.h
··· 269 269 x(BCH_ERR_invalid_sb, invalid_sb_downgrade) \ 270 270 x(BCH_ERR_invalid, invalid_bkey) \ 271 271 x(BCH_ERR_operation_blocked, nocow_lock_blocked) \ 272 - x(EIO, journal_shutdown) \ 272 + x(EROFS, journal_shutdown) \ 273 273 x(EIO, journal_flush_err) \ 274 274 x(EIO, journal_write_err) \ 275 275 x(EIO, btree_node_read_err) \
+3 -2
fs/bcachefs/extents.c
··· 1056 1056 static bool want_cached_ptr(struct bch_fs *c, struct bch_io_opts *opts, 1057 1057 struct bch_extent_ptr *ptr) 1058 1058 { 1059 - if (!opts->promote_target || 1060 - !bch2_dev_in_target(c, ptr->dev, opts->promote_target)) 1059 + unsigned target = opts->promote_target ?: opts->foreground_target; 1060 + 1061 + if (target && !bch2_dev_in_target(c, ptr->dev, target)) 1061 1062 return false; 1062 1063 1063 1064 struct bch_dev *ca = bch2_dev_rcu_noerror(c, ptr->dev);
+3 -8
fs/bcachefs/fs.c
··· 2502 2502 2503 2503 bch2_opts_apply(&c->opts, opts); 2504 2504 2505 - /* 2506 - * need to initialise sb and set c->vfs_sb _before_ starting fs, 2507 - * for blk_holder_ops 2508 - */ 2505 + ret = bch2_fs_start(c); 2506 + if (ret) 2507 + goto err_stop_fs; 2509 2508 2510 2509 sb = sget(fc->fs_type, NULL, bch2_set_super, fc->sb_flags|SB_NOSEC, c); 2511 2510 ret = PTR_ERR_OR_ZERO(sb); ··· 2565 2566 #endif 2566 2567 2567 2568 sb->s_shrink->seeks = 0; 2568 - 2569 - ret = bch2_fs_start(c); 2570 - if (ret) 2571 - goto err_put_super; 2572 2569 2573 2570 #ifdef CONFIG_UNICODE 2574 2571 sb->s_encoding = c->cf_encoding;
+3 -1
fs/bcachefs/journal_io.c
··· 19 19 20 20 #include <linux/ioprio.h> 21 21 #include <linux/string_choices.h> 22 + #include <linux/sched/sysctl.h> 22 23 23 24 void bch2_journal_pos_from_member_info_set(struct bch_fs *c) 24 25 { ··· 1263 1262 degraded = true; 1264 1263 } 1265 1264 1266 - closure_sync(&jlist.cl); 1265 + while (closure_sync_timeout(&jlist.cl, sysctl_hung_task_timeout_secs * HZ / 2)) 1266 + ; 1267 1267 1268 1268 if (jlist.ret) 1269 1269 return jlist.ret;
+4 -3
fs/bcachefs/journal_reclaim.c
··· 266 266 267 267 static bool should_discard_bucket(struct journal *j, struct journal_device *ja) 268 268 { 269 - bool ret; 270 - 271 269 spin_lock(&j->lock); 272 - ret = ja->discard_idx != ja->dirty_idx_ondisk; 270 + unsigned min_free = max(4, ja->nr / 8); 271 + 272 + bool ret = bch2_journal_dev_buckets_available(j, ja, journal_space_discarded) < min_free && 273 + ja->discard_idx != ja->dirty_idx_ondisk; 273 274 spin_unlock(&j->lock); 274 275 275 276 return ret;
+2 -1
fs/bcachefs/move.c
··· 784 784 goto err; 785 785 786 786 ret = bch2_btree_write_buffer_tryflush(trans); 787 - bch_err_msg(c, ret, "flushing btree write buffer"); 787 + if (!bch2_err_matches(ret, EROFS)) 788 + bch_err_msg(c, ret, "flushing btree write buffer"); 788 789 if (ret) 789 790 goto err; 790 791
+5
fs/bcachefs/super.c
··· 377 377 bch_verbose(c, "marking filesystem clean"); 378 378 bch2_fs_mark_clean(c); 379 379 } else { 380 + /* Make sure error counts/counters are persisted */ 381 + mutex_lock(&c->sb_lock); 382 + bch2_write_super(c); 383 + mutex_unlock(&c->sb_lock); 384 + 380 385 bch_verbose(c, "done going read-only, filesystem not clean"); 381 386 } 382 387 }
+3 -1
fs/bcachefs/thread_with_file.c
··· 455 455 struct stdio_buf *buf = &stdio->output; 456 456 unsigned long flags; 457 457 ssize_t ret; 458 - 459 458 again: 459 + if (stdio->done) 460 + return -EPIPE; 461 + 460 462 spin_lock_irqsave(&buf->lock, flags); 461 463 ret = bch2_darray_vprintf(&buf->buf, GFP_NOWAIT, fmt, args); 462 464 spin_unlock_irqrestore(&buf->lock, flags);