Whamcloud - gitweb
LU-8386 zfs: Use ZFS_MAXPROPLEN instead of ZFS_MAXNAMELEN
[fs/lustre-release.git] / lustre / mdt / mdt_hsm_cdt_agent.c
index 4ef5f14..c97be71 100644 (file)
@@ -344,18 +344,10 @@ int mdt_hsm_agent_send(struct mdt_thread_info *mti,
               hal->hal_archive_id);
 
        len = hal_size(hal);
-       if (kuc_ispayload(hal)) {
-               /* hal is already a kuc payload
-                * we do not need to alloc a new one
-                * this avoid a alloc/memcpy/free
-                */
-               buf = hal;
-       } else {
-               buf = kuc_alloc(len, KUC_TRANSPORT_HSM, HMT_ACTION_LIST);
-               if (IS_ERR(buf))
-                       RETURN(PTR_ERR(buf));
-               memcpy(buf, hal, len);
-       }
+       buf = kuc_alloc(len, KUC_TRANSPORT_HSM, HMT_ACTION_LIST);
+       if (IS_ERR(buf))
+               RETURN(PTR_ERR(buf));
+       memcpy(buf, hal, len);
 
        /* Check if request is still valid (cf file hsm flags) */
        fail_request = false;
@@ -414,6 +406,33 @@ int mdt_hsm_agent_send(struct mdt_thread_info *mti,
                                              hai->hai_cookie, rc);
                                        GOTO(out_buf, rc);
                                }
+
+                               /* if restore and record status updated, give
+                                * 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,
+                                                               &hai->hai_fid);
+                                       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,
+                                                                 &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);
+                               }
                        }
                }
        }
@@ -487,8 +506,7 @@ out:
        }
 
 out_buf:
-       if (buf != hal)
-               kuc_free(buf, len);
+       kuc_free(buf, len);
 
        RETURN(rc);
 }