Whamcloud - gitweb
LU-7988 hsm: split mdt_hsm_add_actions() 72/20272/32
authorFrank Zago <fzago@cray.com>
Tue, 3 May 2016 20:13:05 +0000 (16:13 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 9 Oct 2017 03:49:30 +0000 (03:49 +0000)
Split a portion of mdt_hsm_add_actions() to the new function
mdt_hsm_process_hal() in order to re-use it in a subsequent patch.

Signed-off-by: frank zago <fzago@cray.com>
Change-Id: I32785c549a744592d4e84787fd16d12e7ffd7322
Reviewed-on: https://review.whamcloud.com/20272
Tested-by: Jenkins
Reviewed-by: Quentin Bouget <quentin.bouget@cea.fr>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Ben Evans <bevans@cray.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_hsm_cdt_client.c

index aa4f123..153f285 100644 (file)
@@ -281,48 +281,22 @@ hsm_action_permission(struct mdt_thread_info *mti,
        RETURN(*mask & (1UL << hsma) ? 0 : -EPERM);
 }
 
-/*
- * Coordinator external API
- */
-
-/**
- * register a list of requests
- * \param mti [IN]
- * \param hal [IN] list of requests
- * \retval 0 success
- * \retval -ve failure
- * in case of restore, caller must hold layout lock
- */
-int mdt_hsm_add_actions(struct mdt_thread_info *mti,
-                       struct hsm_action_list *hal)
+/* Process a single HAL. hsm_find_compatible has already been called
+ * on it. */
+static int mdt_hsm_register_hal(struct mdt_thread_info *mti,
+                               struct mdt_device *mdt,
+                               struct coordinator *cdt,
+                               struct hsm_action_list *hal)
 {
-       struct mdt_device       *mdt = mti->mti_mdt;
-       struct coordinator      *cdt = &mdt->mdt_coordinator;
        struct hsm_action_item  *hai;
        struct mdt_object       *obj = NULL;
-       int                      rc = 0, i;
+       int                      rc, i;
        struct md_hsm            mh;
        bool                     is_restore = false;
        __u64                    compound_id;
-       ENTRY;
-
-       /* no coordinator started, so we cannot serve requests */
-       if (cdt->cdt_state == CDT_STOPPED)
-               RETURN(-EAGAIN);
-
-       if (!hal_is_sane(hal))
-               RETURN(-EINVAL);
 
        compound_id = atomic_inc_return(&cdt->cdt_compound_id);
 
-       /* search for compatible request, if found hai_cookie is set
-        * to the request cookie
-        * it is also used to set the cookie for cancel request by FID
-        */
-       rc = hsm_find_compatible(mti->mti_env, mdt, hal);
-       if (rc)
-               GOTO(out, rc);
-
        hai = hai_first(hal);
        for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) {
                int archive_id;
@@ -478,6 +452,49 @@ record:
                rc = 0;
 
        GOTO(out, rc);
+
+out:
+       return rc;
+}
+
+/*
+ * Coordinator external API
+ */
+
+/**
+ * register a list of requests
+ * \param mti [IN]
+ * \param hal [IN] list of requests
+ * \retval 0 success
+ * \retval -ve failure
+ * in case of restore, caller must hold layout lock
+ */
+int mdt_hsm_add_actions(struct mdt_thread_info *mti,
+                       struct hsm_action_list *hal)
+{
+       struct mdt_device       *mdt = mti->mti_mdt;
+       struct coordinator      *cdt = &mdt->mdt_coordinator;
+       int                      rc;
+       ENTRY;
+
+       /* no coordinator started, so we cannot serve requests */
+       if (cdt->cdt_state == CDT_STOPPED)
+               RETURN(-EAGAIN);
+
+       if (!hal_is_sane(hal))
+               RETURN(-EINVAL);
+
+       /* search for compatible request, if found hai_cookie is set
+        * to the request cookie
+        * it is also used to set the cookie for cancel request by FID
+        */
+       rc = hsm_find_compatible(mti->mti_env, mdt, hal);
+       if (rc)
+               GOTO(out, rc);
+
+       rc = mdt_hsm_register_hal(mti, mdt, cdt, hal);
+
+       GOTO(out, rc);
 out:
        /* if work has been added, signal the coordinator */
        if (rc == 0 || rc == -ENODATA)