Whamcloud - gitweb
LU-13543 lustre: update *pos in seq_file .next functions 57/40757/4
authorMikhail Pershin <mpershin@whamcloud.com>
Wed, 25 Nov 2020 19:45:38 +0000 (22:45 +0300)
committerOleg Drokin <green@whamcloud.com>
Thu, 3 Dec 2020 17:58:12 +0000 (17:58 +0000)
Patch fixes mdt_hsm_actions_debugfs seq operations to work with
new seq file logic in newer kernels

Meanwhile it finishes remaining work originating in LU-13985 which
updates ->next functions to always increment *pos as it is expected
by kernel

Test-Parameters: clientdistro=el8.2 serverdistro=el8.2 testlist=sanity-hsm
Signed-off-by: Mikhail Pershin <mpershin@whamcloud.com>
Change-Id: I4f077b633fbf7d420bfda10cce6b0141cef07761
Reviewed-on: https://review.whamcloud.com/40757
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Neil Brown <neilb@suse.de>
lustre/lod/lod_pool.c
lustre/lod/lproc_lod.c
lustre/mdt/mdt_hsm_cdt_actions.c

index 55932d5..b59b0df 100644 (file)
@@ -165,8 +165,9 @@ static void *pool_proc_next(struct seq_file *seq, void *v, loff_t *pos)
 
        LASSERTF(iter->lpi_magic == POOL_IT_MAGIC, "%08X\n", iter->lpi_magic);
 
 
        LASSERTF(iter->lpi_magic == POOL_IT_MAGIC, "%08X\n", iter->lpi_magic);
 
+       (*pos)++;
        /* test if end of file */
        /* test if end of file */
-       if (*pos >= pool_tgt_count(iter->lpi_pool))
+       if (*pos > pool_tgt_count(iter->lpi_pool))
                return NULL;
 
        OBD_FAIL_TIMEOUT(OBD_FAIL_OST_LIST_ASSERT, cfs_fail_val);
                return NULL;
 
        OBD_FAIL_TIMEOUT(OBD_FAIL_OST_LIST_ASSERT, cfs_fail_val);
@@ -178,7 +179,7 @@ static void *pool_proc_next(struct seq_file *seq, void *v, loff_t *pos)
                iter->lpi_idx = prev_idx; /* we stay on the last entry */
                return NULL;
        }
                iter->lpi_idx = prev_idx; /* we stay on the last entry */
                return NULL;
        }
-       (*pos)++;
+
        /* return != NULL to continue */
        return iter;
 }
        /* return != NULL to continue */
        return iter;
 }
index 578305f..1ca3f5c 100644 (file)
@@ -835,11 +835,12 @@ static void *lod_tgts_seq_next(struct seq_file *p, void *v, loff_t *pos,
        struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
                                            &lod->lod_ost_descs;
 
        struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
                                            &lod->lod_ost_descs;
 
-       if (*pos >= ltd->ltd_tgts_size - 1)
+       (*pos)++;
+       if (*pos > ltd->ltd_tgts_size - 1)
                return NULL;
 
        *pos = find_next_bit(ltd->ltd_tgt_bitmap,
                return NULL;
 
        *pos = find_next_bit(ltd->ltd_tgt_bitmap,
-                            ltd->ltd_tgts_size, *pos + 1);
+                            ltd->ltd_tgts_size, *pos);
        if (*pos < ltd->ltd_tgts_size)
                return LTD_TGT(ltd, *pos);
        else
        if (*pos < ltd->ltd_tgts_size)
                return LTD_TGT(ltd, *pos);
        else
index e220134..7ae3762 100644 (file)
@@ -482,7 +482,8 @@ struct agent_action_iterator {
  */
 static void *mdt_hsm_actions_debugfs_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",
        ENTRY;
 
        LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X\n",
@@ -502,7 +503,6 @@ static void *mdt_hsm_actions_debugfs_start(struct seq_file *s, loff_t *pos)
                aai->aai_cat_index = 0;
                aai->aai_index = 0;
                aai->aai_eof = false;
                aai->aai_cat_index = 0;
                aai->aai_index = 0;
                aai->aai_eof = false;
-               *pos = 1;
        }
 
        if (aai->aai_eof)
        }
 
        if (aai->aai_eof)
@@ -514,7 +514,12 @@ static void *mdt_hsm_actions_debugfs_start(struct seq_file *s, loff_t *pos)
 static void *mdt_hsm_actions_debugfs_next(struct seq_file *s, void *v,
                                         loff_t *pos)
 {
 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);
 }
 
 /**
 }
 
 /**
@@ -525,14 +530,14 @@ static int hsm_actions_show_cb(const struct lu_env *env,
                                 struct llog_rec_hdr *hdr,
                                 void *data)
 {
                                 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;
 
        ENTRY;
 
-       aai = s->private;
        LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X\n",
                 aai->aai_magic);
 
        LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X\n",
                 aai->aai_magic);
 
@@ -577,9 +582,10 @@ static int hsm_actions_show_cb(const struct lu_env *env,
  */
 static int mdt_hsm_actions_debugfs_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",
        ENTRY;
 
        LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X\n",
@@ -599,6 +605,7 @@ static int mdt_hsm_actions_debugfs_show(struct seq_file *s, void *v)
                aai->aai_eof = true;
        if (rc == LLOG_PROC_BREAK) /* buffer full */
                rc = 0;
                aai->aai_eof = true;
        if (rc == LLOG_PROC_BREAK) /* buffer full */
                rc = 0;
+
        RETURN(rc);
 }
 
        RETURN(rc);
 }
 
@@ -609,6 +616,7 @@ static int mdt_hsm_actions_debugfs_show(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;
 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",
        ENTRY;
 
        LASSERTF(aai->aai_magic == AGENT_ACTIONS_IT_MAGIC, "%08X\n",