Skip to content

Commit

Permalink
enable discard option for dom0 filesystems by default
Browse files Browse the repository at this point in the history
This may have performance impact on some older SSD, but on the other
hand, without this option it's pretty easy to fill the whole LVM thin
pool even if there is plenty free space in dom0.
Note that this doesn't enable it on LUKS layer, this is still disabled
by default.

Fixes QubesOS/qubes-issues#3226
  • Loading branch information
marmarek authored and fepitre committed Mar 16, 2019
1 parent 3879174 commit 99a1469
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pyanaconda/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,15 @@ def wait_for_all_treads():
task_args=(storage,),
task_kwargs={"mount_only": flags.flags.dirInstall, "callbacks": callbacks_reg}))

# For autopart, actual partition related objects (especially
# blivet.format.FS objects) are created by the above call. And autopart
# does not provide any way to specify default mount options (unlike manual
# partitioning). Because of this, patch it now to add 'discard' option.
if storage.root_device.format.options and 'discard' not in storage.root_device.format.options:
storage.root_device.format.options += ',discard'
else:
storage.root_device.format.options = 'defaults,discard'

early_storage.append(Task("Write early storage", payload.writeStorageEarly))
installation_queue.append(early_storage)

Expand Down
12 changes: 12 additions & 0 deletions pyanaconda/kickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,10 @@ def execute(self, storage, ksdata, instClass):
self.mountpoint = ""
ty = None

if self.mountpoint.startswith('/') and not self.fsopts:
# enable discard for normal filesystems in dom0
self.fsopts = "defaults,discard"

# Sanity check mountpoint
if self.mountpoint != "" and self.mountpoint[0] != '/':
raise KickstartParseError(lineno=self.lineno,
Expand Down Expand Up @@ -1571,6 +1575,10 @@ def execute(self, storage, ksdata, instClass):
else:
ty = storage.default_fstype

if self.mountpoint.startswith('/') and not self.fsopts:
# enable discard for normal filesystems in dom0
self.fsopts = "defaults,discard"

if not size and self.size:
try:
size = Size("%d MiB" % self.size)
Expand Down Expand Up @@ -1834,6 +1842,10 @@ def execute(self, storage, ksdata, instClass):
else:
ty = storage.default_fstype

if self.mountpoint.startswith('/') and not self.fsopts:
# enable discard for normal filesystems in dom0
self.fsopts = "defaults,discard"

# Sanity check mountpoint
if self.mountpoint != "" and self.mountpoint[0] != '/':
raise KickstartParseError(lineno=self.lineno,
Expand Down

0 comments on commit 99a1469

Please sign in to comment.