openzfs / zfs

OpenZFS on Linux and FreeBSD
https://openzfs.github.io/openzfs-docs
Other
10.47k stars 1.74k forks source link

Inconsistent zpool create error messages for: already-imported pool, mounted ext4, unmounted ext4, and no warning or failure for exported pool (only(?) when backed by zvol); doesn't recognise whole-disk vdevs ("unknown filesystem") #13171

Open nabijaczleweli opened 2 years ago

nabijaczleweli commented 2 years ago

System information

Type Version/Name
Distribution Name Debian
Distribution Version Bullseye
Kernel Version Linux tarta 5.10.0-11-amd64 #1 SMP Debian 5.10.92-1 (2022-01-18) x86_64 Linux
Architecture amd64
OpenZFS Version 2.1.2-1.1

Vaguely similar to #10108

Describe the problem you're observing

These are consistent across zvol and SCSI backdevs: whole disk with existing, imported, pool whole disk with mounted ext4 whole disk with ext4 image
outcome fails; in use by "unknown filesystem" fails; in use by "ext4" fails; -fable: contains "ext4"
expected? yes; no yes yes
They diverge here: whole disk with exported (undestroyed!) pool likewise
where SCSI zvol
outcome fails; part of exported pool SUCCEEDS
expected? yes No!

So, in reality, this is two issues, I guess:

  1. zpool create will eat your pool and not even warn you on zvols (possibly (if unlikely) somewhere else too, but dunno)
  2. it doesn't understand how zfs wholedisk looks so it's "unknown filesystem", which, well, "suboptimal" comes to mind

Describe how to reproduce the problem

For normal SCSI vdevs:

# zfs create -sV 400G tarta-zoot/test-zpool-create
# zfs create -sV 400G tarta-zoot/test-mkfs.ext4
# zfs create -sV 400G tarta-zoot/test-zpool-create-exported
# zfs create -sV 400G tarta-zoot/test-mkfs.ext4-exported

# tgt-setup-lun -d /dev/zvol/tarta-zoot/test-zpool-create -n tarta-zoot.test-zpool-create
# tgt-setup-lun -d /dev/zvol/tarta-zoot/test-mkfs.ext4 -n tarta-zoot.test-mkfs.ext4
# tgt-setup-lun -d /dev/zvol/tarta-zoot/test-zpool-create-exported -n tarta-zoot.test-zpool-create-exported
# tgt-setup-lun -d /dev/zvol/tarta-zoot/test-mkfs.ext4-exported -n tarta-zoot.test-mkfs.ext4-exported

# iscsiadm --mode node --targetname  iqn.2001-04.com.tarta-tarta-zoot.test-zpool-create  --portal tarta --login
# iscsiadm --mode node --targetname  iqn.2001-04.com.tarta-tarta-zoot.test-mkfs.ext4  --portal tarta --login
# iscsiadm --mode node --targetname  iqn.2001-04.com.tarta-tarta-zoot.test-zpool-create-exported  --portal tarta --login
# iscsiadm --mode node --targetname  iqn.2001-04.com.tarta-tarta-zoot.test-mkfs.ext4-exported  --portal tarta --login

# zpool create zpool-create scsi-360000000000000000e00000000010001
# zpool create zpool-create scsi-360000000000000000e00000000010001
/dev/disk/by-id/scsi-360000000000000000e00000000010001 is in use and contains a unknown filesystem.

# mkfs.ext4 /dev/disk/by-id/scsi-360000000000000000e00000000020001
mke2fs 1.46.2 (28-Feb-2021)
Creating filesystem with 104857600 4k blocks and 26214400 inodes
Filesystem UUID: 3c76bf3f-e743-48c7-a95c-81cc8739d44a
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done

# mount /dev/disk/by-id/scsi-360000000000000000e00000000020001 test
# zpool create mkfs.ext4 scsi-360000000000000000e00000000020001
/dev/disk/by-id/scsi-360000000000000000e00000000020001 is in use and contains a ext4 filesystem.

# zpool create zpool-create-exported scsi-360000000000000000e00000000030001
# zpool export zpool-create-exported
# zpool create zpool-create-exported2 scsi-360000000000000000e00000000030001
invalid vdev specification
use '-f' to override the following errors:
/dev/disk/by-id/scsi-360000000000000000e00000000030001-part1 is part of exported pool 'zpool-create-exported'

# mkfs.ext4 /dev/disk/by-id/scsi-360000000000000000e00000000040001
# zpool create mkfs.ext4-exported scsi-360000000000000000e00000000040001
invalid vdev specification
use '-f' to override the following errors:
/dev/disk/by-id/scsi-360000000000000000e00000000040001 contains a filesystem of type 'ext4'

For zvols:

# zfs create -sV 400G tarta-zoot/test-zpool-create
# zfs create -sV 400G tarta-zoot/test-mkfs.ext4
# zfs create -sV 400G tarta-zoot/test-zpool-create-exported
# zfs create -sV 400G tarta-zoot/test-mkfs.ext4-exported

# zpool create zpool-create /dev/zvol/tarta-zoot/test-zpool-create
# zpool create zpool-create /dev/zvol/tarta-zoot/test-zpool-create
/dev/disk/by-id//dev/zvol/tarta-zoot/test-zpool-create is in use and contains a unknown filesystem.

# mkfs.ext4 /dev/zvol/tarta-zoot/test-mkfs.ext4
mke2fs 1.46.2 (28-Feb-2021)
Creating filesystem with 104857600 4k blocks and 26214400 inodes
Filesystem UUID: 3c76bf3f-e743-48c7-a95c-81cc8739d44a
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done

# mount /dev/zvol/tarta-zoot/test-mkfs.ext4 test
# zpool create mkfs.ext4 /dev/zvol/tarta-zoot/test-mkfs.ext4
/dev/zvol/tarta-zoot/test-mkfs.ext4 is in use and contains a ext4 filesystem.

# zpool create zpool-create-exported /dev/zvol/tarta-zoot/test-zpool-create-exported
# zpool export zpool-create-exported
# zpool create zpool-create-exported2 /dev/zvol/tarta-zoot/test-zpool-create-exported
$ zpool list zpool-create-exported2
NAME                     SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
zpool-create-exported2   398G   744K   398G        -         -     0%     0%  1.00x    ONLINE  -

# mkfs.ext4 /dev/zvol/tarta-zoot/test-mkfs.ext4-exported
# zpool create mkfs.ext4-exported /dev/zvol/tarta-zoot/test-mkfs.ext4-exported
invalid vdev specification
use '-f' to override the following errors:
/dev/zvol/tarta-zoot/test-mkfs.ext4-exported contains a filesystem of type 'ext4'
stale[bot] commented 1 year ago

This issue has been automatically marked as "stale" because it has not had any activity for a while. It will be closed in 90 days if no further activity occurs. Thank you for your contributions.

nabijaczleweli commented 1 year ago

Can repro this to a tee with zfs-2.1.9-2 zfs-kmod-2.1.8-1