diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.c index 529131aeab49..ca55063a3ccd 100644 --- a/usr.sbin/ctld/ctld.c +++ b/usr.sbin/ctld/ctld.c @@ -1662,6 +1662,16 @@ conf_apply(struct conf *oldconf, struct conf *newconf) */ newtarg = target_find(newconf, oldtarg->t_name); if (newtarg == NULL) { + error = kernel_port_remove(oldtarg); + if (error != 0) { + log_warnx("failed to remove target %s", + oldtarg->t_name); + /* + * XXX: Uncomment after fixing the root cause. + * + * cumulated_error++; + */ + } TAILQ_FOREACH_SAFE(oldlun, &oldtarg->t_luns, l_next, tmplun) { log_debugx("target %s not found in new " @@ -1678,16 +1688,6 @@ conf_apply(struct conf *oldconf, struct conf *newconf) cumulated_error++; } } - error = kernel_port_remove(oldtarg); - if (error != 0) { - log_warnx("failed to remove target %s", - oldtarg->t_name); - /* - * XXX: Uncomment after fixing the root cause. - * - * cumulated_error++; - */ - } continue; }