[PATCH 07/14] writeback: Provide a function to get bdi from bdi_writeback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When we switch to per-sb dirty tracking it won't be so trivial to
get bdi from bdi_writeback so provide a helper function for that.

Signed-off-by: Jan Kara <jack@xxxxxxx>
---
 fs/fs-writeback.c                | 25 +++++++++++++------------
 include/linux/backing-dev.h      |  5 +++++
 include/trace/events/writeback.h |  2 +-
 3 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 4bf1db730b40..4247e1f7cb03 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -637,7 +637,7 @@ static long writeback_inodes(struct bdi_writeback *wb,
 		inode->i_state |= I_SYNC;
 		spin_unlock(&inode->i_lock);
 
-		write_chunk = writeback_chunk_size(wb->bdi, work);
+		write_chunk = writeback_chunk_size(wb_bdi(wb), work);
 		wbc.nr_to_write = write_chunk;
 		wbc.pages_skipped = 0;
 
@@ -695,7 +695,7 @@ static bool over_bground_thresh(struct backing_dev_info *bdi)
 static void wb_update_bandwidth(struct bdi_writeback *wb,
 				unsigned long start_time)
 {
-	struct backing_dev_info *bdi = wb->bdi;
+	struct backing_dev_info *bdi = wb_bdi(wb);
  
 	spin_lock_bh(&bdi->wb_lock);
 	__bdi_update_bandwidth(bdi, 0, 0, 0, 0, 0, start_time);
@@ -724,6 +724,7 @@ static long wb_writeback(struct bdi_writeback *wb,
 	long nr_pages = work->nr_pages;
 	unsigned long oldest_jif;
 	long progress;
+	struct backing_dev_info *bdi = wb_bdi(wb);
 
 	oldest_jif = jiffies;
 	work->older_than_this = &oldest_jif;
@@ -743,14 +744,14 @@ static long wb_writeback(struct bdi_writeback *wb,
 		 * after the other works are all done.
 		 */
 		if ((work->for_background || work->for_kupdate) &&
-		    !list_empty(&wb->bdi->work_list))
+		    !list_empty(&bdi->work_list))
 			break;
 
 		/*
 		 * For background writeout, stop when we are below the
 		 * background dirty threshold
 		 */
-		if (work->for_background && !over_bground_thresh(wb->bdi))
+		if (work->for_background && !over_bground_thresh(bdi))
 			break;
 
 		/*
@@ -765,11 +766,11 @@ static long wb_writeback(struct bdi_writeback *wb,
 		} else if (work->for_background)
 			oldest_jif = jiffies;
 
-		trace_writeback_start(wb->bdi, work);
+		trace_writeback_start(bdi, work);
 		if (list_empty(&wb->b_io))
 			queue_io(wb, work);
 		progress = writeback_inodes(wb, work);
-		trace_writeback_written(wb->bdi, work);
+		trace_writeback_written(bdi, work);
 
 		wb_update_bandwidth(wb, wb_start);
 
@@ -825,7 +826,7 @@ static unsigned long get_nr_dirty_pages(void)
 
 static long wb_check_background_flush(struct bdi_writeback *wb)
 {
-	if (over_bground_thresh(wb->bdi)) {
+	if (over_bground_thresh(wb_bdi(wb))) {
 
 		struct wb_writeback_work work = {
 			.nr_pages	= LONG_MAX,
@@ -852,12 +853,12 @@ static long wb_check_old_data_flush(struct bdi_writeback *wb)
 	if (!dirty_writeback_interval)
 		return 0;
 
-	expired = wb->bdi->last_old_flush +
+	expired = wb_bdi(wb)->last_old_flush +
 			msecs_to_jiffies(dirty_writeback_interval * 10);
 	if (time_before(jiffies, expired))
 		return 0;
 
-	wb->bdi->last_old_flush = jiffies;
+	wb_bdi(wb)->last_old_flush = jiffies;
 	nr_pages = get_nr_dirty_pages();
 
 	if (nr_pages) {
@@ -880,11 +881,11 @@ static long wb_check_old_data_flush(struct bdi_writeback *wb)
  */
 static long wb_do_writeback(struct bdi_writeback *wb)
 {
-	struct backing_dev_info *bdi = wb->bdi;
+	struct backing_dev_info *bdi = wb_bdi(wb);
 	struct wb_writeback_work *work;
 	long wrote = 0;
 
-	set_bit(BDI_writeback_running, &wb->bdi->state);
+	set_bit(BDI_writeback_running, &bdi->state);
 	while ((work = get_next_work_item(bdi)) != NULL) {
 
 		trace_writeback_exec(bdi, work);
@@ -906,7 +907,7 @@ static long wb_do_writeback(struct bdi_writeback *wb)
 	 */
 	wrote += wb_check_old_data_flush(wb);
 	wrote += wb_check_background_flush(wb);
-	clear_bit(BDI_writeback_running, &wb->bdi->state);
+	clear_bit(BDI_writeback_running, &bdi->state);
 
 	return wrote;
 }
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 87096947af68..5bfe30d6f01f 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -110,6 +110,11 @@ struct backing_dev_info {
 #endif
 };
 
+static inline struct backing_dev_info *wb_bdi(struct bdi_writeback *wb)
+{
+	return wb->bdi;
+}
+
 int __must_check bdi_init(struct backing_dev_info *bdi);
 void bdi_destroy(struct backing_dev_info *bdi);
 
diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index 102e2ad9f90f..2f04fdeebc0c 100644
--- a/include/trace/events/writeback.h
+++ b/include/trace/events/writeback.h
@@ -288,7 +288,7 @@ TRACE_EVENT(writeback_queue_io,
 	),
 	TP_fast_assign(
 		unsigned long *older_than_this = work->older_than_this;
-		strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
+		strncpy(__entry->name, dev_name(wb_bdi(wb)->dev), 32);
 		__entry->older	= older_than_this ?  *older_than_this : 0;
 		__entry->age	= older_than_this ?
 				  (jiffies - *older_than_this) * 1000 / HZ : -1;
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux