Skip to contentSkip to conversation

btrfs defragment: ioctl failed, ret -1 errno 28

DISCUSSION Tomasz Chmielewski 2 participants 2 messages Oct 18, 2011 Btrfs file system

lore
Share & tools
lore
#0 lore raw

I'm trying to defragment a 280 GB file when running 3.1.0-rc9 kernel:

# filefrag /mnt/btrfs/images/srv1-backup.qcow2
/mnt/btrfs/images/srv1-backup.qcow2: 1139699 extents found
# btrfs filesystem defragment /mnt/btrfs/images/srv1-backup.qcow2
ioctl failed on /mnt/btrfs/images/srv1-backup.qcow2 ret -1 errno 28
total 1 failures

Some files fail to defragment like this; some are defragmented correctly.

Why does it fail?

Signature · 2 lines
Tomasz Chmielewski
http://wpkg.org
#1 lore raw
Quoted 6 lines · Tomasz Chmielewski

I'm trying to defragment a 280 GB file when running 3.1.0-rc9 kernel:

# filefrag /mnt/btrfs/images/srv1-backup.qcow2
/mnt/btrfs/images/srv1-backup.qcow2: 1139699 extents found
Quoted 9 lines
# btrfs filesystem defragment /mnt/btrfs/images/srv1-backup.qcow2
ioctl failed on /mnt/btrfs/images/srv1-backup.qcow2 ret -1 errno 28
total 1 failures

Some files fail to defragment like this; some are defragmented correctly.

Why does it fail?

Error 28 is ENOSPC (error, no space).

Since btrfs will be trying to COW the file, it is looking for at least 280 GB of free space. Also, I've run into situations where btrfs seemed to need way more free space to complete an operation than appeared necessary on the surface.

The btrfs defragment command has some capabilities to defragment just segments of a file at a time. But you may want to test that capability on some less important files first.