Whamcloud - gitweb
LU-4022 hsm: Set agent_actions start index from -1 79/7879/4
authorJinshan Xiong <jinshan.xiong@intel.com>
Tue, 8 Oct 2013 00:52:27 +0000 (17:52 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 18 Dec 2013 07:28:59 +0000 (07:28 +0000)
aai_index was set to start from 0 which will cause the first entry
to be skipped. Set it to -1 instead.

Also take llog lock in proc_show() to avoid it from being changed
during the iteration.

Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Change-Id: I09013dbf8a85d198496d8470746e773b388d9bee
Reviewed-on: http://review.whamcloud.com/7879
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Faccini Bruno <bruno.faccini@intel.com>
Reviewed-by: Aurelien Degremont <aurelien.degremont@cea.fr>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_hsm_cdt_actions.c

index eda547e..da7f5a9 100644 (file)
@@ -339,7 +339,7 @@ struct agent_action_iterator {
        int                      aai_magic;      /**< magic number */
        bool                     aai_eof;        /**< all done */
        struct lu_env            aai_env;        /**< lustre env for llog */
        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 */
        struct llog_ctxt        *aai_ctxt;       /**< llog context */
        int                      aai_cat_index;  /**< cata idx already shown */
        int                      aai_index;      /**< idx in cata shown */
@@ -357,7 +357,8 @@ static void *mdt_hsm_actions_proc_start(struct seq_file *s, loff_t *pos)
        LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X",
                 aai->aai_magic);
 
        LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X",
                 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));
        if (aai->aai_ctxt == NULL || aai->aai_ctxt->loc_handle == NULL) {
                CERROR("llog_get_context() failed\n");
                RETURN(ERR_PTR(-ENOENT));
@@ -368,7 +369,7 @@ static void *mdt_hsm_actions_proc_start(struct seq_file *s, loff_t *pos)
        /* first call = rewind */
        if (*pos == 0) {
                aai->aai_cat_index = 0;
        /* 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;
        }
                aai->aai_eof = false;
                *pos = 1;
        }
@@ -454,6 +455,7 @@ 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;
 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;
 
        int                              rc;
        ENTRY;
 
@@ -465,9 +467,11 @@ static int mdt_hsm_actions_proc_show(struct seq_file *s, void *v)
        if (aai->aai_eof)
                RETURN(0);
 
        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);
        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 */
        if (rc == 0) /* all llog parsed */
                aai->aai_eof = true;
        if (rc == LLOG_PROC_BREAK) /* buffer full */
@@ -529,7 +533,7 @@ static int lprocfs_open_hsm_actions(struct inode *inode, struct file *file)
         * mdt_coordinator_procfs_init() calling lprocfs_register()
         */
        mdt = (struct mdt_device *)PDE(inode)->data;
         * mdt_coordinator_procfs_init() calling lprocfs_register()
         */
        mdt = (struct mdt_device *)PDE(inode)->data;
-       aai->aai_obd = mdt2obd_dev(mdt);
+       aai->aai_mdt = mdt;
        s = file->private_data;
        s->private = aai;
 
        s = file->private_data;
        s->private = aai;