Skip to content

Commit 5dd176d

Browse files
committed
btrfs-progs: docs: clarify swapfile
Clarify active vs inactive swapfile regarding snapshotting. Issue: #608 Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 33560e2 commit 5dd176d

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

Documentation/ch-swapfile.rst

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
A swapfile is file-backed memory that the system uses to temporarily offload
2-
the RAM. It is supported since kernel 5.0. Use ``swapon(8)`` to activate the
3-
swapfile. There are some limitations of the implementation in BTRFS and Linux
4-
swap subsystem:
2+
the RAM. It is supported since kernel 5.0. Use ``swapon(8)`` to activate it as
3+
a swap area, until then it's just a normal file (with NODATACOW set), for which
4+
the special restrictions for active swapfile areas don't apply.
5+
6+
There are some limitations of the implementation in BTRFS and Linux swap
7+
subsystem:
58

69
* filesystem - must be only single device
710
* filesystem - must have only *single* data profile
8-
* swapfile - the containing subvolume cannot be snapshotted
9-
* swapfile - must be preallocated (i.e. no holes)
10-
* swapfile - must be NODATACOW (i.e. also NODATASUM, no compression)
11+
* swapfile - the containing subvolume cannot be snapshotted if there's an active swapfile
12+
* swapfile - the file must be preallocated (i.e. no holes)
13+
* swapfile - the file must be NODATACOW (i.e. also NODATASUM, no compression)
1114

1215
The limitations come namely from the COW-based design and mapping layer of
1316
blocks that allows the advanced features like relocation and multi-device
@@ -18,12 +21,14 @@ swap.
1821
With active swapfiles, the following whole-filesystem operations will skip
1922
swapfile extents or may fail:
2023

21-
* balance - block groups with swapfile extents are skipped and reported, the
22-
rest will be processed normally
24+
* balance - block groups with an active swapfile extents are skipped and
25+
reported, the rest will be processed normally
2326
* resize grow - unaffected
24-
* resize shrink - works as long as the extents are outside of the shrunk range
25-
* device add - a new device does not interfere with existing swapfile and this
26-
operation will work, though no new swapfile can be activated afterwards
27+
* resize shrink - works as long as the extents of an active swapfile are
28+
outside of the shrunk range
29+
* device add - a new device does not interfere with existing active swapfile
30+
and this operation will work, though no new swapfile can be activated
31+
afterwards
2732
* device delete - if the device has been added as above, it can be also deleted
2833
* device replace - ditto
2934

@@ -54,7 +59,7 @@ Please note that the UUID returned by the *mkswap* utility identifies the swap
5459
"filesystem" and because it's stored in a file, it's not generally visible and
5560
usable as an identifier unlike if it was on a block device.
5661

57-
The file will appear in */proc/swaps*:
62+
Once activated the file will appear in */proc/swaps*:
5863

5964
.. code-block:: none
6065
@@ -73,6 +78,16 @@ priority, not the BTRFS mount options).
7378
7479
/path/swapfile none swap defaults 0 0
7580
81+
From now on the subvolume with the active swapfile cannot be snapshotted until
82+
the swapfile is deactivated again by ``swapoff``. Then the swapfile is a
83+
regular file and the subvolume can be snapshotted again, though this would prevent
84+
another activation any swapfile that has been snapshotted. New swapfiles (not
85+
snapshotted) can be created and activated.
86+
87+
Otherwise, an inactive swapfile does not affect the containing subvolume. Activation
88+
creates a temporary in-memory status and prevents some file operations, but is
89+
not stored permanently.
90+
7691
Hibernation
7792
-----------
7893

0 commit comments

Comments
 (0)