Skip to contentSkip to conversation

Unable to remove read-only seeding device from a filesystem.

DISCUSSION Jan Kouba 1 participant 1 message Apr 9, 2014 Btrfs file system

lore
Share & tools
lore

Jan Kouba

author
#0 lore raw

When running this script:

dd if=/dev/zero of=seed-disk.img bs=1M seek=1k count=0 dd if=/dev/zero of=test-disk.img bs=1M seek=1k count=0

# Make image of seed device
mkfs.btrfs seed-disk.img
seed_dev=losetup -f --show seed-disk.img
mount $seed_dev /mnt/tmp
touch /mnt/tmp/a
umount /mnt/tmp
losetup -d $seed_dev
btrfstune -S 1 seed-disk.img

# Make read-only seed device
seed_dev=losetup -f -r --show seed-disk.img

test_dev=losetup -f --show test-disk.img

mount $seed_dev /mnt/tmp
btrfs dev add $test_dev /mnt/tmp
mount -o remount,rw /mnt/tmp

# This fails
btrfs dev delete $seed_dev /mnt/tmp

# cleanup
umount /mnt/tmp
losetup -d $seed_dev
losetup -d $test_dev

rm seed-disk.img
rm test-disk.img

the command
"btrfs dev delete $seed_dev /mnt/tmp" fails with
"ERROR: error removing the device '/dev/loop0' - Permission denied" message.

If /dev/loop0 is not read-only everything works.

I tested this on ubuntu 13.10, 14.04 with stock kernel and btrfs-progs and on ubuntu 14.04 with latest PPA kernel (3.14.0-031400-generic) and v3.14 btrfs- progs.

Is this behaviour expected or is it a bug?

I thougt that btrfs never changes seeding devices, so I don't understand, why it needs to be writeable in order to remove it from a filesystem.

Jan Kouba