While trying to use a swapfile for hibernation, I noticed that the suspend process was failing when it tried to search for the swap to use for snapshot. I had created the swapfile on ext4 and got the starting physical block offset using the filefrag command. Upon looking at the swap activation code, I realized that the iomap part is doing some rounding up for the physical offset of the swapfile. Then I checked the block size of the filesystem, which was actually set to 1KB by default in my environment. (This was in buildroot, using the genimage utility to create the VM disk partitions, filesystems etc.) The block offset is rounded-up and stored in the swap extents metadata by iomap code, but as the exact value is lost for 1KB-block filesystem, hibernate cannot read back the swap header after it finishes writing data pages to swap. Note that this is not a bug in my understanding. Both swapfile and hibernate subsystems have the correct handling of this edge case, individually. Another observation was that we need to rely on external commands, such as filefrag for getting the swapfile offset value. This value can be conveniently printed in dmesg output when doing swapon. Sukrit Bhatnagar (2): iomap: swap: print warning for unaligned swapfile mm: swap: print starting physical block offset in swapon fs/iomap/swapfile.c | 10 ++++++++++ mm/swapfile.c | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) -- 2.34.1