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 <batkinson@lanl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #13538
Closes #15747
This commit is contained in:
Brian Behlendorf
2024-01-12 12:35:29 -08:00
parent 509526ad21
commit 2006ac1f4a
2 changed files with 14 additions and 5 deletions
+1 -3
View File
@@ -291,10 +291,8 @@ zpool_in_use(libzfs_handle_t *hdl, int fd, pool_state_t *state, char **namestr,
*inuse = B_FALSE;
if (zpool_read_label(fd, &config, NULL) != 0) {
(void) no_memory(hdl);
if (zpool_read_label(fd, &config, NULL) != 0)
return (-1);
}
if (config == NULL)
return (0);