Skip to content

Commit ff8cb87

Browse files
tonyhutterFedorUporovVstack
authored andcommitted
zed: Print return code on failed zpool_prepare_disk
We had a case where we were autoreplacing a disk and zpool_prepare_disk failed for some reason, and ZED didn't log the return code. This commit logs the code. Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Tony Hutter <[email protected]> Closes openzfs#17124
1 parent 20572d6 commit ff8cb87

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

cmd/zed/agents/zfs_mod.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t labeled)
214214
vdev_stat_t *vs;
215215
char **lines = NULL;
216216
int lines_cnt = 0;
217+
int rc;
217218

218219
/*
219220
* Get the persistent path, typically under the '/dev/disk/by-id' or
@@ -405,17 +406,17 @@ zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t labeled)
405406
}
406407

407408
nvlist_lookup_string(vdev, "new_devid", &new_devid);
408-
409409
if (is_mpath_wholedisk) {
410410
/* Don't label device mapper or multipath disks. */
411411
zed_log_msg(LOG_INFO,
412412
" it's a multipath wholedisk, don't label");
413-
if (zpool_prepare_disk(zhp, vdev, "autoreplace", &lines,
414-
&lines_cnt) != 0) {
413+
rc = zpool_prepare_disk(zhp, vdev, "autoreplace", &lines,
414+
&lines_cnt);
415+
if (rc != 0) {
415416
zed_log_msg(LOG_INFO,
416417
" zpool_prepare_disk: could not "
417-
"prepare '%s' (%s)", fullpath,
418-
libzfs_error_description(g_zfshdl));
418+
"prepare '%s' (%s), path '%s', rc = %d", fullpath,
419+
libzfs_error_description(g_zfshdl), path, rc);
419420
if (lines_cnt > 0) {
420421
zed_log_msg(LOG_INFO,
421422
" zfs_prepare_disk output:");
@@ -446,12 +447,13 @@ zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t labeled)
446447
* If this is a request to label a whole disk, then attempt to
447448
* write out the label.
448449
*/
449-
if (zpool_prepare_and_label_disk(g_zfshdl, zhp, leafname,
450-
vdev, "autoreplace", &lines, &lines_cnt) != 0) {
450+
rc = zpool_prepare_and_label_disk(g_zfshdl, zhp, leafname,
451+
vdev, "autoreplace", &lines, &lines_cnt);
452+
if (rc != 0) {
451453
zed_log_msg(LOG_WARNING,
452454
" zpool_prepare_and_label_disk: could not "
453-
"label '%s' (%s)", leafname,
454-
libzfs_error_description(g_zfshdl));
455+
"label '%s' (%s), rc = %d", leafname,
456+
libzfs_error_description(g_zfshdl), rc);
455457
if (lines_cnt > 0) {
456458
zed_log_msg(LOG_INFO,
457459
" zfs_prepare_disk output:");

0 commit comments

Comments
 (0)