Skip to contentSkip to conversation

3.17.0 mixed-bg enospc but both btrfs fi show and btrfs fi df say there's plenty

Bug Duncan 1 participant 2 messages Oct 7, 2014 Btrfs file system

lore
Share & tools
lore

Duncan

author
#0 lore raw

This is with my small 256 MiB btrfs mixed-bg dup-mode /boot, or actually, with its backup (same size partition, different device). Kernel 3.17.0, btrfs-progs 3.16.1 (both actually from git), gentoo.

It was time to renew my backups so I did a mkfs.btrfs on the backup to start fresh:

mkfs.btrfs -d dup -m dup -L bt0238gcn0+35l0 -O extref,skinny-metadata,no- holes -f /dev/sdb3

Of course with the 256 MiB size, mkfs.btrfs naturally added mixed-bg to the features as well.

I then did a balance to remove the single-mode mkfs-time artifacts.

Mount-options on both the working and backup filesystems are identical:

nodev,nosuid,noauto,compress=lzo,autodefrag

Mounting both filesystems, I then tried to use mc to copy everything from the working filesystem to the mkfs-fresh backup. That failed with enospc. However, in the past, repeated copy attempts, using "if size differs" when mc pops up the duplicate filename warnings, have eventually copied everything over just fine.

This time, while repeated copy attempts did result in most files copying, the (dracut generated) cpio archive that gets appended to my kernels as the initramfs failed to copy over.

However, the source filesystem is an identically sized btrfs with the same mount options (and I think the same features enabled, tho I'm not sure), and the files fit there with "plenty" (for the fs size) of room to spare!

And both btrfs filesystem show and btrfs filesystem df say there's lots of room left.

Destination filesystem (without the 14905 KiB cpio file, #>> indicates the prompt):

#>>btrfs filesystem show /bk/bt
Label: 'bt0238gcn0+35l0' uuid: 4d310294-c899-4dcc-be81-580d477060e9
Total devices 1 FS bytes used 30.59MiB
devid 1 size 256.00MiB used 132.00MiB path /dev/sdb3

Btrfs v3.16.1

#>>btrfs filesystem df /bk/bt
System, DUP: total=16.00MiB, used=4.00KiB
Data+Metadata, DUP: total=50.00MiB, used=30.59MiB
GlobalReserve, single: total=4.00MiB, used=0.00

Source filesystem (including the 14905 KiB cpio file):

c#>>btrfs filesystem show /bt
Label: 'bt0238gcn1+35l0' uuid: d6539322-0834-4eeb-928d-a13eb32dcbb2
Total devices 1 FS bytes used 44.48MiB
devid 1 size 256.00MiB used 159.00MiB path /dev/sda3

Btrfs v3.16.1

#>>btrfs filesystem df /bt
System, DUP: total=15.50MiB, used=4.00KiB
Data+Metadata, DUP: total=64.00MiB, used=44.48MiB
GlobalReserve, single: total=4.00MiB, used=0.00

On the destination, 50 MiB data+metadata allocated - 30.59 MiB used = 19.41 MiB free in the chunk(s). So an approximately 14.6 MiB file shouldn't even require additional chunk allocation. But as can be seen from the show output, even if it did, there's plenty of unallocated space left to allocate new chunks if need be.

So why am I getting enospc?

FWIW, if I try to cp it instead of using mc, 14208 KiB copies before I get the enospc.

At that point, with the partially copied (14208/14905 KiB) file, this is what I get:

#>>btrfs filesystem show /bk/bt
Label: 'bt0238gcn0+35l0' uuid: 4d310294-c899-4dcc-be81-580d477060e9
Total devices 1 FS bytes used 43.59MiB
devid 1 size 256.00MiB used 132.00MiB path /dev/sdb3

Btrfs v3.16.1

#>>btrfs filesystem df /bk/bt
System, DUP: total=16.00MiB, used=4.00KiB
Data+Metadata, DUP: total=50.00MiB, used=43.58MiB
GlobalReserve, single: total=4.00MiB, used=0.00

So no further chunk allocation, data+metadata usage increased from 30.59 MiB to 43.58 MiB, almost exactly 13 MiB. The file is 14905 MiB and 14208 copied but it couldn't handle that last ~700 KiB, even tho data+metadata still shows nearly 6.5 MiB still unused in the existing chunk and there's still 124 MiB unallocated, nearly half the 256 MiB filesystem size! That can be halved due to dup-mode for ~62 MiB of usable space, barring bugs like this one.

And it all fits on the basically identical source btrfs, with 97 MiB still unallocated to chunks and 19+ MiB free in the data+metadata chunks. So why is the new filesystem prematurely enospcing me?

I can btrfs image the filesystems if necessary, and/or even dd-image them and send the whole thing, tho it /does/ have kernel config and system- maps, etc as well as my grub2 config, so while it's not too private it's probably not something I want on a public list. Tho I'd guess it to be a reasonably generic issue to duplicate, given the information above.

Signature · 3 lines
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman
author
#1 lore raw

Duncan posted on Tue, 07 Oct 2014 13:41:49 +0000 as excerpted:

Quoted 2 lines

FWIW, if I try to cp it instead of using mc, 14208 KiB copies before I get the enospc.

Interesting workaround I just found:

1) cp the file and let the cp abort.
2) delete the partial copy
3) mc-copy the file.
4) watch the full 14905 KiB file mc-copy over just fine.

But:

5) delete the full copy
6) try mc-copying the thing again
7) same issue as before

And:

8) try using cp for the partial copy again
9) delete the partial copy
10) cp the file again
11) still a partial copy, but 14464 KiB instead of 14208 KiB copied

Further:

12) delete that (14464 KiB) partial copy
13) cp the file yet again
14) full file copies over (diff-identical)

With the full file copied over now, btrfs filesystem show gives the same results, but the btrfs filesystem df data+metadata line looks like this:

Data+Metadata, DUP: total=50.00MiB, used=43.94MiB

Given that without the file it was used=30.59 MiB, the space used by the 14.56 MiB file is 13.35 MiB, presumably due to lzo-compression.

But why is it working under some conditions and failing with enospc under others?

Is this something those compression-related patches I've see floating around should fix? I guess not all of them made it into 3.17 if so. Hopefully 3.18. Or is this a different bug without a patch floating around yet?

Signature · 3 lines
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman