summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fs/fs-writeback.c7
-rw-r--r--include/linux/backing-dev-defs.h2
-rw-r--r--mm/page-writeback.c3
3 files changed, 11 insertions, 1 deletions
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 0a90dc557748..bbccf68b38db 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -99,6 +99,8 @@ static bool wb_io_lists_populated(struct bdi_writeback *wb)
return false;
} else {
set_bit(WB_has_dirty_io, &wb->state);
+ atomic_long_add(wb->avg_write_bandwidth,
+ &wb->bdi->tot_write_bandwidth);
return true;
}
}
@@ -106,8 +108,11 @@ static bool wb_io_lists_populated(struct bdi_writeback *wb)
static void wb_io_lists_depopulated(struct bdi_writeback *wb)
{
if (wb_has_dirty_io(wb) && list_empty(&wb->b_dirty) &&
- list_empty(&wb->b_io) && list_empty(&wb->b_more_io))
+ list_empty(&wb->b_io) && list_empty(&wb->b_more_io)) {
clear_bit(WB_has_dirty_io, &wb->state);
+ atomic_long_sub(wb->avg_write_bandwidth,
+ &wb->bdi->tot_write_bandwidth);
+ }
}
/**
diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h
index 7a94b7850b7c..d631a61f4023 100644
--- a/include/linux/backing-dev-defs.h
+++ b/include/linux/backing-dev-defs.h
@@ -142,6 +142,8 @@ struct backing_dev_info {
unsigned int min_ratio;
unsigned int max_ratio, max_prop_frac;
+ atomic_long_t tot_write_bandwidth; /* sum of active avg_write_bw */
+
struct bdi_writeback wb; /* the root writeback info for this bdi */
struct bdi_writeback_congested wb_congested; /* its congested state */
#ifdef CONFIG_CGROUP_WRITEBACK
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index e31dea94d116..c95eb24dd652 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -881,6 +881,9 @@ static void wb_update_write_bandwidth(struct bdi_writeback *wb,
avg += (old - avg) >> 3;
out:
+ if (wb_has_dirty_io(wb))
+ atomic_long_add(avg - wb->avg_write_bandwidth,
+ &wb->bdi->tot_write_bandwidth);
wb->write_bandwidth = bw;
wb->avg_write_bandwidth = avg;
}