Whamcloud - gitweb
LU-3635 hsm: Fix ASSERT(inode->i_nlink > 0) 11/7111/2
authorAurelien Degremont <aurelien.degremont@cea.fr>
Fri, 19 Jul 2013 20:26:48 +0000 (22:26 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 29 Jul 2013 21:00:48 +0000 (21:00 +0000)
Two different handlers were setup to access Agent LLOG.
One for coordinator access, and one for /proc accesses.
Both tried to clean the LLOG content when closing it, leading to
crashes.
Both now used handler initialized by MDS.

Signed-off-by: Aurelien Degremont <aurelien.degremont@cea.fr>
Change-Id: Ia6f22e9173266faf56a25e77fa5c9ae1bf69dc71
Reviewed-on: http://review.whamcloud.com/7111
Tested-by: Hudson
Reviewed-by: jacques-Charles Lafoucriere <jacques-charles.lafoucriere@cea.fr>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: James Nunez <james.a.nunez@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_hsm_cdt_actions.c

index 37a4da1..5ee61bc 100644 (file)
@@ -340,7 +340,6 @@ struct agent_action_iterator {
        struct lu_env            aai_env;        /**< lustre env for llog */
        struct obd_device       *aai_obd;        /**< metadata device */
        struct llog_ctxt        *aai_ctxt;       /**< llog context */
        struct lu_env            aai_env;        /**< lustre env for llog */
        struct obd_device       *aai_obd;        /**< metadata device */
        struct llog_ctxt        *aai_ctxt;       /**< llog context */
-       struct llog_handle      *aai_llh;        /**< llog handle */
        int                      aai_index_done; /**< idx already shown */
        int                      aai_index_cb;   /**< current idx in loop cb */
        int                      aai_eof;        /**< all done */
        int                      aai_index_done; /**< idx already shown */
        int                      aai_index_cb;   /**< current idx in loop cb */
        int                      aai_eof;        /**< all done */
@@ -353,25 +352,16 @@ struct agent_action_iterator {
 static void *mdt_agent_actions_proc_start(struct seq_file *s, loff_t *pos)
 {
        struct agent_action_iterator    *aai = s->private;
 static void *mdt_agent_actions_proc_start(struct seq_file *s, loff_t *pos)
 {
        struct agent_action_iterator    *aai = s->private;
-       int                              rc;
        ENTRY;
 
        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);
        ENTRY;
 
        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);
-       if (aai->aai_ctxt == NULL) {
+       if ((aai->aai_ctxt == NULL) || (aai->aai_ctxt->loc_handle == NULL)) {
                CERROR("llog_get_context() failed\n");
                RETURN(ERR_PTR(-ENOENT));
        }
                CERROR("llog_get_context() failed\n");
                RETURN(ERR_PTR(-ENOENT));
        }
-       rc = llog_open(&aai->aai_env, aai->aai_ctxt, &aai->aai_llh, NULL,
-                      HSM_ACTIONS, LLOG_OPEN_EXISTS);
-       if (rc)
-               GOTO(err, rc);
-
-       rc = llog_init_handle(&aai->aai_env, aai->aai_llh, LLOG_F_IS_CAT, NULL);
-       if (rc)
-               GOTO(err, rc);
 
        CDEBUG(D_HSM, "llog succesfully initialized, start from "LPD64"\n",
               *pos);
 
        CDEBUG(D_HSM, "llog succesfully initialized, start from "LPD64"\n",
               *pos);
@@ -383,16 +373,6 @@ static void *mdt_agent_actions_proc_start(struct seq_file *s, loff_t *pos)
        }
 
        RETURN(aai);
        }
 
        RETURN(aai);
-err:
-       if (aai->aai_llh) {
-               llog_cat_close(&aai->aai_env, aai->aai_llh);
-               aai->aai_llh = NULL;
-       }
-
-       if (aai->aai_ctxt)
-               llog_ctxt_put(aai->aai_ctxt);
-
-       RETURN(ERR_PTR(rc));
 }
 
 /**
 }
 
 /**
@@ -492,7 +472,7 @@ static int mdt_agent_actions_proc_show(struct seq_file *s, void *v)
                RETURN(0);
 
        aai->aai_index_cb = 0;
                RETURN(0);
 
        aai->aai_index_cb = 0;
-       rc = llog_cat_process(&aai->aai_env, aai->aai_llh,
+       rc = llog_cat_process(&aai->aai_env, aai->aai_ctxt->loc_handle,
                              agent_actions_show_cb, s, 0, 0);
        /* was all llog parsed? */
        if (rc == 0)
                              agent_actions_show_cb, s, 0, 0);
        /* was all llog parsed? */
        if (rc == 0)
@@ -516,12 +496,9 @@ static void mdt_agent_actions_proc_stop(struct seq_file *s, void *v)
        LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X",
                 aai->aai_magic);
 
        LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X",
                 aai->aai_magic);
 
-       if (aai->aai_llh) {
-               llog_cat_close(&aai->aai_env, aai->aai_llh);
-               aai->aai_llh = NULL;
-       }
        if (aai->aai_ctxt)
                llog_ctxt_put(aai->aai_ctxt);
        if (aai->aai_ctxt)
                llog_ctxt_put(aai->aai_ctxt);
+
        EXIT;
        return;
 }
        EXIT;
        return;
 }
@@ -559,7 +536,6 @@ static int lprocfs_open_agent_actions(struct inode *inode, struct file *file)
        if (rc)
                GOTO(err, rc);
 
        if (rc)
                GOTO(err, rc);
 
-       aai->aai_llh = NULL;
        /* mdt is saved in proc_dir_entry->data by
         * mdt_coordinator_procfs_init() calling lprocfs_register()
         */
        /* mdt is saved in proc_dir_entry->data by
         * mdt_coordinator_procfs_init() calling lprocfs_register()
         */