lightnvm: pblk: add trace events for line state changes
authorHans Holmberg <hans.holmberg@cnexlabs.com>
Tue, 9 Oct 2018 11:11:53 +0000 (13:11 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 9 Oct 2018 14:25:07 +0000 (08:25 -0600)
Add trace events for logging for line state changes.

Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
Signed-off-by: Matias Bjørling <mb@lightnvm.io>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/lightnvm/pblk-core.c
drivers/lightnvm/pblk-gc.c
drivers/lightnvm/pblk-init.c
drivers/lightnvm/pblk-recovery.c
drivers/lightnvm/pblk-trace.h

index 8a5158607467dac133f220c23ee25bc4ce3efe63..ef52c1647f881107f866476d8ffc4190b32d9fe4 100644 (file)
@@ -413,6 +413,9 @@ struct list_head *pblk_line_gc_list(struct pblk *pblk, struct pblk_line *line)
                }
        } else {
                line->state = PBLK_LINESTATE_CORRUPT;
+               trace_pblk_line_state(pblk_disk_name(pblk), line->id,
+                                       line->state);
+
                line->gc_group = PBLK_LINEGC_NONE;
                move_list =  &l_mg->corrupt_list;
                pblk_err(pblk, "corrupted vsc for line %d, vsc:%d (%d/%d/%d)\n",
@@ -1019,6 +1022,8 @@ static int pblk_line_init_metadata(struct pblk *pblk, struct pblk_line *line,
                spin_lock(&l_mg->free_lock);
                spin_lock(&line->lock);
                line->state = PBLK_LINESTATE_BAD;
+               trace_pblk_line_state(pblk_disk_name(pblk), line->id,
+                                       line->state);
                spin_unlock(&line->lock);
 
                list_add_tail(&line->list, &l_mg->bad_list);
@@ -1166,6 +1171,8 @@ static int pblk_line_init_bb(struct pblk *pblk, struct pblk_line *line,
                bitmap_weight(line->invalid_bitmap, lm->sec_per_line)) {
                spin_lock(&line->lock);
                line->state = PBLK_LINESTATE_BAD;
+               trace_pblk_line_state(pblk_disk_name(pblk), line->id,
+                                       line->state);
                spin_unlock(&line->lock);
 
                list_add_tail(&line->list, &l_mg->bad_list);
@@ -1218,6 +1225,8 @@ static int pblk_line_prepare(struct pblk *pblk, struct pblk_line *line)
        if (line->state == PBLK_LINESTATE_NEW) {
                blk_to_erase = pblk_prepare_new_line(pblk, line);
                line->state = PBLK_LINESTATE_FREE;
+               trace_pblk_line_state(pblk_disk_name(pblk), line->id,
+                                       line->state);
        } else {
                blk_to_erase = blk_in_line;
        }
@@ -1235,6 +1244,8 @@ static int pblk_line_prepare(struct pblk *pblk, struct pblk_line *line)
        }
 
        line->state = PBLK_LINESTATE_OPEN;
+       trace_pblk_line_state(pblk_disk_name(pblk), line->id,
+                               line->state);
 
        atomic_set(&line->left_eblks, blk_to_erase);
        atomic_set(&line->left_seblks, blk_to_erase);
@@ -1331,6 +1342,8 @@ retry:
        if (unlikely(bit >= lm->blk_per_line)) {
                spin_lock(&line->lock);
                line->state = PBLK_LINESTATE_BAD;
+               trace_pblk_line_state(pblk_disk_name(pblk), line->id,
+                                       line->state);
                spin_unlock(&line->lock);
 
                list_add_tail(&line->list, &l_mg->bad_list);
@@ -1650,6 +1663,8 @@ static void __pblk_line_put(struct pblk *pblk, struct pblk_line *line)
        spin_lock(&line->lock);
        WARN_ON(line->state != PBLK_LINESTATE_GC);
        line->state = PBLK_LINESTATE_FREE;
+       trace_pblk_line_state(pblk_disk_name(pblk), line->id,
+                                       line->state);
        line->gc_group = PBLK_LINEGC_NONE;
        pblk_line_free(line);
 
@@ -1779,7 +1794,6 @@ void pblk_line_close(struct pblk *pblk, struct pblk_line *line)
        WARN_ON(line->state != PBLK_LINESTATE_OPEN);
        line->state = PBLK_LINESTATE_CLOSED;
        move_list = pblk_line_gc_list(pblk, line);
-
        list_add_tail(&line->list, move_list);
 
        mempool_free(line->map_bitmap, l_mg->bitmap_pool);
@@ -1798,6 +1812,9 @@ void pblk_line_close(struct pblk *pblk, struct pblk_line *line)
 
        spin_unlock(&line->lock);
        spin_unlock(&l_mg->gc_lock);
+
+       trace_pblk_line_state(pblk_disk_name(pblk), line->id,
+                                       line->state);
 }
 
 void pblk_line_close_meta(struct pblk *pblk, struct pblk_line *line)
index 157c2567c9e8507d9194c476a3f9f10533f3b73b..b841d84c4342748cbf7f531415bca7166345937c 100644 (file)
  */
 
 #include "pblk.h"
+#include "pblk-trace.h"
 #include <linux/delay.h>
 
+
 static void pblk_gc_free_gc_rq(struct pblk_gc_rq *gc_rq)
 {
        if (gc_rq->data)
@@ -64,6 +66,8 @@ static void pblk_put_line_back(struct pblk *pblk, struct pblk_line *line)
        spin_lock(&line->lock);
        WARN_ON(line->state != PBLK_LINESTATE_GC);
        line->state = PBLK_LINESTATE_CLOSED;
+       trace_pblk_line_state(pblk_disk_name(pblk), line->id,
+                                       line->state);
        move_list = pblk_line_gc_list(pblk, line);
        spin_unlock(&line->lock);
 
@@ -405,6 +409,8 @@ void pblk_gc_free_full_lines(struct pblk *pblk)
                spin_lock(&line->lock);
                WARN_ON(line->state != PBLK_LINESTATE_CLOSED);
                line->state = PBLK_LINESTATE_GC;
+               trace_pblk_line_state(pblk_disk_name(pblk), line->id,
+                                       line->state);
                spin_unlock(&line->lock);
 
                list_del(&line->list);
@@ -451,6 +457,8 @@ next_gc_group:
                spin_lock(&line->lock);
                WARN_ON(line->state != PBLK_LINESTATE_CLOSED);
                line->state = PBLK_LINESTATE_GC;
+               trace_pblk_line_state(pblk_disk_name(pblk), line->id,
+                                       line->state);
                spin_unlock(&line->lock);
 
                list_del(&line->list);
index 4f2d9b5020281cb1a332a4f92a4e5f7143afc51f..fca37da162667fdf4cbbcd97042eb746f58048cd 100644 (file)
@@ -985,6 +985,9 @@ static int pblk_lines_init(struct pblk *pblk)
                        goto fail_free_lines;
 
                nr_free_chks += pblk_setup_line_meta(pblk, line, chunk_meta, i);
+
+               trace_pblk_line_state(pblk_disk_name(pblk), line->id,
+                                                               line->state);
        }
 
        if (!nr_free_chks) {
index cbcc0828517ecc7d6b561f41d487d8cad9c02d5c..0322ab915ddcb3fe43e18ded76fd6ebdd9a933d3 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include "pblk.h"
+#include "pblk-trace.h"
 
 int pblk_recov_check_emeta(struct pblk *pblk, struct line_emeta *emeta_buf)
 {
@@ -932,6 +933,8 @@ next:
 
                        spin_lock(&line->lock);
                        line->state = PBLK_LINESTATE_CLOSED;
+                       trace_pblk_line_state(pblk_disk_name(pblk), line->id,
+                                       line->state);
                        move_list = pblk_line_gc_list(pblk, line);
                        spin_unlock(&line->lock);
 
@@ -947,6 +950,9 @@ next:
                        if (open_lines > 1)
                                pblk_err(pblk, "failed to recover L2P\n");
 
+                       trace_pblk_line_state(pblk_disk_name(pblk), line->id,
+                                       line->state);
+
                        open_lines++;
                        line->meta_line = meta_line;
                        data_line = line;
index d985b729428ff0da60f6fbea7fd62ba3bafb0dee..f9aa9e25e4283b923db7132b21a5dc81962fe95f 100644 (file)
@@ -15,6 +15,16 @@ struct ppa_addr;
        { NVM_CHK_ST_OPEN,              "OPEN",         },      \
        { NVM_CHK_ST_OFFLINE,           "OFFLINE",      })
 
+#define show_line_state(state) __print_symbolic(state,         \
+       { PBLK_LINESTATE_NEW,           "NEW",          },      \
+       { PBLK_LINESTATE_FREE,          "FREE",         },      \
+       { PBLK_LINESTATE_OPEN,          "OPEN",         },      \
+       { PBLK_LINESTATE_CLOSED,        "CLOSED",       },      \
+       { PBLK_LINESTATE_GC,            "GC",           },      \
+       { PBLK_LINESTATE_BAD,           "BAD",          },      \
+       { PBLK_LINESTATE_CORRUPT,       "CORRUPT"       })
+
+
 TRACE_EVENT(pblk_chunk_state,
 
        TP_PROTO(const char *name, struct ppa_addr *ppa, int state),
@@ -41,6 +51,29 @@ TRACE_EVENT(pblk_chunk_state,
 
 );
 
+TRACE_EVENT(pblk_line_state,
+
+       TP_PROTO(const char *name, int line, int state),
+
+       TP_ARGS(name, line, state),
+
+       TP_STRUCT__entry(
+               __string(name, name)
+               __field(int, line)
+               __field(int, state);
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, name);
+               __entry->line = line;
+               __entry->state = state;
+       ),
+
+       TP_printk("dev=%s line=%d state=%s", __get_str(name),
+                       (int)__entry->line,
+                       show_line_state((int)__entry->state))
+
+);
 
 #endif /* !defined(_TRACE_PBLK_H) || defined(TRACE_HEADER_MULTI_READ) */