Whamcloud - gitweb
LU-5756 hsm: add missing return code in llapi_hsm_copytool_register 14/12314/6
authorFrank Zago <fzago@cray.com>
Thu, 16 Oct 2014 16:49:49 +0000 (11:49 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 30 Oct 2014 02:18:00 +0000 (02:18 +0000)
llapi_hsm_copytool_register() returns a bogus error code on one error
path.

Removed a never true "if" case.

If the LL_IOC_HSM_CT_START fails, then we have to go to out_kuc,
not out_err.

Change-Id: I738078392f98d4616f6451beece4f0d97bc8051d
Signed-off-by: frank zago <fzago@cray.com>
Reviewed-on: http://review.whamcloud.com/12314
Reviewed-by: Henri Doreau <henri.doreau@cea.fr>
Tested-by: Jenkins
Reviewed-by: James Nunez <james.a.nunez@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/utils/liblustreapi_hsm.c

index 09b537f..7c2d175 100644 (file)
@@ -654,11 +654,16 @@ out_free:
 }
 
 /** Register a copytool
 }
 
 /** Register a copytool
- * \param[out] priv Opaque private control structure
- * \param mnt Lustre filesystem mount point
- * \param archive_count
- * \param archives Which archive numbers this copytool is responsible for
- * \param rfd_flags flags applied to read fd of pipe (e.g. O_NONBLOCK)
+ * \param[out] priv            Opaque private control structure
+ * \param mnt                  Lustre filesystem mount point
+ * \param archive_count                Number of valid archive IDs in \a archives
+ * \param archives             Which archive numbers this copytool is
+ *                             responsible for
+ * \param rfd_flags            flags applied to read fd of pipe
+ *                             (e.g. O_NONBLOCK)
+ *
+ * \retval 0 on success.
+ * \retval -errno on error.
  */
 int llapi_hsm_copytool_register(struct hsm_copytool_private **priv,
                                const char *mnt, int archive_count,
  */
 int llapi_hsm_copytool_register(struct hsm_copytool_private **priv,
                                const char *mnt, int archive_count,
@@ -714,6 +719,7 @@ int llapi_hsm_copytool_register(struct hsm_copytool_private **priv,
                        llapi_err_noerrno(LLAPI_MSG_ERROR,
                                          "maximum of %zu archives supported",
                                          8 * sizeof(ct->archives));
                        llapi_err_noerrno(LLAPI_MSG_ERROR,
                                          "maximum of %zu archives supported",
                                          8 * sizeof(ct->archives));
+                       rc = -EINVAL;
                        goto out_err;
                }
                /* in the list we have a all archive wildcard
                        goto out_err;
                }
                /* in the list we have a all archive wildcard
@@ -738,9 +744,7 @@ int llapi_hsm_copytool_register(struct hsm_copytool_private **priv,
                rc = -errno;
                llapi_error(LLAPI_MSG_ERROR, rc,
                            "cannot start copytool on '%s'", mnt);
                rc = -errno;
                llapi_error(LLAPI_MSG_ERROR, rc,
                            "cannot start copytool on '%s'", mnt);
-               goto out_err;
-       } else {
-               rc = 0;
+               goto out_kuc;
        }
 
        llapi_hsm_log_ct_registration(&ct, CT_REGISTER);
        }
 
        llapi_hsm_log_ct_registration(&ct, CT_REGISTER);
@@ -748,10 +752,8 @@ int llapi_hsm_copytool_register(struct hsm_copytool_private **priv,
        /* Only the kernel reference keeps the write side open */
        close(ct->kuc.lk_wfd);
        ct->kuc.lk_wfd = LK_NOFD;
        /* Only the kernel reference keeps the write side open */
        close(ct->kuc.lk_wfd);
        ct->kuc.lk_wfd = LK_NOFD;
-       if (rc < 0)
-               goto out_kuc;
-
        *priv = ct;
        *priv = ct;
+
        return 0;
 
 out_kuc:
        return 0;
 
 out_kuc: