Whamcloud - gitweb
Revert "LU-5216 hsm: cancel hsm actions running on CT when killed"
[fs/lustre-release.git] / lustre / mdt / mdt_hsm_cdt_agent.c
index a28a932..579c309 100644 (file)
@@ -40,7 +40,6 @@
 #include <obd.h>
 #include <obd_support.h>
 #include <lustre_export.h>
-#include <lustre/lustre_user.h>
 #include <lprocfs_status.h>
 #include <lustre_kernelcomm.h>
 #include "mdt_internal.h"
@@ -405,6 +404,8 @@ int mdt_hsm_agent_send(struct mdt_thread_info *mti,
                hai = hai_first(hal);
                for (i = 0; i < hal->hal_count; i++,
                     hai = hai_next(hai)) {
+                       struct hsm_record_update update;
+
                        /* only removes are concerned */
                        if (hai->hai_action != HSMA_REMOVE) {
                                /* count if other actions than HSMA_REMOVE,
@@ -424,9 +425,11 @@ int mdt_hsm_agent_send(struct mdt_thread_info *mti,
                         * XXX: this should only cause duplicates to be sent,
                         * unless a method to record already successfully
                         * reached archive_ids is implemented */
+
+                       update.cookie = hai->hai_cookie;
+                       update.status = ARS_SUCCEED;
                        rc2 = mdt_agent_record_update(mti->mti_env, mdt,
-                                                    &hai->hai_cookie,
-                                                    1, ARS_SUCCEED);
+                                                     &update, 1);
                        if (rc2) {
                                CERROR("%s: mdt_agent_record_update() "
                                      "failed, cannot update "
@@ -473,13 +476,17 @@ int mdt_hsm_agent_send(struct mdt_thread_info *mti,
                if (!IS_ERR(obj)) {
                        mdt_object_put(mti->mti_env, obj);
                } else if (PTR_ERR(obj) == -ENOENT) {
+                       struct hsm_record_update update = {
+                               .cookie = hai->hai_cookie,
+                               .status = ARS_FAILED,
+                       };
+
                        if (hai->hai_action == HSMA_REMOVE)
                                continue;
 
                        fail_request = true;
                        rc = mdt_agent_record_update(mti->mti_env, mdt,
-                                                    &hai->hai_cookie,
-                                                    1, ARS_FAILED);
+                                                    &update, 1);
                        if (rc < 0) {
                                CERROR("%s: mdt_agent_record_update() failed, "
                                       "cannot update status to %s for cookie "
@@ -497,14 +504,18 @@ int mdt_hsm_agent_send(struct mdt_thread_info *mti,
 
                if (!mdt_hsm_is_action_compat(hai, hal->hal_archive_id,
                                              hal->hal_flags, &hsm)) {
+                       struct hsm_record_update update = {
+                               .cookie = hai->hai_cookie,
+                               .status = ARS_FAILED,
+                       };
+
                        /* incompatible request, we abort the request */
                        /* next time coordinator will wake up, it will
                         * make the same compound with valid only
                         * records */
                        fail_request = true;
                        rc = mdt_agent_record_update(mti->mti_env, mdt,
-                                                    &hai->hai_cookie,
-                                                    1, ARS_FAILED);
+                                                    &update, 1);
                        if (rc) {
                                CERROR("%s: mdt_agent_record_update() failed, "
                                       "cannot update status to %s for cookie "
@@ -519,7 +530,6 @@ int mdt_hsm_agent_send(struct mdt_thread_info *mti,
                         * back granted layout lock */
                        if (hai->hai_action == HSMA_RESTORE) {
                                struct cdt_restore_handle *crh = NULL;
-                               struct mdt_object *obj = NULL;
 
                                mutex_lock(&cdt->cdt_restore_lock);
                                crh = mdt_hsm_restore_hdl_find(cdt,
@@ -527,17 +537,12 @@ int mdt_hsm_agent_send(struct mdt_thread_info *mti,
                                if (crh != NULL)
                                        list_del(&crh->crh_list);
                                mutex_unlock(&cdt->cdt_restore_lock);
-                               obj = mdt_object_find(mti->mti_env,
-                                                     mti->mti_mdt,
-                                                     &hai->hai_fid);
-                               if (!IS_ERR(obj) && crh != NULL)
-                                       mdt_object_unlock(mti, obj,
+                               if (crh != NULL) {
+                                       mdt_object_unlock(mti, NULL,
                                                          &crh->crh_lh, 1);
-                               if (crh != NULL)
                                        OBD_SLAB_FREE_PTR(crh,
                                                          mdt_hsm_cdt_kmem);
-                               if (!IS_ERR(obj))
-                                       mdt_object_put(mti->mti_env, obj);
+                               }
                        }
                }
        }
@@ -765,4 +770,3 @@ const struct file_operations mdt_hsm_agent_fops = {
        .llseek         = seq_lseek,
        .release        = lprocfs_seq_release,
 };
-