Skip to contentSkip to conversation

Ext4: avoid multiple quota reservation when retry block reservation for delalloc

PATCH In review Mingming 3 participants 4 messages Sep 21, 2009 – Sep 28, 2009 ext4 file system

lore
Share & tools
lore

Mingming

author
#0 lore raw

PATCH 1/1 Ext4: avoid multiple quota reservation when retry block reservation for delalloc

Ext4: release reserved quota before block reservation for delalloc retry

ext4_da_reserve_space() can reserve quota blocks multiple times if ext4_claim_free_blocks() fail and we retry the allocation. We should release the quota reservation before restarting.

Bug found be Jan Kara.

---
 fs/ext4/inode.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inode.c +1 -1
Index: linux-2.6.31-rc4/fs/ext4/inode.c
===================================================================
@@ -1785,11 +1785,11 @@ repeat:
 
 	if (ext4_claim_free_blocks(sbi, total)) {
 		spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
+		vfs_dq_release_reservation_block(inode, total);
 		if (ext4_should_retry_alloc(inode->i_sb, &retries)) {
 			yield();
 			goto repeat;
 		}
-		vfs_dq_release_reservation_block(inode, total);
 		return -ENOSPC;
 	}
 	EXT4_I(inode)->i_reserved_data_blocks += nrblocks;
reviewer
#1 lore raw
Quoted 7 lines · Mingming

Ext4: release reserved quota before block reservation for delalloc retry

ext4_da_reserve_space() can reserve quota blocks multiple times if ext4_claim_free_blocks() fail and we retry the allocation. We should release the quota reservation before restarting.

Bug found be Jan Kara.

            ^^ by
Quoted 15 lines
---
 fs/ext4/inode.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6.31-rc4/fs/ext4/inode.c
===================================================================

fs/ext4/inode.c +0 -0
@@ -1785,11 +1785,11 @@ repeat:
 
 	if (ext4_claim_free_blocks(sbi, total)) {

fs/ext4/inode.c repeat: · line 1795

Quoted 10 lines
fs/ext4/inode.c +1 -1
 		spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
+		vfs_dq_release_reservation_block(inode, total);
 		if (ext4_should_retry_alloc(inode->i_sb, &retries)) {
 			yield();
 			goto repeat;
 		}
-		vfs_dq_release_reservation_block(inode, total);
 		return -ENOSPC;
 	}
 	EXT4_I(inode)->i_reserved_data_blocks += nrblocks;

The patch is fine. Acked-by: Jan Kara <[email protected]>
But it's certainly not the issue hit by Pavol but I'm out of ideas where could be a problem provided he runs with extents...

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author
#2 lore raw
Quoted 9 lines · Jan Kara
Quoted 7 lines · Mingming

Ext4: release reserved quota before block reservation for delalloc retry

ext4_da_reserve_space() can reserve quota blocks multiple times if ext4_claim_free_blocks() fail and we retry the allocation. We should release the quota reservation before restarting.

Bug found be Jan Kara.

            ^^ by

attached is the updated patch with this typo fixed.

Quoted 13 lines
Quoted 13 lines
---
 fs/ext4/inode.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6.31-rc4/fs/ext4/inode.c
===================================================================

fs/ext4/inode.c +0 -0
@@ -1785,11 +1785,11 @@ repeat:
 
Quoted 13 lines

fs/ext4/inode.c repeat: · line 1795

Quoted 12 lines
fs/ext4/inode.c +1 -1
 	if (ext4_claim_free_blocks(sbi, total)) {
 		spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
+		vfs_dq_release_reservation_block(inode, total);
 		if (ext4_should_retry_alloc(inode->i_sb, &retries)) {
 			yield();
 			goto repeat;
 		}
-		vfs_dq_release_reservation_block(inode, total);
 		return -ENOSPC;
 	}
 	EXT4_I(inode)->i_reserved_data_blocks += nrblocks;

The patch is fine. Acked-by: Jan Kara <[email protected]>

Thanks!

Quoted 3 lines

But it's certainly not the issue hit by Pavol but I'm out of ideas where could be a problem provided he runs with extents...

I am not sure where is the problem reported by Pavol by looking at the code either. Perhaps enable some debugging code, but I am under impression that the system is in-use now...

Mingming

Ext4: release reserved quota when block reservation for delalloc retry

ext4_da_reserve_space() can reserve quota blocks multiple times if ext4_claim_free_blocks() fail and we retry the allocation. We should release the quota reservation before restarting.

Bug found by Jan Kara.

---
 fs/ext4/inode.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inode.c +1 -1
Index: linux-2.6.31-rc4/fs/ext4/inode.c
===================================================================
@@ -1785,11 +1785,11 @@ repeat:
 
 	if (ext4_claim_free_blocks(sbi, total)) {
 		spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
+		vfs_dq_release_reservation_block(inode, total);
 		if (ext4_should_retry_alloc(inode->i_sb, &retries)) {
 			yield();
 			goto repeat;
 		}
-		vfs_dq_release_reservation_block(inode, total);
 		return -ENOSPC;
 	}
 	EXT4_I(inode)->i_reserved_data_blocks += nrblocks;
maintainer
#3 lore raw
Quoted 4 lines · Mingming
Quoted 3 lines · Jan Kara
Quoted 2 lines · Mingming

Ext4: release reserved quota before block reservation for delalloc retry

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines

ext4_da_reserve_space() can reserve quota blocks multiple times if ext4_claim_free_blocks() fail and we retry the allocation. We should release the quota reservation before restarting.

Bug found be Jan Kara.

            ^^ by

attached is the updated patch with this typo fixed.

Added to the ext4 patch queue, thanks.

- Ted