linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Rendering a btrfs filesystem unmountable with the btrfs command
@ 2013-01-15 20:44 hopper
  2013-01-15 22:06 ` hopper
  2013-01-17  8:26 ` Arne Jansen
  0 siblings, 2 replies; 4+ messages in thread
From: hopper @ 2013-01-15 20:44 UTC (permalink / raw)
  To: linux-btrfs

[-- Attachment #1: Type: text/plain, Size: 706 bytes --]

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!

Help!  BTW, I'm not a mailing list subscriber.

Thanks,
-- 
"They who can give up essential liberty to obtain a little temporary
 safety, deserve neither liberty nor safety." -- Benjanmin Franklin
-- Eric Hopper (http://www.omnifarious.org/~hopper) --

[-- Attachment #2: Type: application/pgp-signature, Size: 665 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Rendering a btrfs filesystem unmountable with the btrfs command
  2013-01-15 20:44 Rendering a btrfs filesystem unmountable with the btrfs command hopper
@ 2013-01-15 22:06 ` hopper
  2013-01-16 15:42   ` Eric Hopper
  2013-01-17  8:26 ` Arne Jansen
  1 sibling, 1 reply; 4+ messages in thread
From: hopper @ 2013-01-15 22:06 UTC (permalink / raw)
  To: linux-btrfs

[-- Attachment #1: Type: text/plain, Size: 1259 bytes --]

On Tue, Jan 15, 2013 at 12:44:36PM -0800, hopper@omnifarious.org wrote:
> Help!  BTW, I'm not a mailing list subscriber.

Here is a sample fix that I believe will allow the offending filesystem
to at least be mounted.  It hasn't been tested at all.

----------------------------
diff -ur kernel-3.7.fc17.orig/linux-3.7.2-201.fc17.x86_64/fs/btrfs/qgroup.c kernel-3.7.fc17/linux-3.7.2-201.fc17.x86_64/fs/btrfs/qgroup.c
--- kernel-3.7.fc17.orig/linux-3.7.2-201.fc17.x86_64/fs/btrfs/qgroup.c	2012-12-10 19:30:57.000000000 -0800
+++ kernel-3.7.fc17/linux-3.7.2-201.fc17.x86_64/fs/btrfs/qgroup.c	2013-01-15 14:02:39.643630137 -0800
@@ -379,8 +379,13 @@
 
 		ret = add_relation_rb(fs_info, found_key.objectid,
 				      found_key.offset);
-		if (ret)
+		/* Failing to add a relation because one side or the other
+		 * doesn't exist isn't a fatal error here. */
+		if (ret) {
+			if (ret == -ENOENT)
+				ret = ENOENT;
 			goto out;
+		}
 next2:
 		ret = btrfs_next_item(quota_root, path);
 		if (ret < 0)
----------------------------


-- 
"They who can give up essential liberty to obtain a little temporary
 safety, deserve neither liberty nor safety." -- Benjanmin Franklin
-- Eric Hopper (http://www.omnifarious.org/~hopper) --

[-- Attachment #2: Type: application/pgp-signature, Size: 665 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Rendering a btrfs filesystem unmountable with the btrfs command
  2013-01-15 22:06 ` hopper
@ 2013-01-16 15:42   ` Eric Hopper
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Hopper @ 2013-01-16 15:42 UTC (permalink / raw)
  To: linux-btrfs

[-- Attachment #1: Type: text/plain, Size: 1929 bytes --]

On Tue, Jan 15, 2013 at 02:06:01PM -0800, hopper@omnifarious.org wrote:
> Here is a sample fix that I believe will allow the offending filesystem
> to at least be mounted.  It hasn't been tested at all.

I got this patch into a kernel and tested it. It does indeed allow the
offending filesystem to be mounted.  I'm not convinced it's the best
possible patch.  Perhaps instead the place where the return value of the
function that's being patched is used should be changed instead.

Here is some data showing what the problem is...

# btrfs qgroup show .
0/266 97579008 97579008
0/268 97640448 97640448
1/1 97619968 97619968

# btrfs-debug-tree /dev/sdb3 | fgrep QGROUP_RELATION_KEY
  item 7 key (0/266 BTRFS_QGROUP_RELATION_KEY 1/0) itemoff 3723 itemsize 0
  item 8 key (0/266 BTRFS_QGROUP_RELATION_KEY 1/1) itemoff 3723 itemsize 0
  item 9 key (0/267 BTRFS_QGROUP_RELATION_KEY 1/0) itemoff 3723 itemsize 0
  item 10 key (0/268 BTRFS_QGROUP_RELATION_KEY 1/0) itemoff 3723 itemsize 0
  item 11 key (0/268 BTRFS_QGROUP_RELATION_KEY 1/1) itemoff 3723 itemsize 0
  item 12 key (1/0 BTRFS_QGROUP_RELATION_KEY 0/266) itemoff 3723 itemsize 0
  item 13 key (1/0 BTRFS_QGROUP_RELATION_KEY 0/267) itemoff 3723 itemsize 0
  item 14 key (1/0 BTRFS_QGROUP_RELATION_KEY 0/268) itemoff 3723 itemsize 0
  item 15 key (1/1 BTRFS_QGROUP_RELATION_KEY 0/266) itemoff 3723 itemsize 0
  item 16 key (1/1 BTRFS_QGROUP_RELATION_KEY 0/268) itemoff 3723 itemsize 0

Notice how there are a whole bunch of QGROUP_RELATION_KEY records that
refer to qgroups that no longer exist (1/0 and 0/267).  This is because
a qgroup destroy was done on these qgroups but the corresponding
QGROUP_RELATION_KEY records were not removed.

-- 
"They who can give up essential liberty to obtain a little temporary
 safety, deserve neither liberty nor safety." -- Benjanmin Franklin
-- Eric Hopper (http://www.omnifarious.org/~hopper) --

[-- Attachment #2: Type: application/pgp-signature, Size: 665 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Rendering a btrfs filesystem unmountable with the btrfs command
  2013-01-15 20:44 Rendering a btrfs filesystem unmountable with the btrfs command hopper
  2013-01-15 22:06 ` hopper
@ 2013-01-17  8:26 ` Arne Jansen
  1 sibling, 0 replies; 4+ messages in thread
From: Arne Jansen @ 2013-01-17  8:26 UTC (permalink / raw)
  To: hopper; +Cc: linux-btrfs

Hi Eric,

thanks for reporting this. I sent a small patch series to the list
to fix this.
Sorry I forgot to CC you, will send the patches to you directly again.
It would be great if you could give it some testing.

Thanks,
Arne

On 15.01.2013 21:44, hopper@omnifarious.org wrote:
> 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!
> 
> Help!  BTW, I'm not a mailing list subscriber.
> 
> Thanks,


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-01-17  8:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-15 20:44 Rendering a btrfs filesystem unmountable with the btrfs command hopper
2013-01-15 22:06 ` hopper
2013-01-16 15:42   ` Eric Hopper
2013-01-17  8:26 ` Arne Jansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).