delalloc ENOSPC: release reservation for unlink/truncate
RFC PATCH 5/6 delalloc ENOSPC: release reservation for unlink/truncate
ext4: delalloc block reservation unlink/truncate handling
From: Mingming cao <[email protected]>
Release reserved blocks for unlink/truncate/invalidate page
Signed-off-by Mingming cao <[email protected]>
--- fs/ext4/inode.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-)
fs/ext4/inode.c +21 -7
@@ -1477,6 +1477,27 @@ void ext4_da_release_space(struct inodeEXT4_I (inode)->i_reserved_meta_blocks -= mdb; } +static void ext4_da_page_release_reservation (struct page *page, +unsigned long offset) +{ +int to_release =0 ; +struct buffer_head *head, *bh; +unsigned int curr_off =0 ; + + head =page_buffers (page); + bh = head; +do { +unsigned int next_off = curr_off + bh->b_size; + +if ((offset <= curr_off) && (buffer_delay (bh))) { + to_release++; +clear_buffer_delay (bh); + } + curr_off = next_off; + }while ((bh = bh->b_this_page) != head); +ext4_da_release_space (page->mapping->host,0 , to_release); +} +/* * this is a special callback for ->write_begin() only * it's intention is to return mapped block or reserve space
@@ -1737,9 +1758,6 @@ static int ext4_da_write_begin(struct fistatic void ext4_da_invalidatepage (struct page *page,unsigned long offset) { -struct buffer_head *head, *bh; -unsigned int curr_off =0 ; -/* * Drop reserved blocks */
@@ -1747,21 +1765,7 @@ static void ext4_da_invalidatepage(strucif (!page_has_buffers (page)) goto out; - head =page_buffers (page); - bh = head; - do { - unsigned int next_off = curr_off + bh->b_size;