Infinite busy-loop trying to cull when cache space is short

Bug #1810372 reported by Daniel Axtens on 2019-01-03
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cachefilesd (Ubuntu)
Medium
Daniel Axtens
Trusty
Medium
Daniel Axtens
Xenial
Medium
Daniel Axtens

Bug Description

[Impact]

A user reports that cachefilesd will spin at 100% of a cpu when started on a filesystem where the free space is less than the bcull threshold and culling the cache is insufficient to free up space.

Investigation shows that this is because cachefilesd detects that culling is required, tries to cull, and does not realise that culling cannot free up enough space, so just keeps retrying.

[Test Case]

Create a trusty or xenial VM, and install cachefilesd. Using either a real disk or loopback image, create a ext4 filesystem, and edit fstab to mount it at /var/cache/fscache, e.g.:
$ sudo dd if=/dev/zero of=/cache.img bs=1024m count=1024
$ sudo losetup -f /cache.img
$ sudo losetup -a
$ sudo mkfs.ext4 /dev/loop0 (note, adjust loop0 if needed)

edit fstab e.g.:
$ grep fscache /etc/fstab
/cache.img /var/cache/fscache ext4 defaults,loop,user_xattr 0 0

It's important to include the 'user_xattr' option as cachefilesd requires that.

stop the cachefilesd service and move the fscache contents:
$ sudo service cachefilesd stop
$ cd /var/cache
$ sudo mkdir fscache2
$ sudo mv -vf fscache/* fscache2/
$ sudo mount fscache
$ sudo mv -vf fscache2/* fscache/
$ sudo rmdir fscache2

create a file to fill up the fscache space, e.g.:
$ sudo dd if=/dev/zero of=/var/cache/fscache/largefile.txt bs=1024k count=850
$ df /var/cache/fscache
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/loop0 999320 922896 7612 100% /var/cache/fscache

edit /etc/default/cachefilesd to uncomment 'RUN=yes', e.g.:
$ grep RUN /etc/default/cachefilesd
RUN=yes

reboot, or just restart cachefilesd service
$ sudo service cachefilesd start

check top
$ top

cachefilesd should be spinning, using 100% (or as much as it can) cpu time.

[Regression Potential]

The patch makes changes to how cachefilesd detects if it should sleep
or cull, so regressions would be in the area of cachefilesd spinning
instead of sleeping (which is what it does now) or sleeping instead
of culling.

However the patch is small and easily understood and backports with minimal effort.

[Other Info]

This is fixed upstream in 0.10.6:

* Wed Feb 3 2016 David Howells <email address hidden> 0.10.6-1
...
- Suspend culling when cache space is short and cache objects are pinned.

The particular patch is ce353f5b6b5b ("cachefilesd can spin when disk space is short.")

Since bionic has version 0.10.10-0.1, this fix is needed only for xenial and trusty.

Daniel Axtens (daxtens) wrote :

It turns out the package uses the cdbs system rather than quilt, so providing a debdiff is a bit tricky. Here's the patch that I applied, the result is at https://launchpad.net/~daxtens/+archive/ubuntu/builder/+build/16226405 and it works on my test system, and I am asking the original reporter to verify it as well.

The attachment "0001-cachefilesd-can-spin-when-disk-space-is-short.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Daniel Axtens (daxtens) wrote :

The full .diff.tar.gz is attached.

Dan Streetman (ddstreet) on 2019-01-08
tags: added: sts sts-sponsor sts-sponsor-ddstreet
Dan Streetman (ddstreet) on 2019-01-11
description: updated
description: updated
Dan Streetman (ddstreet) on 2019-01-11
Changed in cachefilesd (Ubuntu Trusty):
status: New → In Progress
Changed in cachefilesd (Ubuntu Xenial):
status: New → In Progress
Changed in cachefilesd (Ubuntu Trusty):
assignee: nobody → Daniel Axtens (daxtens)
Changed in cachefilesd (Ubuntu Xenial):
assignee: nobody → Daniel Axtens (daxtens)
Changed in cachefilesd (Ubuntu Trusty):
importance: Undecided → Medium
Changed in cachefilesd (Ubuntu Xenial):
importance: Undecided → Medium
Changed in cachefilesd (Ubuntu):
importance: Undecided → Medium
status: Confirmed → Fix Released
description: updated
Dan Streetman (ddstreet) on 2019-01-11
description: updated

Hello Daniel, or anyone else affected,

Accepted cachefilesd into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/cachefilesd/0.10.5-1ubuntu0.16.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in cachefilesd (Ubuntu Xenial):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-xenial
Changed in cachefilesd (Ubuntu Trusty):
status: In Progress → Fix Committed
tags: added: verification-needed-trusty
Brian Murray (brian-murray) wrote :

Hello Daniel, or anyone else affected,

Accepted cachefilesd into trusty-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/cachefilesd/0.10.5-1ubuntu0.14.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-trusty to verification-done-trusty. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-trusty. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Daniel Axtens (daxtens) on 2019-01-17
tags: added: verification-done-xenial
removed: verification-needed-xenial
Daniel Axtens (daxtens) wrote :

User has verified the Xenial version. I have verified the Trusty version.

Regards,
Daniel

tags: added: verification-done-trusty
removed: verification-needed-trusty
Dan Streetman (ddstreet) on 2019-01-17
tags: added: verification-done
removed: verification-needed
tags: removed: sts-sponsor sts-sponsor-ddstreet
Eric Desrochers (slashd) wrote :

Hi Daniel,

As discussed on irc, can you be a little bit more specific about the test you did for both releases (X/T), the package version used, the outcome, ... I'm sure you did the necessary testing but the SRU team will definitely appreciate hearing about it in order to have more information to take the right decision when they will be ready to release the package into -updates.

Thanks in advance !

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers