All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: fix sleep inside spinlock issue aka #14739
@ 2009-12-10  1:42 Dmitry Monakhov
  2009-12-10 16:15 ` Jan Kara
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Monakhov @ 2009-12-10  1:42 UTC (permalink / raw)
  To: linux-ext4; +Cc: cmm, Dmitry Monakhov

drop i_block_reservation_lock before vfs_dq_reserve_block().
this patch fix http://bugzilla.kernel.org/show_bug.cgi?id=14739

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 fs/ext4/inode.c |   29 ++++++++++++++++-------------
 1 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 942e183..f693768 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1852,19 +1852,8 @@ repeat:
 	md_needed = mdblocks - EXT4_I(inode)->i_reserved_meta_blocks;
 	total = md_needed + nrblocks;
 
-	/*
-	 * Make quota reservation here to prevent quota overflow
-	 * later. Real quota accounting is done at pages writeout
-	 * time.
-	 */
-	if (vfs_dq_reserve_block(inode, total)) {
-		spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
-		return -EDQUOT;
-	}
-
 	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;
@@ -1872,10 +1861,24 @@ repeat:
 		return -ENOSPC;
 	}
 	EXT4_I(inode)->i_reserved_data_blocks += nrblocks;
-	EXT4_I(inode)->i_reserved_meta_blocks = mdblocks;
+	EXT4_I(inode)->i_reserved_meta_blocks += md_needed;
+	spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
+
+	/*
+	 * Make quota reservation here to prevent quota overflow
+	 * later. Real quota accounting is done at pages writeout
+	 * time.
+	 */
+	if (!vfs_dq_reserve_block(inode, total))
+		return 0;       /* success */
 
+	/* Quota reservation has failed, revert inode's reservation */
+	percpu_counter_sub(&sbi->s_dirtyblocks_counter, total);
+	spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
+	EXT4_I(inode)->i_reserved_data_blocks -= nrblocks;
+	EXT4_I(inode)->i_reserved_meta_blocks -= md_needed;
 	spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
-	return 0;       /* success */
+	return -EDQUOT;
 }
 
 static void ext4_da_release_space(struct inode *inode, int to_free)
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-12-19 15:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-10  1:42 [PATCH] ext4: fix sleep inside spinlock issue aka #14739 Dmitry Monakhov
2009-12-10 16:15 ` Jan Kara
2009-12-10 17:22   ` [PATCH] ext4: fix sleep inside spinlock issue aka #14739 V2 Dmitry Monakhov
2009-12-15 21:48     ` Jan Kara
2009-12-15 23:16       ` Dmitry Monakhov
2009-12-15 23:44         ` Jan Kara
2009-12-18 10:06     ` Aneesh Kumar K.V
2009-12-19 15:11       ` Dmitry Monakhov
2009-12-18 10:02   ` [PATCH] ext4: fix sleep inside spinlock issue aka #14739 Aneesh Kumar K.V

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.