Skip to contentSkip to conversation

docs/power: note Btrfs limitation with FIBMAP for swap file offset

PATCH In review Arun Rao Balappa 2 participants 2 messages May 12

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 docs/power: note Btrfs limitation with FIBMAP for swap file offset

On Btrfs, the FIBMAP ioctl does not return physical block addresses. Tools such as filefrag therefore cannot determine the correct swap file offset for use as resume_offset. Document the correct btrfs-progs command to use instead.

---
 Documentation/power/swsusp-and-swap-files.rst | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/power/swsusp-and-swap-files.rst +8 -0
index a33a2919d..44ffe02b3 100644
@@ -35,6 +35,14 @@ FIBMAP ioctl and determine the location of the file's swap header, as the
 offset, in <PAGE_SIZE> units, from the beginning of the partition which
 holds the swap file.
 
+.. note::
+
+   On Btrfs, the FIBMAP ioctl does not return physical block addresses, so
+   tools such as ``filefrag`` cannot be used to determine the correct offset.
+   On Btrfs, use btrfs-progs instead::
+
+      btrfs inspect-internal map-swapfile -r <swap_file_path>
+
 3) Add the following parameters to the kernel command line::
 
     resume=<swap_file_partition> resume_offset=<swap_file_offset>
Signature · 1 line
2.53.0
#1 lore raw
Quoted 1 line · Arun Rao Balappa

On Btrfs, the FIBMAP ioctl does not return physical block addresses.

On btrfs, and on anything that writes out of place or uses multiple devices for that matter, FIBMAP is not implemented.

Quoted 3 lines

Tools such as filefrag therefore cannot determine the correct swap file offset for use as resume_offset. Document the correct btrfs-progs command to use instead.

All of this is inherently unsafe. File systems and do move file data without notifying users. This document is a really bad idea and should be removed as we should not encourage users to rely on these kinds of hacks.