Bug 895727

Summary: btrfs quotas are easy to get into an inconsistent state
Product: [Fedora] Fedora Reporter: Eric Hopper <eric-bugs2>
Component: kernelAssignee: Josef Bacik <josef>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 18CC: gansalmon, itamar, jonathan, josef, kernel-maint, madhu.chinakonda, mmahut, zab
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-09-23 20:28:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
allow mounting of btrfs volumes with inconsistent quota information none

Description Eric Hopper 2013-01-15 21:19:25 UTC
Description of problem:
Using a few commands related to btrfs quotas it's trivial to get btrfs into an inconsistent state

Version-Release number of selected component (if applicable):
Not sure exactly. The kernel shipped with Fedora 18 has the problem, but I'm not sure about kernels after that. I think they all do.

How reproducible:
Every time

Steps to Reproduce:
mkfs.btrfs /dev/sdb
mkdir /tmp/mnt
mount /dev/sdb /tmp/mnt
cd /tmp/mnt
btrfs quota enable .
btrfs subvol create foo
btrfs qgroup create 1/0
btrfs qgroup assign 0/257 1/0
btrfs subvol snapshot foo bar
btrfs qgroup assign 0/258 1/0
cd ..
umount /dev/sdb
mount /dev/sdb /tmp/mnt
# Still mountable!
cd mnt
btrfs qgroup destroy 1/0
cd ..
umount /dev/sdb
mount /dev/sdb /tmp/mnt
# Oops, no longer mountable, even in recovery mode!
  
Actual results:
Unmountable filesystem

Expected results:
A filesystem that I can still mount

Additional info:
http://www.spinics.net/lists/linux-btrfs/index.html#21463

Comment 1 Eric Hopper 2013-01-15 23:28:00 UTC
This will likely need two fixes.

First, according to sensille (aka Arne Jansen, owner of this development tree http://git.kernel.org/?p=linux/kernel/git/arne/linux-btrfs.git;a=summary) on Freenode, inconsistencies in the quota subsystem are not supposed to prevent mounting.

Secondly, btrfs qgroup destroy leaves BTRFS_QGROUP_RELATION_KEY nodes lying around that refer to the destroyed qgroup. This should probably also be fixed.

I have a patch which I think should fix the first problem, and I will attach it to this bug.

Comment 2 Eric Hopper 2013-01-15 23:29:48 UTC
Created attachment 679166 [details]
allow mounting of btrfs volumes with inconsistent quota information

Comment 3 Eric Hopper 2013-01-15 23:30:39 UTC
This is a bug in btrfs, but at least part of it is within the kernel.

Comment 4 Eric Hopper 2013-01-16 06:05:19 UTC
I verified my patch as working, though I'm not sure that it's the best possible patch, it is a patch that works.

Comment 5 Josh Boyer 2013-01-16 14:34:17 UTC
(In reply to comment #4)
> I verified my patch as working, though I'm not sure that it's the best
> possible patch, it is a patch that works.

Did you send this to the upstream developers?

Comment 6 Eric Hopper 2013-01-16 15:22:50 UTC
(In reply to comment #5)
> Did you send this to the upstream developers?

I sent the patch to the mailing list, yes.

Comment 8 Josef Bacik 2013-09-23 20:28:40 UTC
Fixed upstream.