hopper@omnifarious.org
2013-Jan-15 20:44 UTC
Rendering a btrfs filesystem unmountable with the btrfs command
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) --
hopper@omnifarious.org
2013-Jan-15 22:06 UTC
Re: Rendering a btrfs filesystem unmountable with the btrfs command
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) --
Eric Hopper
2013-Jan-16 15:42 UTC
Re: Rendering a btrfs filesystem unmountable with the btrfs command
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) --
Arne Jansen
2013-Jan-17 08:26 UTC
Re: Rendering a btrfs filesystem unmountable with the btrfs command
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,-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html