Subject: linux-next: manual merge of the bcachefs tree with Linus' tree

From: Stephen Rothwell <[email-masked]>
Date: Thu, 11 Jul 2024 10:04:26 +1000

Hi all,

Today's linux-next merge of the bcachefs tree got a conflict in:

  fs/bcachefs/btree_gc.c

between commit:

  b5cbb42dc59f ("bcachefs: Repair fragmentation_lru in alloc_write_key()")

from Linus' tree and commits:

  282e9325dd4a ("bcachefs: bch_alloc->stripe_sectors")
  f75ad706a1cf ("bcachefs: fsck_err() may now take a btree_trans")

from the bcachefs tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc fs/bcachefs/btree_gc.c
index 7c72a9e6f511,2e9ccb2071ff..000000000000
--- a/fs/bcachefs/btree_gc.c
+++ b/fs/bcachefs/btree_gc.c
@@@ -899,14 -812,14 +812,16 @@@ static int bch2_alloc_write_key(struct 
  	alloc_data_type_set(&gc, gc.data_type);
  
  	if (gc.data_type != old_gc.data_type ||
- 	    gc.dirty_sectors != old_gc.dirty_sectors)
- 		bch2_dev_usage_update(c, ca, &old_gc, &gc, 0, true);
- 	percpu_up_read(&c->mark_lock);
+ 	    gc.dirty_sectors != old_gc.dirty_sectors) {
+ 		ret = bch2_alloc_key_to_dev_counters(trans, ca, &old_gc, &gc, BTREE_TRIGGER_gc);
+ 		if (ret)
+ 			return ret;
+ 	}
  
 +	gc.fragmentation_lru = alloc_lru_idx_fragmentation(gc, ca);
 +
- 	if (fsck_err_on(new.data_type != gc.data_type, c,
- 			alloc_key_data_type_wrong,
+ 	if (fsck_err_on(new.data_type != gc.data_type,
+ 			trans, alloc_key_data_type_wrong,
  			"bucket %llu:%llu gen %u has wrong data_type"
  			": got %s, should be %s",
  			iter->pos.inode, iter->pos.offset,
@@@ -916,21 -829,28 +831,23 @@@
  		new.data_type = gc.data_type;
  
  #define copy_bucket_field(_errtype, _f)					\
- 	if (fsck_err_on(new._f != gc._f, c, _errtype,			\
+ 	if (fsck_err_on(new._f != gc._f,				\
+ 			trans, _errtype,				\
  			"bucket %llu:%llu gen %u data type %s has wrong " #_f	\
 -			": got %u, should be %u",			\
 +			": got %llu, should be %llu",			\
  			iter->pos.inode, iter->pos.offset,		\
  			gc.gen,						\
  			bch2_data_type_str(gc.data_type),		\
 -			new._f, gc._f))					\
 +			(u64) new._f, (u64) gc._f))				\
  		new._f = gc._f;						\
  
 -	copy_bucket_field(alloc_key_gen_wrong,
 -			  gen);
 -	copy_bucket_field(alloc_key_dirty_sectors_wrong,
 -			  dirty_sectors);
 -	copy_bucket_field(alloc_key_stripe_sectors_wrong,
 -			  stripe_sectors);
 -	copy_bucket_field(alloc_key_cached_sectors_wrong,
 -			  cached_sectors);
 -	copy_bucket_field(alloc_key_stripe_wrong,
 -			  stripe);
 -	copy_bucket_field(alloc_key_stripe_redundancy_wrong,
 -			  stripe_redundancy);
 +	copy_bucket_field(alloc_key_gen_wrong,			gen);
 +	copy_bucket_field(alloc_key_dirty_sectors_wrong,	dirty_sectors);
++	copy_bucket_field(alloc_key_stripe_sectors_wrong,	stripe_sectors);
 +	copy_bucket_field(alloc_key_cached_sectors_wrong,	cached_sectors);
 +	copy_bucket_field(alloc_key_stripe_wrong,		stripe);
 +	copy_bucket_field(alloc_key_stripe_redundancy_wrong,	stripe_redundancy);
 +	copy_bucket_field(alloc_key_fragmentation_lru_wrong,	fragmentation_lru);
  #undef copy_bucket_field
  
  	if (!bch2_alloc_v4_cmp(*old, new))