Whamcloud - gitweb
LU-3789 mgs: Add deprecation warning for "lctl conf_param"
[fs/lustre-release.git] / lustre / utils / liblustreapi_hsm.c
index 72b64cc..9a36c6b 100644 (file)
@@ -122,7 +122,7 @@ int llapi_hsm_copytool_register(struct hsm_copytool_private **priv,
        for (rc = 0; rc < archive_count; rc++) {
                if (archives[rc] > 8 * sizeof(ct->archives)) {
                        llapi_err_noerrno(LLAPI_MSG_ERROR,
-                                         "Maximum of %d archives supported",
+                                         "maximum of %zu archives supported",
                                          8 * sizeof(ct->archives));
                        goto out_err;
                }
@@ -155,7 +155,7 @@ 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 = 0;
+       ct->kuc.lk_wfd = LK_NOFD;
        if (rc < 0)
                goto out_kuc;
 
@@ -340,10 +340,13 @@ static int fid_parent(const char *mnt, const lustre_fid *fid, char *parent,
 
 /** Create the destination volatile file for a restore operation.
  *
- * \param hcp  Private copyaction handle.
+ * \param hcp        Private copyaction handle.
+ * \param mdt_index  MDT index where to create the volatile file.
+ * \param flags      Volatile file creation flags.
  * \return 0 on success.
  */
-static int create_restore_volatile(struct hsm_copyaction_private *hcp)
+static int create_restore_volatile(struct hsm_copyaction_private *hcp,
+                                  int mdt_index, int flags)
 {
        int                      rc;
        int                      fd;
@@ -360,7 +363,7 @@ static int create_restore_volatile(struct hsm_copyaction_private *hcp)
                snprintf(parent, sizeof(parent), "%s", mnt);
        }
 
-       fd = llapi_create_volatile_idx(parent, 0, O_LOV_DELAY_CREATE);
+       fd = llapi_create_volatile_idx(parent, mdt_index, flags);
        if (fd < 0)
                return fd;
 
@@ -384,17 +387,24 @@ err_cleanup:
  * It could be skipped if copytool only want to directly report an error,
  * \see llapi_hsm_action_end().
  *
- * \param hcp      Opaque action handle to be passed to
- *                 llapi_hsm_action_progress and llapi_hsm_action_end.
- * \param ct       Copytool handle acquired at registration.
- * \param hai      The hsm_action_item describing the request.
- * \param is_error Whether this call is just to report an error.
+ * \param hcp                Opaque action handle to be passed to
+ *                           llapi_hsm_action_progress and llapi_hsm_action_end.
+ * \param ct                 Copytool handle acquired at registration.
+ * \param hai                The hsm_action_item describing the request.
+ * \param restore_mdt_index  On restore: MDT index where to create the volatile
+ *                           file. Use -1 for default.
+ * \param restore_open_flags On restore: volatile file creation mode. Use
+ *                           O_LOV_DELAY_CREATE to manually set the LOVEA
+ *                           afterwards.
+ * \param is_error           Whether this call is just to report an error.
  *
  * \return 0 on success.
  */
 int llapi_hsm_action_begin(struct hsm_copyaction_private **phcp,
                           const struct hsm_copytool_private *ct,
-                          const struct hsm_action_item *hai, bool is_error)
+                          const struct hsm_action_item *hai,
+                          int restore_mdt_index, int restore_open_flags,
+                          bool is_error)
 {
        struct hsm_copyaction_private   *hcp;
        int                              rc;
@@ -412,7 +422,8 @@ int llapi_hsm_action_begin(struct hsm_copyaction_private **phcp,
                goto ok_out;
 
        if (hai->hai_action == HSMA_RESTORE) {
-               rc = create_restore_volatile(hcp);
+               rc = create_restore_volatile(hcp, restore_mdt_index,
+                                            restore_open_flags);
                if (rc < 0)
                        goto err_out;
        }