未验证 提交 4758cc88 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!1420 [sync] PR-1415: Fix generic/299 fail

Merge Pull Request from: @openeuler-sync-bot 
 

Origin pull request: 
https://gitee.com/openeuler/kernel/pulls/1415 
 
PR sync from: Zhihao Cheng <chengzhihao1@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/TSXRUVDLVGILRT2XURWM3RIMGTKSEUZT/ 
Revert origin fix, add debug message.

Zhihao Cheng (2):
  Revert "ext4: Stop trying writing pages if no free blocks generated"
  ext4: Add debug message to notify user space is out of free


-- 
2.31.1
 
https://gitee.com/openeuler/kernel/issues/I7CBCS 
 
Link:https://gitee.com/openeuler/kernel/pulls/1420 

Reviewed-by: zhangyi (F) <yi.zhang@huawei.com> 
Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com> 
......@@ -700,7 +700,6 @@ enum {
#define EXT4_FREE_BLOCKS_NOFREE_FIRST_CLUSTER 0x0010
#define EXT4_FREE_BLOCKS_NOFREE_LAST_CLUSTER 0x0020
#define EXT4_FREE_BLOCKS_RERESERVE_CLUSTER 0x0040
#define EXT4_FREE_BLOCKS_DONT_WAIT_JOURNAL 0x0080
/*
* ioctl commands
......
......@@ -1294,8 +1294,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
if (!ablocks[i])
continue;
ext4_free_blocks(handle, inode, NULL, ablocks[i], 1,
EXT4_FREE_BLOCKS_METADATA |
EXT4_FREE_BLOCKS_DONT_WAIT_JOURNAL);
EXT4_FREE_BLOCKS_METADATA);
}
}
kfree(ablocks);
......@@ -4330,7 +4329,6 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
ext4_discard_preallocations(inode, 0);
if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE)
fb_flags = EXT4_FREE_BLOCKS_NO_QUOT_UPDATE;
fb_flags |= EXT4_FREE_BLOCKS_DONT_WAIT_JOURNAL;
ext4_free_blocks(handle, inode, NULL, newblock,
EXT4_C2B(sbi, allocated_clusters),
fb_flags);
......
......@@ -2479,7 +2479,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
* is non-zero, a commit should free up blocks.
*/
if ((err == -ENOMEM) ||
(err == -ENOSPC && EXT4_SB(sb)->s_mb_free_pending)) {
(err == -ENOSPC && ext4_count_free_clusters(sb))) {
if (progress)
goto update_disksize;
return err;
......@@ -2696,6 +2696,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;
......@@ -2877,6 +2880,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
......@@ -2885,6 +2897,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)
......
......@@ -5498,9 +5498,8 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
* consistency guarantees.
*/
if (ext4_handle_valid(handle) &&
(((flags & EXT4_FREE_BLOCKS_METADATA) ||
!ext4_should_writeback_data(inode)) &&
!(flags & EXT4_FREE_BLOCKS_DONT_WAIT_JOURNAL))) {
((flags & EXT4_FREE_BLOCKS_METADATA) ||
!ext4_should_writeback_data(inode))) {
struct ext4_free_data *new_entry;
/*
* We use __GFP_NOFAIL because ext4_free_blocks() is not allowed
......
......@@ -357,7 +357,6 @@ static struct inode *create_whiteout(struct inode *dir, struct dentry *dentry)
umode_t mode = S_IFCHR | WHITEOUT_MODE;
struct inode *inode;
struct ubifs_info *c = dir->i_sb->s_fs_info;
struct fscrypt_name nm;
/*
* Create an inode('nlink = 1') for whiteout without updating journal,
......@@ -368,10 +367,6 @@ static struct inode *create_whiteout(struct inode *dir, struct dentry *dentry)
dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
dentry, mode, dir->i_ino);
err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
if (err)
return ERR_PTR(err);
inode = ubifs_new_inode(c, dir, mode, false);
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
......@@ -394,7 +389,6 @@ static struct inode *create_whiteout(struct inode *dir, struct dentry *dentry)
make_bad_inode(inode);
iput(inode);
out_free:
fscrypt_free_filename(&nm);
ubifs_err(c, "cannot create whiteout file, error %d", err);
return ERR_PTR(err);
}
......@@ -490,6 +484,7 @@ static int ubifs_tmpfile(struct inode *dir, struct dentry *dentry,
unlock_2_inodes(dir, inode);
ubifs_release_budget(c, &req);
fscrypt_free_filename(&nm);
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册