Whamcloud - gitweb
LU-3817 llite: Truncate to restore file
[fs/lustre-release.git] / lustre / mdt / mdt_coordinator.c
index 5c07bf0..fa92f75 100644 (file)
@@ -422,7 +422,7 @@ static int mdt_coordinator(void *data)
        ENTRY;
 
        cdt->cdt_thread.t_flags = SVC_RUNNING;
-       cfs_waitq_signal(&cdt->cdt_thread.t_ctl_waitq);
+       wake_up(&cdt->cdt_thread.t_ctl_waitq);
 
        CDEBUG(D_HSM, "%s: coordinator thread starting, pid=%d\n",
               mdt_obd_name(mdt), current_pid());
@@ -652,7 +652,7 @@ out:
                 * and cdt cleaning will be done by event sender
                 */
                cdt->cdt_thread.t_flags = SVC_STOPPED;
-               cfs_waitq_signal(&cdt->cdt_thread.t_ctl_waitq);
+               wake_up(&cdt->cdt_thread.t_ctl_waitq);
        }
 
        if (rc != 0)
@@ -725,6 +725,10 @@ static int hsm_restore_cb(const struct lu_env *env,
 
        larr = (struct llog_agent_req_rec *)hdr;
        hai = &larr->arr_hai;
+       if (hai->hai_cookie > cdt->cdt_last_cookie)
+               /* update the cookie to avoid collision */
+               cdt->cdt_last_cookie = hai->hai_cookie + 1;
+
        if (hai->hai_action != HSMA_RESTORE ||
            agent_req_in_final_state(larr->arr_status))
                RETURN(0);
@@ -741,7 +745,7 @@ static int hsm_restore_cb(const struct lu_env *env,
        crh->extent.end = hai->hai_extent.offset + hai->hai_extent.length;
        */
        crh->crh_extent.start = 0;
-       crh->crh_extent.end = OBD_OBJECT_EOF;
+       crh->crh_extent.end = hai->hai_extent.length;
        /* get the layout lock */
        mdt_lock_reg_init(&crh->crh_lh, LCK_EX);
        child = mdt_object_find_lock(mti, &crh->crh_fid, &crh->crh_lh,
@@ -796,7 +800,7 @@ static int hsm_init_ucred(struct lu_ucred *uc)
        uc->uc_fsgid = 0;
        uc->uc_suppgids[0] = -1;
        uc->uc_suppgids[1] = -1;
-       uc->uc_cap = 0;
+       uc->uc_cap = CFS_CAP_FS_MASK;
        uc->uc_umask = 0777;
        uc->uc_ginfo = NULL;
        uc->uc_identity = NULL;
@@ -820,7 +824,7 @@ int mdt_hsm_cdt_wakeup(struct mdt_device *mdt)
 
        /* wake up coordinator */
        cdt->cdt_thread.t_flags = SVC_EVENT;
-       cfs_waitq_signal(&cdt->cdt_thread.t_ctl_waitq);
+       wake_up(&cdt->cdt_thread.t_ctl_waitq);
 
        RETURN(0);
 }
@@ -840,7 +844,7 @@ int mdt_hsm_cdt_init(struct mdt_device *mdt)
 
        cdt->cdt_state = CDT_STOPPED;
 
-       cfs_waitq_init(&cdt->cdt_thread.t_ctl_waitq);
+       init_waitqueue_head(&cdt->cdt_thread.t_ctl_waitq);
        mutex_init(&cdt->cdt_llog_lock);
        init_rwsem(&cdt->cdt_agent_lock);
        init_rwsem(&cdt->cdt_request_lock);
@@ -929,6 +933,7 @@ int mdt_hsm_cdt_start(struct mdt_device *mdt)
        cdt->cdt_delay = 60;
        cdt->cdt_timeout = 3600;
        cdt->cdt_max_request = 3;
+       cdt->cdt_archive_id = 1;
        atomic_set(&cdt->cdt_request_count, 0);
 
        /* to avoid deadlock when start is made through /proc
@@ -955,7 +960,7 @@ int mdt_hsm_cdt_start(struct mdt_device *mdt)
                rc = 0;
        }
 
-       cfs_wait_event(cdt->cdt_thread.t_ctl_waitq,
+       wait_event(cdt->cdt_thread.t_ctl_waitq,
                       (cdt->cdt_thread.t_flags & SVC_RUNNING));
 
        cdt->cdt_state = CDT_RUNNING;
@@ -989,9 +994,9 @@ int mdt_hsm_cdt_stop(struct mdt_device *mdt)
        if (cdt->cdt_state != CDT_STOPPING) {
                /* stop coordinator thread before cleaning */
                cdt->cdt_thread.t_flags = SVC_STOPPING;
-               cfs_waitq_signal(&cdt->cdt_thread.t_ctl_waitq);
-               cfs_wait_event(cdt->cdt_thread.t_ctl_waitq,
-                              cdt->cdt_thread.t_flags & SVC_STOPPED);
+               wake_up(&cdt->cdt_thread.t_ctl_waitq);
+               wait_event(cdt->cdt_thread.t_ctl_waitq,
+                          cdt->cdt_thread.t_flags & SVC_STOPPED);
        }
        cdt->cdt_state = CDT_STOPPED;
 
@@ -1897,6 +1902,7 @@ GENERATE_PROC_METHOD(cdt_loop_period)
 GENERATE_PROC_METHOD(cdt_delay)
 GENERATE_PROC_METHOD(cdt_timeout)
 GENERATE_PROC_METHOD(cdt_max_request)
+GENERATE_PROC_METHOD(cdt_archive_id)
 
 /*
  * procfs write method for MDT/hsm_control
@@ -1982,6 +1988,9 @@ static struct lprocfs_vars lprocfs_mdt_hsm_vars[] = {
        { "agents",             NULL, NULL, NULL, &mdt_hsm_agent_fops, 0 },
        { "agent_actions",      NULL, NULL, NULL,
                                &mdt_agent_actions_fops, 0444 },
+       { "archive_id",         lprocfs_rd_hsm_cdt_archive_id,
+                               lprocfs_wr_hsm_cdt_archive_id,
+                               NULL, NULL, 0 },
        { "grace_delay",        lprocfs_rd_hsm_cdt_delay,
                                lprocfs_wr_hsm_cdt_delay,
                                NULL, NULL, 0 },