@@ -1112,6 +1112,7 @@ enum page_type {
META_FLUSH,
IPU, /* the below types are used by tracepoints only. */
OPU,
+ DISCARD, /* used by iostat */
};
enum temp_type {
@@ -235,7 +235,7 @@ void iostat_update_and_unbind_ctx(struct bio *bio)
{
struct bio_iostat_ctx *iostat_ctx = bio->bi_private;
- if (op_is_write(bio_op(bio)))
+ if (op_is_write(bio_op(bio)) && !op_is_discard(bio_op(bio)))
bio->bi_private = iostat_ctx->sbi;
else
bio->bi_private = iostat_ctx->iostat_private;
@@ -251,7 +251,9 @@ void iostat_update_submit_ctx(struct bio *bio, enum page_type type)
iostat_ctx->submit_ts = jiffies;
- if (op_is_write(bio_op(bio))) {
+ if (type == DISCARD) {
+ lat_type = DISCARD_LAT;
+ } else if (op_is_write(bio_op(bio))) {
lat_type = bio->bi_opf & REQ_SYNC ?
WRITE_SYNC_DATA_LAT : WRITE_ASYNC_DATA_LAT;
lat_type = (enum iostat_lat_type)(lat_type + type);
@@ -1100,9 +1100,12 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi,
static void f2fs_submit_discard_endio(struct bio *bio)
{
- struct discard_cmd *dc = (struct discard_cmd *)bio->bi_private;
+ struct discard_cmd *dc;
unsigned long flags;
+ iostat_update_and_unbind_ctx(bio);
+ dc = bio->bi_private;
+
spin_lock_irqsave(&dc->lock, flags);
if (!dc->error)
dc->error = blk_status_to_errno(bio->bi_status);
@@ -1276,6 +1279,9 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
bio->bi_private = dc;
bio->bi_end_io = f2fs_submit_discard_endio;
bio->bi_opf |= flag;
+
+ iostat_alloc_and_bind_ctx(sbi, bio, dc);
+ iostat_update_submit_ctx(bio, DISCARD);
submit_bio(bio);
atomic_inc(&dcc->issued_discard);
@@ -2078,6 +2078,9 @@ TRACE_EVENT(f2fs_iostat_latency,
__field(unsigned int, m_wr_as_peak)
__field(unsigned int, m_wr_as_avg)
__field(unsigned int, m_wr_as_cnt)
+ __field(unsigned int, discard_peak)
+ __field(unsigned int, discard_avg)
+ __field(unsigned int, discard_cnt)
),
TP_fast_assign(
@@ -2109,6 +2112,9 @@ TRACE_EVENT(f2fs_iostat_latency,
__entry->m_wr_as_peak = iostat_lat[WRITE_ASYNC_META_LAT].peak_lat;
__entry->m_wr_as_avg = iostat_lat[WRITE_ASYNC_META_LAT].avg_lat;
__entry->m_wr_as_cnt = iostat_lat[WRITE_ASYNC_META_LAT].cnt;
+ __entry->discard_peak = iostat_lat[DISCARD_LAT].peak_lat;
+ __entry->discard_avg = iostat_lat[DISCARD_LAT].avg_lat;
+ __entry->discard_cnt = iostat_lat[DISCARD_LAT].cnt;
),
TP_printk("dev = (%d,%d), "
@@ -2116,7 +2122,8 @@ TRACE_EVENT(f2fs_iostat_latency,
"rd_data [%u/%u/%u], rd_node [%u/%u/%u], rd_meta [%u/%u/%u], "
"wr_sync_data [%u/%u/%u], wr_sync_node [%u/%u/%u], "
"wr_sync_meta [%u/%u/%u], wr_async_data [%u/%u/%u], "
- "wr_async_node [%u/%u/%u], wr_async_meta [%u/%u/%u]",
+ "wr_async_node [%u/%u/%u], wr_async_meta [%u/%u/%u], "
+ "discard [%u/%u/%u]",
show_dev(__entry->dev),
__entry->d_rd_peak, __entry->d_rd_avg, __entry->d_rd_cnt,
__entry->n_rd_peak, __entry->n_rd_avg, __entry->n_rd_cnt,
@@ -2126,7 +2133,8 @@ TRACE_EVENT(f2fs_iostat_latency,
__entry->m_wr_s_peak, __entry->m_wr_s_avg, __entry->m_wr_s_cnt,
__entry->d_wr_as_peak, __entry->d_wr_as_avg, __entry->d_wr_as_cnt,
__entry->n_wr_as_peak, __entry->n_wr_as_avg, __entry->n_wr_as_cnt,
- __entry->m_wr_as_peak, __entry->m_wr_as_avg, __entry->m_wr_as_cnt)
+ __entry->m_wr_as_peak, __entry->m_wr_as_avg, __entry->m_wr_as_cnt,
+ __entry->discard_peak, __entry->discard_avg, __entry->discard_cnt)
);
#endif