New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 776417 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Nov 2017
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 3
Type: Feature



Sign in to add a comment

Enable fstrim for chroots

Project Member Reported by bmgordon@chromium.org, Oct 19 2017

Issue description

As space in the chroot is used, chroot.img grows, but the used space isn't released back to the OS when files are deleted inside the chroot.  This makes the sparse image progressively less sparse over time.

We should run fstrim on the chroot mountpoint to garbage collect the unused space.  cros_sdk could do this automatically, but it can take a few seconds, so we should only do this when it would help.
 
A quick/lazy benchmark suggests that adding the discard mount option slows down builds inside the chroot by about 10%, so figuring out how to do a periodic fstrim instead is likely to be better.
Project Member

Comment 2 by bugdroid1@chromium.org, Nov 18 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/chromite/+/e3d5bd1ef1a99d5be8fc452f6c617efc33806058

commit e3d5bd1ef1a99d5be8fc452f6c617efc33806058
Author: Benjamin Gordon <bmgordon@chromium.org>
Date: Sat Nov 18 04:18:50 2017

cros_sdk: Run fstrim to keep chroot.img sparse

chroot.img is a sparse image, but it gradually becomes allocated as
space is used inside the chroot.  The filesystem doesn't garbage collect
the freed space as files are deleted, so chroot.img eventually uses
much more space than the chroot contents need.

Call fstrim in cros_sdk after mounting the chroot to recover the unused
space.  fstrim takes some time to run, so only call it if it's likely to
free enough space to be worthwhile (arbitrarily defined as 20GB).

BUG= chromium:776417 
TEST=Deleted large files inside chroot and verified that space was
     recovered after running cros_sdk.

Change-Id: Id84b2dfac7ef03a5eab96f59726ea5b2b17b227e
Reviewed-on: https://chromium-review.googlesource.com/776003
Commit-Ready: Benjamin Gordon <bmgordon@chromium.org>
Tested-by: Benjamin Gordon <bmgordon@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>

[modify] https://crrev.com/e3d5bd1ef1a99d5be8fc452f6c617efc33806058/scripts/cros_sdk.py

Status: Fixed (was: Assigned)

Sign in to add a comment