Whamcloud - gitweb
LU-8592 mdt: hold mdt_device::mdt_md_root until service stop
[fs/lustre-release.git] / lustre / mdt / mdt_hsm_cdt_actions.c
index 5c5f254..14b08f9 100644 (file)
@@ -53,10 +53,10 @@ void dump_llog_agent_req_rec(const char *prefix,
        sz = larr->arr_hai.hai_len - sizeof(larr->arr_hai);
        CDEBUG(D_HSM, "%slrh=[type=%X len=%d idx=%d] fid="DFID
               " dfid="DFID
-              " compound/cookie="LPX64"/"LPX64
-              " status=%s action=%s archive#=%d flags="LPX64
-              " create="LPU64" change="LPU64
-              " extent="LPX64"-"LPX64" gid="LPX64" datalen=%d"
+              " compound/cookie=%#llx/%#llx"
+              " status=%s action=%s archive#=%d flags=%#llx"
+              " create=%llu change=%llu"
+              " extent=%#llx-%#llx gid=%#llx datalen=%d"
               " data=[%s]\n",
               prefix,
               larr->arr_hdr.lrh_type,
@@ -157,11 +157,13 @@ int mdt_agent_record_add(const struct lu_env *env,
        /* in case of cancel request, the cookie is already set to the
         * value of the request cookie to be cancelled
         * so we do not change it */
-       if (hai->hai_action != HSMA_CANCEL) {
+       if (hai->hai_action == HSMA_CANCEL) {
+               larr->arr_hai.hai_cookie = hai->hai_cookie;
+       } else {
                cdt->cdt_last_cookie++;
-               hai->hai_cookie = cdt->cdt_last_cookie;
+               larr->arr_hai.hai_cookie = cdt->cdt_last_cookie;
        }
-       larr->arr_hai.hai_cookie = hai->hai_cookie;
+
        rc = llog_cat_add(env, lctxt->loc_handle, &larr->arr_hdr, NULL);
        if (rc > 0)
                rc = 0;
@@ -205,12 +207,10 @@ static int mdt_agent_record_update_cb(const struct lu_env *env,
        struct llog_agent_req_rec       *larr;
        struct data_update_cb           *ducb;
        int                              rc, i;
-       int                              found;
        ENTRY;
 
        larr = (struct llog_agent_req_rec *)hdr;
        ducb = data;
-       found = 0;
 
        /* check if all done */
        if (ducb->cookies_count == ducb->cookies_done)
@@ -230,17 +230,15 @@ static int mdt_agent_record_update_cb(const struct lu_env *env,
 
        rc = 0;
        for (i = 0 ; i < ducb->cookies_count ; i++) {
-               CDEBUG(D_HSM, "%s: search "LPX64", found "LPX64"\n",
+               CDEBUG(D_HSM, "%s: search %#llx, found %#llx\n",
                       mdt_obd_name(ducb->mdt), ducb->cookies[i],
                       larr->arr_hai.hai_cookie);
                if (larr->arr_hai.hai_cookie == ducb->cookies[i]) {
 
                        larr->arr_status = ducb->status;
                        larr->arr_req_change = ducb->change_time;
-                       rc = mdt_agent_llog_update_rec(env, ducb->mdt, llh,
-                                                      larr);
+                       rc = llog_write(env, llh, hdr, hdr->lrh_index);
                        ducb->cookies_done++;
-                       found = 1;
                        break;
                }
        }
@@ -249,9 +247,6 @@ static int mdt_agent_record_update_cb(const struct lu_env *env,
                CERROR("%s: mdt_agent_llog_update_rec() failed, rc = %d\n",
                       mdt_obd_name(ducb->mdt), rc);
 
-       if (found == 1)
-               RETURN(LLOG_DEL_RECORD);
-
        RETURN(rc);
 }
 
@@ -290,35 +285,6 @@ int mdt_agent_record_update(const struct lu_env *env, struct mdt_device *mdt,
        RETURN(rc);
 }
 
-/**
- * update a llog record
- *  cdt_llog_lock must be hold
- * \param env [IN] environment
- * \param mdt [IN] mdt device
- * \param llh [IN] llog handle, must be a catalog handle
- * \param larr [IN] record
- * \retval 0 success
- * \retval -ve failure
- */
-int mdt_agent_llog_update_rec(const struct lu_env *env,
-                             struct mdt_device *mdt, struct llog_handle *llh,
-                             struct llog_agent_req_rec *larr)
-{
-       struct llog_rec_hdr      saved_hdr;
-       int                      rc;
-       ENTRY;
-
-       /* saved old record info */
-       saved_hdr = larr->arr_hdr;
-       /* add new record with updated values */
-       larr->arr_hdr.lrh_id = 0;
-       larr->arr_hdr.lrh_index = 0;
-       rc = llog_cat_add(env, llh->u.phd.phd_cat_handle, &larr->arr_hdr,
-                         NULL);
-       larr->arr_hdr = saved_hdr;
-       RETURN(rc);
-}
-
 /*
  * Agent actions /proc seq_file methods
  * As llog processing uses a callback for each entry, we cannot do a sequential
@@ -365,7 +331,7 @@ static void *mdt_hsm_actions_proc_start(struct seq_file *s, loff_t *pos)
                RETURN(ERR_PTR(-ENOENT));
        }
 
-       CDEBUG(D_HSM, "llog successfully initialized, start from "LPD64"\n",
+       CDEBUG(D_HSM, "llog successfully initialized, start from %lld\n",
               *pos);
        /* first call = rewind */
        if (*pos == 0) {
@@ -418,10 +384,10 @@ static int hsm_actions_show_cb(const struct lu_env *env,
        count = s->count;
        sz = larr->arr_hai.hai_len - sizeof(larr->arr_hai);
        seq_printf(s, "lrh=[type=%X len=%d idx=%d/%d] fid="DFID
-                  " dfid="DFID" compound/cookie="LPX64"/"LPX64
-                  " action=%s archive#=%d flags="LPX64
-                  " extent="LPX64"-"LPX64
-                  " gid="LPX64" datalen=%d status=%s data=[%s]\n",
+                  " dfid="DFID" compound/cookie=%#llx/%#llx"
+                  " action=%s archive#=%d flags=%#llx"
+                  " extent=%#llx-%#llx"
+                  " gid=%#llx datalen=%d status=%s data=[%s]\n",
                   hdr->lrh_type, hdr->lrh_len,
                   llh->lgh_hdr->llh_cat_idx, hdr->lrh_index,
                   PFID(&larr->arr_hai.hai_fid),