I tested Swapfile on Btrfs with LUKS in Arch VM. I noticed the physical offset of Swapfile is changed after btrfs balance.
Before balance:
$ sudo filefrag -v /swap/swapfile
Filesystem type is: 9123683e
File size of /swap/swapfile is 2147483648 (524288 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 0: 6241536.. 6241536: 1:
1: 1.. 262143: 6241537.. 6503679: 262143: unwritten
2: 262144.. 524287: 5979392.. 6241535: 262144: 6503680: last,unwritten,eof
/swap/swapfile: 2 extents found
After balance:
$ sudo swapon /swap/swapfile
swapon: /swap/swapfile: swapon failed: Invalid argument
$ sudo filefrag -v /swap/swapfile
Filesystem type is: 9123683e
File size of /swap/swapfile is 2147483648 (524288 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 0: 9338112.. 9338112: 1:
1: 1.. 524287: 9338113.. 9862399: 524287: last,unwritten,eof
/swap/swapfile: 1 extent found
physical_offset
of Swapfile does not match resume_offset
for hibernation in kernel parameter.
I tried disabling CoW for the @swap
subvolume with the mount option nodatacow
and running $ sudo chattr +c /swap/swapfile
, but that does not help, still the same error message of swapon.
Update:
Kernel 5.15 has no issue, however, the offset of Swapfile is also changed a little bit after the balance, but unlike Kernel 6.1.
Kernel 5.15 has the same issue