Re: [paulmck-rcu:frederic.2023.12.08a 29/37] fs/btrfs/transaction.c:496:6: error: call to '__compiletime_assert_329' declared with 'error' attribute: Need native word sized stores/loads for atomicity.

From: Paul E. McKenney
Date: Sat Dec 09 2023 - 10:51:35 EST


On Sat, Dec 09, 2023 at 06:20:37PM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git frederic.2023.12.08a
> head: 37843b5f561a08ae899fb791eeeb5abd992eabe2
> commit: 7dd87072d40809e26503f04b79d63290288dbbac [29/37] btrfs: Adjust ->last_trans ordering in btrfs_record_root_in_trans()
> config: riscv-rv32_defconfig (https://download.01.org/0day-ci/archive/20231209/202312091837.cKaPw0Tf-lkp@xxxxxxxxx/config)
> compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231209/202312091837.cKaPw0Tf-lkp@xxxxxxxxx/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202312091837.cKaPw0Tf-lkp@xxxxxxxxx/
>
> All errors (new ones prefixed by >>):
>
> warning: unknown warning option '-Wpacked-not-aligned'; did you mean '-Wpacked-non-pod'? [-Wunknown-warning-option]
> warning: unknown warning option '-Wstringop-truncation'; did you mean '-Wstring-concatenation'? [-Wunknown-warning-option]
> warning: unknown warning option '-Wmaybe-uninitialized'; did you mean '-Wuninitialized'? [-Wunknown-warning-option]
> >> fs/btrfs/transaction.c:496:6: error: call to '__compiletime_assert_329' declared with 'error' attribute: Need native word sized stores/loads for atomicity.
> 496 | if (smp_load_acquire(&root->last_trans) == trans->transid && /* ^^^ */
> | ^

Ooooh!!! :-/

>From what I can see, the current code can tear this load on 32-bit
systems, which can result in bad comparisons and then in failure to wait
for a partially complete transaction.

So is btrfs actually supported on 32-bit systems? If not, would the
following patch be appropriate?

If btrfs is to be supported on 32-bit systems, from what I can see some
major surgery is required, even if a 32-bit counter is wrap-safe for
this particular type of transaction. (But SSDs? In-memory btrfs
filesystems?)

Thanx, Paul

------------------------------------------------------------------------

diff --git a/fs/btrfs/Kconfig b/fs/btrfs/Kconfig
index 4fb925e8c981..4d56158c34f9 100644
--- a/fs/btrfs/Kconfig
+++ b/fs/btrfs/Kconfig
@@ -19,6 +19,7 @@ config BTRFS_FS
select RAID6_PQ
select XOR_BLOCKS
depends on PAGE_SIZE_LESS_THAN_256KB
+ depends on 64BIT

help
Btrfs is a general purpose copy-on-write filesystem with extents,