Whamcloud - gitweb
LU-6215 llite: cleanup inode_dio_XXX functions
[fs/lustre-release.git] / lustre / mdt / mdt_hsm_cdt_actions.c
index eda547e..59cbfe2 100644 (file)
@@ -23,6 +23,7 @@
  * (C) Copyright 2012 Commissariat a l'energie atomique et aux energies
  *     alternatives
  *
+ * Copyright (c) 2013, 2014, Intel Corporation.
  */
 /*
  * lustre/mdt/mdt_hsm_cdt_actions.c
@@ -161,7 +162,7 @@ int mdt_agent_record_add(const struct lu_env *env,
                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, NULL);
+       rc = llog_cat_add(env, lctxt->loc_handle, &larr->arr_hdr, NULL);
        if (rc > 0)
                rc = 0;
 
@@ -313,7 +314,7 @@ int mdt_agent_llog_update_rec(const struct lu_env *env,
        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, NULL);
+                         NULL);
        larr->arr_hdr = saved_hdr;
        RETURN(rc);
 }
@@ -339,7 +340,7 @@ struct agent_action_iterator {
        int                      aai_magic;      /**< magic number */
        bool                     aai_eof;        /**< all done */
        struct lu_env            aai_env;        /**< lustre env for llog */
-       struct obd_device       *aai_obd;        /**< metadata device */
+       struct mdt_device       *aai_mdt;        /**< metadata device */
        struct llog_ctxt        *aai_ctxt;       /**< llog context */
        int                      aai_cat_index;  /**< cata idx already shown */
        int                      aai_index;      /**< idx in cata shown */
@@ -354,21 +355,22 @@ static void *mdt_hsm_actions_proc_start(struct seq_file *s, loff_t *pos)
        struct agent_action_iterator    *aai = s->private;
        ENTRY;
 
-       LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X",
+       LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X\n",
                 aai->aai_magic);
 
-       aai->aai_ctxt = llog_get_context(aai->aai_obd, LLOG_AGENT_ORIG_CTXT);
+       aai->aai_ctxt = llog_get_context(mdt2obd_dev(aai->aai_mdt),
+                                        LLOG_AGENT_ORIG_CTXT);
        if (aai->aai_ctxt == NULL || aai->aai_ctxt->loc_handle == NULL) {
                CERROR("llog_get_context() failed\n");
                RETURN(ERR_PTR(-ENOENT));
        }
 
-       CDEBUG(D_HSM, "llog succesfully initialized, start from "LPD64"\n",
+       CDEBUG(D_HSM, "llog successfully initialized, start from "LPD64"\n",
               *pos);
        /* first call = rewind */
        if (*pos == 0) {
                aai->aai_cat_index = 0;
-               aai->aai_index = 0;
+               aai->aai_index = -1;
                aai->aai_eof = false;
                *pos = 1;
        }
@@ -402,7 +404,7 @@ static int hsm_actions_show_cb(const struct lu_env *env,
        ENTRY;
 
        aai = s->private;
-       LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X",
+       LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X\n",
                 aai->aai_magic);
 
        /* if rec already printed => skip */
@@ -454,10 +456,11 @@ static int hsm_actions_show_cb(const struct lu_env *env,
 static int mdt_hsm_actions_proc_show(struct seq_file *s, void *v)
 {
        struct agent_action_iterator    *aai = s->private;
+       struct coordinator              *cdt = &aai->aai_mdt->mdt_coordinator;
        int                              rc;
        ENTRY;
 
-       LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X",
+       LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X\n",
                 aai->aai_magic);
 
        CDEBUG(D_HSM, "show from cat %d index %d eof=%d\n",
@@ -465,9 +468,11 @@ static int mdt_hsm_actions_proc_show(struct seq_file *s, void *v)
        if (aai->aai_eof)
                RETURN(0);
 
+       mutex_lock(&cdt->cdt_llog_lock);
        rc = llog_cat_process(&aai->aai_env, aai->aai_ctxt->loc_handle,
                              hsm_actions_show_cb, s,
                              aai->aai_cat_index, aai->aai_index + 1);
+       mutex_unlock(&cdt->cdt_llog_lock);
        if (rc == 0) /* all llog parsed */
                aai->aai_eof = true;
        if (rc == LLOG_PROC_BREAK) /* buffer full */
@@ -484,7 +489,7 @@ static void mdt_hsm_actions_proc_stop(struct seq_file *s, void *v)
        struct agent_action_iterator *aai = s->private;
        ENTRY;
 
-       LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X",
+       LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X\n",
                 aai->aai_magic);
 
        if (aai->aai_ctxt)
@@ -509,9 +514,6 @@ static int lprocfs_open_hsm_actions(struct inode *inode, struct file *file)
        struct mdt_device               *mdt;
        ENTRY;
 
-       if (LPROCFS_ENTRY_CHECK(PDE(inode)))
-               RETURN(-ENOENT);
-
        rc = seq_open(file, &mdt_hsm_actions_proc_ops);
        if (rc)
                RETURN(rc);
@@ -528,8 +530,8 @@ static int lprocfs_open_hsm_actions(struct inode *inode, struct file *file)
        /* mdt is saved in proc_dir_entry->data by
         * mdt_coordinator_procfs_init() calling lprocfs_register()
         */
-       mdt = (struct mdt_device *)PDE(inode)->data;
-       aai->aai_obd = mdt2obd_dev(mdt);
+       mdt = (struct mdt_device *)PDE_DATA(inode);
+       aai->aai_mdt = mdt;
        s = file->private_data;
        s->private = aai;
 
@@ -547,7 +549,7 @@ out:
 
 /**
  * lprocfs_release_hsm_actions() is called at end of /proc access.
- * It frees allocated ressources and calls cleanup lprocfs methods.
+ * It frees allocated resources and calls cleanup lprocfs methods.
  */
 static int lprocfs_release_hsm_actions(struct inode *inode, struct file *file)
 {