summaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 4ad73d3c1003..2334e86d7447 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1330,7 +1330,7 @@ static void ext4_da_page_release_reservation(struct page *page,
1330 unsigned int offset, 1330 unsigned int offset,
1331 unsigned int length) 1331 unsigned int length)
1332{ 1332{
1333 int to_release = 0; 1333 int to_release = 0, contiguous_blks = 0;
1334 struct buffer_head *head, *bh; 1334 struct buffer_head *head, *bh;
1335 unsigned int curr_off = 0; 1335 unsigned int curr_off = 0;
1336 struct inode *inode = page->mapping->host; 1336 struct inode *inode = page->mapping->host;
@@ -1351,14 +1351,23 @@ static void ext4_da_page_release_reservation(struct page *page,
1351 1351
1352 if ((offset <= curr_off) && (buffer_delay(bh))) { 1352 if ((offset <= curr_off) && (buffer_delay(bh))) {
1353 to_release++; 1353 to_release++;
1354 contiguous_blks++;
1354 clear_buffer_delay(bh); 1355 clear_buffer_delay(bh);
1356 } else if (contiguous_blks) {
1357 lblk = page->index <<
1358 (PAGE_CACHE_SHIFT - inode->i_blkbits);
1359 lblk += (curr_off >> inode->i_blkbits) -
1360 contiguous_blks;
1361 ext4_es_remove_extent(inode, lblk, contiguous_blks);
1362 contiguous_blks = 0;
1355 } 1363 }
1356 curr_off = next_off; 1364 curr_off = next_off;
1357 } while ((bh = bh->b_this_page) != head); 1365 } while ((bh = bh->b_this_page) != head);
1358 1366
1359 if (to_release) { 1367 if (contiguous_blks) {
1360 lblk = page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits); 1368 lblk = page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits);
1361 ext4_es_remove_extent(inode, lblk, to_release); 1369 lblk += (curr_off >> inode->i_blkbits) - contiguous_blks;
1370 ext4_es_remove_extent(inode, lblk, contiguous_blks);
1362 } 1371 }
1363 1372
1364 /* If we have released all the blocks belonging to a cluster, then we 1373 /* If we have released all the blocks belonging to a cluster, then we