If you create a seed device with btrfstune and then try to add a small (32MB)
device to it, the kernel will oops and the attempt to add the device will
fail.

I have attached a transcript of the shell session that demonstrates this.
(This was generated by piping UML to tee and then cleaning up the file. I
removed some control characters, but the backtrace is still intact.)

This bug os triggered by a 32MB device, but not a 64MB one.

This bug is still present with the rc6 kernel.

Note that, in earlier kernels, the attempt to remount read-write would
succeed, but process attempting to access the filesystem would hang forever,
resisting even SIGKILL.
raid6: int32x1    695 MB/s
raid6: int32x2    678 MB/s
raid6: int32x4    689 MB/s
raid6: int32x8    413 MB/s
raid6: using algorithm int32x1 (695 MB/s)
raid6: using intx1 recovery algorithm
xor: measuring software checksum speed
   8regs     :  4674.000 MB/sec
   8regs_prefetch:  4226.000 MB/sec
   32regs    :  2824.400 MB/sec
   32regs_prefetch:  4100.800 MB/sec
xor: using function: 8regs (4674.000 MB/sec)
bio: create slab <bio-1> at 1
Btrfs loaded
btrfs: device fsid 05e9ab31-1ae3-4195-a5dd-7ce0943236db devid 1 transid 451 
/dev/ubda
btrfs: disk space caching is enabled
root@(none):~# truncate st -s 64M
root@(none):~# mkfs.btrfs st

WARNING! - Btrfs v0.20-rc1 IS EXPERIMENTAL
WARNING! - see http://btrfs.wiki.kernel.org before using

SMALL VOLUME: forcing mixed metadata/data groups
Created a data/metadata chunk of size 6684672
fs created label (null) on st
        nodesize 4096 leafsize 4096 sectorsize 4096 size 64.00MB
Btrfs v0.20-rc1
root@(none):~# btrfs -S 1 st
root@(none):~# losetup -fv st
Loop device is /dev/loop0
root@(none):~# mount /dev/loop0 /mnt
EXT4-fs (loop0): VFS: Can't find ext4 filesystem
EXT4-fs (loop0): VFS: Can't find ext4 filesystem
EXT4-fs (loop0): VFS: Can't find ext4 filesystem
btrfs: device fsid 63184a6c-3df9-47b4-bf7a-5f68ebb24761 devid 1 transid 5 
/dev/loop0
mount: block device /dev/loop0 is write-protected, mounting read-only
EXT4-fs (loop0): VFS: Can't find ext4 filesystem
EXT4-fs (loop0): VFS: Can't find ext4 filesystem
EXT4-fs (loop0): VFS: Can't find ext4 filesystem
btrfs: device fsid 63184a6c-3df9-47b4-bf7a-5f68ebb24761 devid 1 transid 5 
/dev/loop0
btrfs: disk space caching is enabled
root@(none):~# truncate st0 -s 32M
root@(none):~# losetup-fv st0
Loop device is /dev/loop1
root@(none):~# btrfs device add /dev/loop1 /mnt
SMALL VOLUME: forcing mixed metadata/data groups
btrfs: relocating block group 0 flags 2
------------[ cut here ]------------
WARNING: CPU: 0 PID: 343 at fs/btrfs/volumes.c:2554 
btrfs_init_new_device+0xc71/0xd4b [btrfs]()
Modules linked in: btrfs lzo_compress zlib_deflate xor raid6_pq libcrc32c
CPU: 0 PID: 343 Comm: btrfs Not tainted 3.12.0-rc5 #1
0ff57c14 08076736 082789fb 00000000 00000157 111e068a 000009fa 1119de3b 
       1119de3b 00000000 0ff48c00 003fffff 00000000 1049f738 1119de3b 00000009 
       00000000 00000100 00000000 000000e4 00000000 10505601 0ff82c00 00000001 
0ff57c18:  [<08076736>] warn_slowpath_common+0x78/0x99
0ff57c30:  [<1119de3b>] btrfs_init_new_device+0xc71/0xd4b [btrfs]
0ff57c34:  [<1119de3b>] btrfs_init_new_device+0xc71/0xd4b [btrfs]
0ff57c4c:  [<1119de3b>] btrfs_init_new_device+0xc71/0xd4b [btrfs]
0ff57cec:  [<111a43d6>] btrfs_ioctl+0x6cf/0x2a8c [btrfs]
0ff57d0c:  [<08095294>] enqueue_task_fair+0xe3/0x195
0ff57d28:  [<08073f2e>] os_set_thread_area+0x25/0x36
0ff57d3c:  [<08073096>] do_set_thread_area+0x1a/0x3e
0ff57d54:  [<080731aa>] arch_switch_tls+0x85/0xb2
0ff57d70:  [<08071e52>] arch_switch_to+0xf/0x40
0ff57d78:  [<080924fa>] finish_task_switch.isra.60+0x1b/0x54
0ff57db0:  [<0822989c>] schedule+0x57/0x59
0ff57dbc:  [<0822851f>] schedule_timeout+0x17/0xfd
0ff57ddc:  [<08092325>] __wake_up+0x29/0x31
0ff57dec:  [<111a3d07>] btrfs_ioctl+0x0/0x2a8c [btrfs]
0ff57dfc:  [<080e8245>] vfs_ioctl+0x26/0x32
0ff57e00:  [<0822942b>] wait_for_common+0xfc/0x106
0ff57e04:  [<080e8245>] vfs_ioctl+0x26/0x32
0ff57e18:  [<080e8dfb>] do_vfs_ioctl+0x526/0x603
0ff57e34:  [<081ad651>] loop_switch.isra.22+0x7e/0x8f
0ff57e54:  [<080ee72b>] iput+0x5d/0x113
0ff57e64:  [<081adaaa>] lo_release+0x49/0x59
0ff57e74:  [<0810222e>] __blkdev_put+0xfe/0x116
0ff57e88:  [<080e8f21>] SyS_ioctl+0x49/0x68
0ff57eb4:  [<08060c9a>] handle_syscall+0x6d/0x7f
0ff57ef4:  [<08070a75>] userspace+0x3c9/0x49c
0ff57f88:  [<08060e92>] do_op_one_page+0xfb/0x17f
0ff57f9c:  [<08073f2e>] os_set_thread_area+0x25/0x36
0ff57fb0:  [<08073096>] do_set_thread_area+0x1a/0x3e
0ff57fbc:  [<08089500>] __task_pid_nr_ns+0x51/0x5b
0ff57fc8:  [<080731aa>] arch_switch_tls+0x85/0xb2
0ff57ff0:  [<0805e648>] fork_handler+0x61/0x65

---[ end trace 729c0d24bd03140c ]---
BTRFS error (device loop0) in btrfs_init_new_device:2124: errno=-28 No space 
left (Failed to relocate sys chunks after device initialization. This can be 
fixed using the "btrfs balance" command.)
BTRFS info (device loop0): forced readonly
ERROR: error adding the device '/dev/loop1' - Read-only file system
root@(none):~# mount -o remount,rw /mnt
btrfs: disk space caching is enabled
BTRFS error (device loop0): Remounting read-write after error is not allowed

mount: /mnt not mounted or bad option
root@(none):~# uname -a
Linux (none) 3.12.0-rc5 #1 Sun Oct 13 20:08:45 CDT 2013 i686 GNU/Linux
root@(none):~# btrfs version
Btrfs v0.20-rc1

Reply via email to