diff options
author | Brian Behlendorf <[email protected]> | 2024-01-12 12:35:29 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2024-01-12 12:35:29 -0800 |
commit | a1771d243a57524c6599d7beedcb2085e5c05395 (patch) | |
tree | d3b5f1d2aac2171314f5245d71f3b49c3d5d8a00 /lib/libzutil/zutil_import.c | |
parent | 363368c67045657b012a2756f54b4c04de01e4ef (diff) |
Fix "out of memory" error
Drop the no_memory() call from zpool_in_use() when reading the
label fails and instead return the error to the caller. This
prevents a misleading "internal error: out of memory" error
when the label can't be read. This will result in is_spare()
returning B_FALSE instead of aborting, which is already safely
handled.
Furthermore, on Linux it's possible for EREMOTEIO to returned
by an NVMe device if the device has been low-level formatted
and not rescanned. In this case we want to fallback to the
legacy scanning method and read any of the labels we can.
Reviewed-by: Brian Atkinson <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Issue #13538
Closes #15747
Diffstat (limited to 'lib/libzutil/zutil_import.c')
-rw-r--r-- | lib/libzutil/zutil_import.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/libzutil/zutil_import.c b/lib/libzutil/zutil_import.c index d023dd105..0b5c47b08 100644 --- a/lib/libzutil/zutil_import.c +++ b/lib/libzutil/zutil_import.c @@ -1056,10 +1056,21 @@ zpool_read_label(int fd, nvlist_t **config, int *num_labels) case EINVAL: break; case EINPROGRESS: - // This shouldn't be possible to - // encounter, die if we do. + /* + * This shouldn't be possible to + * encounter, die if we do. + */ ASSERT(B_FALSE); zfs_fallthrough; + case EREMOTEIO: + /* + * May be returned by an NVMe device + * which is visible in /dev/ but due + * to a low-level format change, or + * other error, needs to be rescanned. + * Try the slow method. + */ + zfs_fallthrough; case EOPNOTSUPP: case ENOSYS: do_slow = B_TRUE; |