[PATCH 09/14] writeback: Switch some function arguments from bdi_writeback to bdi

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

 



Some functions take struct bdi_writeback as an argument. However they
need to touch corresponding bdi anyway. So just pass bdi directly
instead which somewhat simplifies the code. Also rename the functions to
match better new arguments.

Signed-off-by: Jan Kara <jack@xxxxxxx>
---
 fs/fs-writeback.c | 48 ++++++++++++++++++++++--------------------------
 1 file changed, 22 insertions(+), 26 deletions(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index c8806c81e37c..b7d05c0aad14 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -35,7 +35,7 @@
 #define MIN_WRITEBACK_PAGES	(4096UL >> (PAGE_CACHE_SHIFT - 10))
 
 /*
- * Passed into wb_writeback(), essentially a subset of writeback_control
+ * Passed into bdi_writeback(), essentially a subset of writeback_control
  */
 struct wb_writeback_work {
 	long nr_pages;
@@ -543,7 +543,7 @@ static long writeback_chunk_size(struct backing_dev_info *bdi,
 	 *
 	 * The intended call sequence for WB_SYNC_ALL writeback is:
 	 *
-	 *      wb_writeback()
+	 *      bdi_writeback()
 	 *          writeback_inodes()       <== called only once
 	 *              write_cache_pages()  <== called once for each inode
 	 *                   (quickly) tag currently dirty pages
@@ -658,7 +658,7 @@ static long writeback_inodes(struct bdi_writeback *wb,
 		spin_unlock(&inode->i_lock);
 		cond_resched_lock(&wb->list_lock);
 		/*
-		 * bail out to wb_writeback() often enough to check
+		 * bail out to bdi_writeback() often enough to check
 		 * background threshold and other termination conditions.
 		 */
 		if (wrote) {
@@ -692,11 +692,9 @@ static bool over_bground_thresh(struct backing_dev_info *bdi)
  * Called under wb->list_lock. If there are multiple wb per bdi,
  * only the flusher working on the first wb should do it.
  */
-static void wb_update_bandwidth(struct bdi_writeback *wb,
-				unsigned long start_time)
+static void update_bandwidth(struct backing_dev_info *bdi,
+			     unsigned long start_time)
 {
-	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);
 	spin_unlock_bh(&bdi->wb_lock);
@@ -717,14 +715,14 @@ static void wb_update_bandwidth(struct bdi_writeback *wb,
  * older_than_this takes precedence over nr_to_write.  So we'll only write back
  * all dirty pages if they are all attached to "old" mappings.
  */
-static long wb_writeback(struct bdi_writeback *wb,
-			 struct wb_writeback_work *work)
+static long bdi_writeback(struct backing_dev_info *bdi,
+			  struct wb_writeback_work *work)
 {
 	unsigned long wb_start = jiffies;
 	long nr_pages = work->nr_pages;
 	unsigned long oldest_jif;
 	long progress;
-	struct backing_dev_info *bdi = wb_bdi(wb);
+	struct bdi_writeback *wb = &bdi->wb;
 
 	oldest_jif = jiffies;
 	work->older_than_this = &oldest_jif;
@@ -772,7 +770,7 @@ static long wb_writeback(struct bdi_writeback *wb,
 		progress = writeback_inodes(wb, work);
 		trace_writeback_written(bdi, work);
 
-		wb_update_bandwidth(wb, wb_start);
+		update_bandwidth(bdi, wb_start);
 
 		/*
 		 * Did we write something? Try for more
@@ -824,9 +822,9 @@ static unsigned long get_nr_dirty_pages(void)
 		get_nr_dirty_inodes();
 }
 
-static long wb_check_background_flush(struct bdi_writeback *wb)
+static long wb_check_background_flush(struct backing_dev_info *bdi)
 {
-	if (over_bground_thresh(wb_bdi(wb))) {
+	if (over_bground_thresh(bdi)) {
 
 		struct wb_writeback_work work = {
 			.nr_pages	= LONG_MAX,
@@ -836,13 +834,13 @@ static long wb_check_background_flush(struct bdi_writeback *wb)
 			.reason		= WB_REASON_BACKGROUND,
 		};
 
-		return wb_writeback(wb, &work);
+		return bdi_writeback(bdi, &work);
 	}
 
 	return 0;
 }
 
-static long wb_check_old_data_flush(struct bdi_writeback *wb)
+static long wb_check_old_data_flush(struct backing_dev_info *bdi)
 {
 	unsigned long expired;
 	long nr_pages;
@@ -853,12 +851,12 @@ static long wb_check_old_data_flush(struct bdi_writeback *wb)
 	if (!dirty_writeback_interval)
 		return 0;
 
-	expired = wb_bdi(wb)->last_old_flush +
+	expired = bdi->last_old_flush +
 			msecs_to_jiffies(dirty_writeback_interval * 10);
 	if (time_before(jiffies, expired))
 		return 0;
 
-	wb_bdi(wb)->last_old_flush = jiffies;
+	bdi->last_old_flush = jiffies;
 	nr_pages = get_nr_dirty_pages();
 
 	if (nr_pages) {
@@ -870,7 +868,7 @@ static long wb_check_old_data_flush(struct bdi_writeback *wb)
 			.reason		= WB_REASON_PERIODIC,
 		};
 
-		return wb_writeback(wb, &work);
+		return bdi_writeback(bdi, &work);
 	}
 
 	return 0;
@@ -879,9 +877,8 @@ static long wb_check_old_data_flush(struct bdi_writeback *wb)
 /*
  * Retrieve work items and do the writeback they describe
  */
-static long wb_do_writeback(struct bdi_writeback *wb)
+static long bdi_process_work_items(struct backing_dev_info *bdi)
 {
-	struct backing_dev_info *bdi = wb_bdi(wb);
 	struct wb_writeback_work *work;
 	long wrote = 0;
 
@@ -890,7 +887,7 @@ static long wb_do_writeback(struct bdi_writeback *wb)
 
 		trace_writeback_exec(bdi, work);
 
-		wrote += wb_writeback(wb, work);
+		wrote += bdi_writeback(bdi, work);
 
 		/*
 		 * Notify the caller of completion if this is a synchronous
@@ -905,8 +902,8 @@ static long wb_do_writeback(struct bdi_writeback *wb)
 	/*
 	 * Check for periodic writeback, kupdated() style
 	 */
-	wrote += wb_check_old_data_flush(wb);
-	wrote += wb_check_background_flush(wb);
+	wrote += wb_check_old_data_flush(bdi);
+	wrote += wb_check_background_flush(bdi);
 	clear_bit(BDI_writeback_running, &bdi->state);
 
 	return wrote;
@@ -920,7 +917,6 @@ void bdi_writeback_workfn(struct work_struct *work)
 {
 	struct backing_dev_info *bdi = container_of(to_delayed_work(work),
 						struct backing_dev_info, dwork);
-	struct bdi_writeback *wb = &bdi->wb;
 	long pages_written;
 
 	set_worker_desc("flush-%s", dev_name(bdi->dev));
@@ -935,7 +931,7 @@ void bdi_writeback_workfn(struct work_struct *work)
 		 * rescuer as work_list needs to be drained.
 		 */
 		do {
-			pages_written = wb_do_writeback(wb);
+			pages_written = bdi_process_work_items(bdi);
 			trace_writeback_pages_written(pages_written);
 		} while (!list_empty(&bdi->work_list));
 	} else {
@@ -951,7 +947,7 @@ void bdi_writeback_workfn(struct work_struct *work)
 			.reason		= WB_REASON_FORKER_THREAD,
 		};
 
-		pages_written = wb_writeback(wb, &work);
+		pages_written = bdi_writeback(bdi, &work);
 		trace_writeback_pages_written(pages_written);
 	}
 
-- 
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