Whamcloud - gitweb
LU-13543 lustre: update *pos in seq_file .next functions
[fs/lustre-release.git] / lustre / mdt / mdt_hsm_cdt_actions.c
index 93c4a05..7ae3762 100644 (file)
@@ -289,12 +289,10 @@ int mdt_agent_record_add(const struct lu_env *env, struct mdt_device *mdt,
        /* 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++;
-               larr->arr_hai.hai_cookie = cdt->cdt_last_cookie;
-       }
+       else
+               larr->arr_hai.hai_cookie = cdt->cdt_last_cookie++;
 
        rc = llog_cat_add(env, lctxt->loc_handle, &larr->arr_hdr, NULL);
        if (rc > 0)
@@ -482,9 +480,10 @@ struct agent_action_iterator {
  * seq_file method called to start access to /proc file
  * get llog context + llog handle
  */
-static void *mdt_hsm_actions_proc_start(struct seq_file *s, loff_t *pos)
+static void *mdt_hsm_actions_debugfs_start(struct seq_file *s, loff_t *pos)
 {
-       struct agent_action_iterator    *aai = s->private;
+       struct agent_action_iterator *aai = s->private;
+
        ENTRY;
 
        LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X\n",
@@ -504,7 +503,6 @@ static void *mdt_hsm_actions_proc_start(struct seq_file *s, loff_t *pos)
                aai->aai_cat_index = 0;
                aai->aai_index = 0;
                aai->aai_eof = false;
-               *pos = 1;
        }
 
        if (aai->aai_eof)
@@ -513,10 +511,15 @@ static void *mdt_hsm_actions_proc_start(struct seq_file *s, loff_t *pos)
        RETURN(aai);
 }
 
-static void *mdt_hsm_actions_proc_next(struct seq_file *s, void *v,
+static void *mdt_hsm_actions_debugfs_next(struct seq_file *s, void *v,
                                         loff_t *pos)
 {
-       RETURN(NULL);
+       struct agent_action_iterator *aai = s->private;
+
+       (*pos)++;
+       if (aai->aai_eof)
+               RETURN(NULL);
+       RETURN(aai);
 }
 
 /**
@@ -527,14 +530,14 @@ static int hsm_actions_show_cb(const struct lu_env *env,
                                 struct llog_rec_hdr *hdr,
                                 void *data)
 {
-       struct llog_agent_req_rec    *larr = (struct llog_agent_req_rec *)hdr;
-       struct seq_file              *s = data;
-       struct agent_action_iterator *aai;
-       int                           sz;
-       char                          buf[12];
+       struct llog_agent_req_rec *larr = (struct llog_agent_req_rec *)hdr;
+       struct seq_file *s = data;
+       struct agent_action_iterator *aai = s->private;
+       int sz;
+       char buf[12];
+
        ENTRY;
 
-       aai = s->private;
        LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X\n",
                 aai->aai_magic);
 
@@ -573,15 +576,16 @@ static int hsm_actions_show_cb(const struct lu_env *env,
 }
 
 /**
- * mdt_hsm_actions_proc_show() is called at for each seq record
+ * mdt_hsm_actions_debugfs_show() is called at for each seq record
  * process the llog, with a cb which fill the file_seq buffer
  * to be faster, one show will fill multiple records
  */
-static int mdt_hsm_actions_proc_show(struct seq_file *s, void *v)
+static int mdt_hsm_actions_debugfs_show(struct seq_file *s, void *v)
 {
-       struct agent_action_iterator    *aai = s->private;
-       struct coordinator              *cdt = &aai->aai_mdt->mdt_coordinator;
-       int                              rc;
+       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\n",
@@ -601,6 +605,7 @@ static int mdt_hsm_actions_proc_show(struct seq_file *s, void *v)
                aai->aai_eof = true;
        if (rc == LLOG_PROC_BREAK) /* buffer full */
                rc = 0;
+
        RETURN(rc);
 }
 
@@ -608,9 +613,10 @@ static int mdt_hsm_actions_proc_show(struct seq_file *s, void *v)
  * seq_file method called to stop access to /proc file
  * clean + put llog context
  */
-static void mdt_hsm_actions_proc_stop(struct seq_file *s, void *v)
+static void mdt_hsm_actions_debugfs_stop(struct seq_file *s, void *v)
 {
        struct agent_action_iterator *aai = s->private;
+
        ENTRY;
 
        LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X\n",
@@ -620,17 +626,16 @@ static void mdt_hsm_actions_proc_stop(struct seq_file *s, void *v)
                llog_ctxt_put(aai->aai_ctxt);
 
        EXIT;
-       return;
 }
 
-static const struct seq_operations mdt_hsm_actions_proc_ops = {
-       .start  = mdt_hsm_actions_proc_start,
-       .next   = mdt_hsm_actions_proc_next,
-       .show   = mdt_hsm_actions_proc_show,
-       .stop   = mdt_hsm_actions_proc_stop,
+static const struct seq_operations mdt_hsm_actions_debugfs_ops = {
+       .start  = mdt_hsm_actions_debugfs_start,
+       .next   = mdt_hsm_actions_debugfs_next,
+       .show   = mdt_hsm_actions_debugfs_show,
+       .stop   = mdt_hsm_actions_debugfs_stop,
 };
 
-static int lprocfs_open_hsm_actions(struct inode *inode, struct file *file)
+static int ldebugfs_open_hsm_actions(struct inode *inode, struct file *file)
 {
        struct agent_action_iterator    *aai;
        struct seq_file                 *s;
@@ -638,7 +643,7 @@ static int lprocfs_open_hsm_actions(struct inode *inode, struct file *file)
        struct mdt_device               *mdt;
        ENTRY;
 
-       rc = seq_open(file, &mdt_hsm_actions_proc_ops);
+       rc = seq_open(file, &mdt_hsm_actions_debugfs_ops);
        if (rc)
                RETURN(rc);
 
@@ -651,10 +656,11 @@ static int lprocfs_open_hsm_actions(struct inode *inode, struct file *file)
        if (rc)
                GOTO(err, rc);
 
-       /* mdt is saved in proc_dir_entry->data by
-        * mdt_coordinator_procfs_init() calling lprocfs_register()
+       /* mdt is saved in seq_file->data by
+        * mdt_coordinator_tunables_init() calling
+        * debugfs_register()
         */
-       mdt = (struct mdt_device *)PDE_DATA(inode);
+       mdt = inode->i_private;
        aai->aai_mdt = mdt;
        s = file->private_data;
        s->private = aai;
@@ -662,7 +668,7 @@ static int lprocfs_open_hsm_actions(struct inode *inode, struct file *file)
        GOTO(out, rc = 0);
 
 err:
-       lprocfs_seq_release(inode, file);
+       seq_release(inode, file);
        if (aai && aai->aai_env.le_ses)
                OBD_FREE_PTR(aai->aai_env.le_ses);
        if (aai)
@@ -672,10 +678,10 @@ out:
 }
 
 /**
- * lprocfs_release_hsm_actions() is called at end of /proc access.
+ * ldebugfs_release_hsm_actions() is called at end of /proc access.
  * It frees allocated resources and calls cleanup lprocfs methods.
  */
-static int lprocfs_release_hsm_actions(struct inode *inode, struct file *file)
+static int ldebugfs_release_hsm_actions(struct inode *inode, struct file *file)
 {
        struct seq_file                 *seq = file->private_data;
        struct agent_action_iterator    *aai = seq->private;
@@ -685,14 +691,14 @@ static int lprocfs_release_hsm_actions(struct inode *inode, struct file *file)
                OBD_FREE_PTR(aai);
        }
 
-       return lprocfs_seq_release(inode, file);
+       return seq_release(inode, file);
 }
 
 /* Methods to access HSM action list LLOG through /proc */
 const struct file_operations mdt_hsm_actions_fops = {
        .owner          = THIS_MODULE,
-       .open           = lprocfs_open_hsm_actions,
+       .open           = ldebugfs_open_hsm_actions,
        .read           = seq_read,
        .llseek         = seq_lseek,
-       .release        = lprocfs_release_hsm_actions,
+       .release        = ldebugfs_release_hsm_actions,
 };