Bug 987136 - RFE: add 'discard' swap option support for /etc/fstab
RFE: add 'discard' swap option support for /etc/fstab
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: systemd (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity medium
: ---
: ---
Assigned To: Jan Synacek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-22 15:11 EDT by Carl Roth
Modified: 2014-10-17 13:10 EDT (History)
10 users (show)

See Also:
Fixed In Version: systemd-216-4.fc21
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-10-17 13:10:58 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Carl Roth 2013-07-22 15:11:00 EDT
Description of problem:

systemd-fstab-generator ignores the 'discard' mount option in /etc/fstab for swap partitions.  Additionally, there is no syntax in the systemd.swap unit files to specify this feature.

Version-Release number of selected component (if applicable):

systemd-201-2.fc18.7.x86_64

How reproducible:

always

Steps to Reproduce:
1. 
2. 
3.

Actual results:


Expected results:


Additional info:

It's an open question how to actually tell if a swap partition is using 'discard' (not systemd-specific).  It's definitely the case that the option is not reflected in the unit file.
Comment 1 Carl Roth 2013-07-22 16:37:22 EDT
If the dmesg results are to be believed, I think this is the difference between 'discard' and 'no discard' (see the 'D' flag):

# swapon /dev/disk/by-uuid/d8e4b4bf-9f1e-446a-a5b0-0325c4ef7d73
# dmesg | grep swap | tail -1
[773331.002898] Adding 8388604k swap on /dev/mapper/M4_CT256_AF15-scruffy_f18_swap.  Priority:-1 extents:1 across:8388604k SS

# swapon --discard /dev/disk/by-uuid/d8e4b4bf-9f1e-446a-a5b0-0325c4ef7d73
# dmesg | grep swap | tail -1
[773346.691092] Adding 8388604k swap on /dev/mapper/M4_CT256_AF15-scruffy_f18_swap.  Priority:-1 extents:1 across:8388604k SSD

More importantly, my /etc/fstab lists that partition with the 'discard' option, and at boot time the option is ignored (presumably because of systemd):
# dmesg | grep swap | head -1
[    2.527089] Adding 8388604k swap on /dev/mapper/M4_CT256_AF15-scruffy_f18_swap.  Priority:-1 extents:1 across:8388604k SS

So this is more of a general systemd/bootup problem.
Comment 2 Carl Roth 2013-07-22 16:39:04 EDT
As per

http://cgit.freedesktop.org/systemd/systemd/tree/src/core/swap.c

this is not currently a supported feature in systemd.
Comment 3 Carl Roth 2013-07-22 16:46:47 EDT
(In reply to Carl Roth from comment #1)
> If the dmesg results are to be believed, I think this is the difference
> between 'discard' and 'no discard' (see the 'D' flag):

Found it at

http://lxr.free-electrons.com/source/mm/swapfile.c?v=3.9#L2136
Comment 4 Lennart Poettering 2014-06-19 14:56:08 EDT
Does "swapon -a" read this from fstab? We should probably support the same syntax.
Comment 5 Carl Roth 2014-06-19 15:43:46 EDT
(In reply to Lennart Poettering from comment #4)
> Does "swapon -a" read this from fstab? We should probably support the same
> syntax.

Yes, see

https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/sys-utils/swapon.c#n640

Note You need to log in before you can comment on or make changes to this bug.