mkfs.btrfs error checking mount status of loop device backing_file
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
btrfs-tools (Ubuntu) |
Fix Released
|
Medium
|
Unassigned | ||
Trusty |
Fix Released
|
Medium
|
Ryan Harper | ||
Xenial |
Fix Released
|
Medium
|
Unassigned |
Bug Description
SRU Template
[Impact]
* Users may be unable to successfully create a btrfs filesystem on
block devices when a loop device is mounted and the backing file
no longer exists. This typically happens in the precense of
overlayroot but may be encountered in other situations.
This affects the btrfs-tools package prior to the 3.13 release.
* Backporting the fix from the upstream repository is required to
allow Trusty MAAS/Cloud images which use overlayrootfs to create
btrfs filesystems in the presence of a loopdevice with a missing
backing file.
* All patches applied are already accepted upstream. Xenial, Artful,
and Bionic are not affected.
[Test Case]
* On a Trusty 14.04 system with a secondary disk (vdb)
- apt-get install btrfs-tools
- truncate -s 1G testloop.img
- losetup /dev/loop0 testloop.img
- mkfs.ext4 /dev/loop0
- mount /dev/loop0 /mnt
- rm testloop.img
- mkfs.btrfs --force /dev/vdb
PASS if mkfs.btrfs returns 0 and /dev/vdb has a btrfs filesystem
FAIL if mkfs.btrfs returns non-zero and /dev/vdb does not have a
btrfs filesystem. mkfs.btrfs returns the error message:
Error: error checking /dev/vdb mount status
[Regression Potential]
* mkfs.btrfs fails to detect that the target device is already mounted
and an existing btrfs filesystem is destroyed.
[Original Description]
# lsb_release -rd
Description: Ubuntu 14.04.5 LTS
Release: 14.04
# apt-cache policy btrfs-tools
btrfs-tools:
Installed: 3.12-1ubuntu0.1
Candidate: 3.12-1ubuntu0.1
Version table:
*** 3.12-1ubuntu0.1 0
500 http://
100 /var/lib/
3.12-1 0
500 http://
# mkfs.btrfs --force /dev/vdd succeeds
# # mkfs.btrfs --force /dev/vdd
Error: error checking /dev/vdd mount status
# strace -f mkfs.btrfs --force /dev/vdd
<snip>
stat("/dev/loop0", {st_mode=
lstat("/dev", {st_mode=
lstat("/dev/loop0", {st_mode=
open("/
fstat(5, {st_mode=
mmap(NULL, 4096, PROT_READ|
read(5, "/root.tmp.img (deleted)\n", 4096) = 24
close(5) = 0
munmap(
lstat("/dev", {st_mode=
lstat("/dev/vdd", {st_mode=
lstat("
close(4) = 0
munmap(
close(3) = 0
write(2, "Error: error checking /dev/vdd m"..., 44Error: error checking /dev/vdd mount status
) = 44
exit_group(1) = ?
+++ exited with 1 +++
It appears that mkfs.btrfs doesn't like the loop device, /dev/loop0 which has a deleted backing file.
root@ubuntu:~# cat /sys/block/
/root.tmp.img (deleted)
root@ubuntu:~# ls -al /root.tmp.img
ls: cannot access /root.tmp.img: No such file or directory
ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: btrfs-tools 3.12-1ubuntu0.1
ProcVersionSign
Uname: Linux 3.13.0-135-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.27
Architecture: amd64
Date: Wed Nov 29 02:58:04 2017
ProcEnviron:
TERM=vt102
PATH=(custom, no user)
LANG=en_US.UTF-8
SHELL=/bin/bash
SourcePackage: btrfs-tools
UpgradeStatus: No upgrade log present (probably fresh install)
Changed in btrfs-tools (Ubuntu): | |
importance: | Undecided → Medium |
description: | updated |
tags: |
added: verification-done removed: verification-needed |
Cherry pick upstream commit which resolves dealing with loopfiles when doing mount checks.
https:/ /git.kernel. org/pub/ scm/linux/ kernel/ git/kdave/ btrfs-progs. git/commit/ ?id=d06b30feb9c b99e3684b570915 9ca59cf811f517
I've built a deb from this and tested that this works when a loopdevice is mounted.