Open glebius opened 4 months ago
I think B_FALSE return of zfs_dev_is_whole_disk() in case of disk opening failure is wrong on any OS. It should be able to return error. Since on FreeBSD ZFS never partitions its disks, on FreeBSD should always return either B_TRUE or error, in the last case addition should fail with respective status.
Observing on FreeBSD 15.0-CURRENT, but my code reading says on Linux it is likely to be the same.
However, both the tank exists and ada0 also exists. As you see the error message is really unhelpful.
The problem is that ada0 is used, either by ZFS or by any other filesystem or swap, or whatever. The call path that leads to this is the following:
This open() will return EPERM. This error code is not covered by libzfs zpool_add(), neither by zpool_standard_error(), nor by zfs_common_error(). However, covering this error code in these functions won't help :( The problem is that zfs_dev_is_whole_disk() is boolean - it doesn't propagate the error up the stack. Checked its Linux twin - it is the same.
So, the right fix is to propagate this EPERM all the way up to zpool_do_add(), which isn't trivial. I can write the code, but first want to get some directions from OpenZFS developers on how exactly you want this to be done.