[Devel,RHEL7,COMMIT] fs-writeback: add endless writeback debug

Submitted by Konstantin Khorenko on Aug. 31, 2017, 10:22 a.m.

Details

Message ID 201708311022.v7VAMxBC012851@finist_ce7.work
State New
Series "fs-writeback: add endless writeback debug"
Headers show

Commit Message

Konstantin Khorenko Aug. 31, 2017, 10:22 a.m.
The commit is pushed to "branch-rh7-3.10.0-514.26.1.vz7.35.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.26.1.vz7.35.5
------>
commit 1069e544ff85161d41fd3679c3d3b47dc3af5139
Author: Dmitry Monakhov <dmonakhov@openvz.org>
Date:   Fri Aug 25 13:16:52 2017 +0400

    fs-writeback: add endless writeback debug
    
    This is temporary debug patch, it will be rolled back before the release.
    
    https://jira.sw.ru/browse/PSBM-69587
    
    Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 fs/fs-writeback.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Patch hide | download patch | download mbox

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index f34ae6c..a54c0bd 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -787,11 +787,15 @@  static long __writeback_inodes_wb(struct bdi_writeback *wb,
 {
 	unsigned long start_time = jiffies;
 	long wrote = 0;
+	int trace = 0;
 
 	while (!list_empty(&wb->b_io)) {
 		struct inode *inode = wb_inode(wb->b_io.prev);
 		struct super_block *sb = inode->i_sb;
 
+		if (time_is_before_jiffies(start_time + 15* HZ))
+			trace = 1;
+
 		if (!grab_super_passive(sb)) {
 			/*
 			 * grab_super_passive() may fail consistently due to
@@ -799,6 +803,9 @@  static long __writeback_inodes_wb(struct bdi_writeback *wb,
 			 * requeue_io() to avoid busy retrying the inode/sb.
 			 */
 			redirty_tail(inode, wb);
+			if (trace)
+				printk("%s:%d writeback is taking too long ino:%ld sb(%p):%s\n",
+				       __FUNCTION__, __LINE__, inode->i_ino, sb, sb->s_id);
 			continue;
 		}
 		wrote += writeback_sb_inodes(sb, wb, work);
@@ -890,6 +897,7 @@  static long wb_writeback(struct bdi_writeback *wb,
 	unsigned long oldest_jif;
 	struct inode *inode;
 	long progress;
+	int trace = 0;
 
 	oldest_jif = jiffies;
 	work->older_than_this = &oldest_jif;
@@ -902,6 +910,9 @@  static long wb_writeback(struct bdi_writeback *wb,
 		if (work->nr_pages <= 0)
 			break;
 
+		if (time_is_before_jiffies(wb_start + 15* HZ))
+			trace = 1;
+
 		/*
 		 * Background writeout and kupdate-style writeback may
 		 * run forever. Stop them if there is other work to do
@@ -973,6 +984,10 @@  static long wb_writeback(struct bdi_writeback *wb,
 			inode = wb_inode(wb->b_more_io.prev);
 			spin_lock(&inode->i_lock);
 			spin_unlock(&wb->list_lock);
+			if (trace)
+				printk("%s:%d writeback is taking too long ino:%ld st:%ld sb(%p):%s\n",
+				       __FUNCTION__, __LINE__, inode->i_ino,
+				       inode->i_state, inode->i_sb, inode->i_sb->s_id);
 			/* This function drops i_lock... */
 			inode_sleep_on_writeback(inode);
 			spin_lock(&wb->list_lock);