Whamcloud - gitweb
LU-5691 hsm: remove a request from the index if not present in the store
[fs/lustre-release.git] / lustre / mdt / mdt_coordinator.c
index 1617eeb..ac5518f 100644 (file)
@@ -227,9 +227,8 @@ static int mdt_coordinator_cb(const struct lu_env *env,
                                RETURN(-ENOMEM);
                        }
                        hal->hal_version = HAL_VERSION;
-                       strncpy(hal->hal_fsname, hsd->fs_name,
-                               MTI_NAME_MAXLEN);
-                       hal->hal_fsname[MTI_NAME_MAXLEN] = '\0';
+                       strlcpy(hal->hal_fsname, hsd->fs_name,
+                               MTI_NAME_MAXLEN + 1);
                        hal->hal_compound_id = larr->arr_compound_id;
                        hal->hal_archive_id = larr->arr_archive_id;
                        hal->hal_flags = larr->arr_flags;
@@ -337,6 +336,15 @@ static int mdt_coordinator_cb(const struct lu_env *env,
                                       hsm_copytool_action2name(
                                                     larr->arr_hai.hai_action));
 
+                       if (rc == -ENOENT) {
+                               /* The request no longer exists, forget
+                                * about it, and do not send a cancel request
+                                * to the client, for which an error will be
+                                * sent back, leading to an endless cycle of
+                                * cancellation. */
+                               RETURN(LLOG_DEL_RECORD);
+                       }
+
                        /* add the cookie to the list of record to be
                         * canceled by caller */
                        if (hsd->max_cookie == (hsd->cookie_cnt - 1)) {
@@ -869,9 +877,9 @@ int mdt_hsm_cdt_init(struct mdt_device *mdt)
        init_rwsem(&cdt->cdt_request_lock);
        mutex_init(&cdt->cdt_restore_lock);
 
-       CFS_INIT_LIST_HEAD(&cdt->cdt_requests);
-       CFS_INIT_LIST_HEAD(&cdt->cdt_agents);
-       CFS_INIT_LIST_HEAD(&cdt->cdt_restore_hdl);
+       INIT_LIST_HEAD(&cdt->cdt_requests);
+       INIT_LIST_HEAD(&cdt->cdt_agents);
+       INIT_LIST_HEAD(&cdt->cdt_restore_hdl);
 
        rc = lu_env_init(&cdt->cdt_env, LCT_MD_THREAD);
        if (rc < 0)