diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 8218b2f5be89616b51b2cc67d1e257a4f05f328b..60a8fcdd9d27ba26e97cad0a6ab50e7f3bf73185 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -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 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index b1eb4ea2c68a1e85195272410e6552dce5011e86..e42a78170109ea6a132392b4bedbf69ebfe501b8 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -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); diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index cde3f3fd3c1b354be3bcd412664dc61a928f6e4d..941c1e61f291484d6d49549e476d70ceb0f6d9cb 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2465,7 +2465,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; @@ -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) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 83b3477487044f5428fc085b568c43186b100f9b..19108d6bb566c19d17b4977fe0f409b27dec44bb 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -5496,9 +5496,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