qvm-template-postprocess: call fstrim after removing image file

This is especially important on LVM thin pool, where space after
removing the file needs to be given back to the pool, to be reused for
other volumes (for example this template).
This commit is contained in:
Marek Marczykowski-Górecki 2018-03-02 02:26:26 +01:00
parent 090cccd468
commit 4a9b57f91f
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -214,6 +214,11 @@ def post_install(args):
if not args.keep_source:
shutil.rmtree(args.dir)
# if running as root, tell underlying storage layer about just freed
# data blocks
if os.getuid() == 0:
subprocess.call(['sync', '-f', os.path.dirname(args.dir)])
subprocess.call(['fstrim', os.path.dirname(args.dir)])
return 0