From 3bbf8b61589342c84f65735b276af8fe7e979e27 Mon Sep 17 00:00:00 2001 From: Zhihao Cheng Date: Fri, 14 Jul 2023 09:58:09 +0800 Subject: [PATCH] ext4: Add debug message to notify user space is out of free hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7CBCS CVE: NA -------------------------------- Add debug message to notify user that ext4_writepages is stuck in loop caused by ENOSPC. Signed-off-by: Zhihao Cheng (cherry picked from commit 4ae7e7037fa5eff9636f2c468312b5e505a57b0e) --- fs/ext4/inode.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 4c9cd5e994cf..941c1e61f291 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2682,6 +2682,9 @@ static int ext4_writepages(struct address_space *mapping, struct ext4_sb_info *sbi = EXT4_SB(mapping->host->i_sb); struct blk_plug plug; bool give_up_on_write = false; + unsigned long retry_warn_ddl = 0; + +#define RETRY_WARN_TIMEOUT (30 * HZ) if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) return -EIO; @@ -2863,6 +2866,15 @@ static int ext4_writepages(struct address_space *mapping, mpd.io_submit.io_end = NULL; if (ret == -ENOSPC && sbi->s_journal) { + if (!retry_warn_ddl) { + retry_warn_ddl = jiffies + RETRY_WARN_TIMEOUT; + } else if (time_after(jiffies, retry_warn_ddl)) { + retry_warn_ddl = jiffies + RETRY_WARN_TIMEOUT; + ext4_warning(inode->i_sb, "There are no free blocks available for writing pages, total free %llu, pending free %u, please delete big files to free space", + ext4_count_free_clusters(inode->i_sb), + sbi->s_mb_free_pending); + } + /* * Commit the transaction which would * free blocks released in the transaction @@ -2871,6 +2883,8 @@ static int ext4_writepages(struct address_space *mapping, jbd2_journal_force_commit_nested(sbi->s_journal); ret = 0; continue; + } else { + retry_warn_ddl = 0; } /* Fatal error - ENOMEM, EIO... */ if (ret) -- GitLab