linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] ext4: ext4_get_reserved_space() must return bytes instead of blocks
@ 2009-11-25  6:57 Dmitry Monakhov
  2009-11-25  6:57 ` [PATCH 2/4] ext4: fix reserved space transferring on chown() [V2] Dmitry Monakhov
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Dmitry Monakhov @ 2009-11-25  6:57 UTC (permalink / raw)
  To: linux-ext4; +Cc: Dmitry Monakhov, Mingming


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

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index ab22297..cc4737e 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1057,7 +1057,7 @@ qsize_t ext4_get_reserved_space(struct inode *inode)
 		EXT4_I(inode)->i_reserved_meta_blocks;
 	spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
 
-	return total;
+	return (total << inode->i_blkbits);
 }
 /*
  * Calculate the number of metadata blocks need to reserve
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH 1/4] ext4: delalloc quota fixes
  2009-11-23 18:13 ext4+quota patch series Dmitry Monakhov
@ 2009-11-23 18:30 Dmitry Monakhov
  2009-11-23 22:58 ` Dmitry Monakhov
  0 siblings, 1 reply; 16+ messages in thread
From: Dmitry Monakhov @ 2009-11-23 18:30 UTC (permalink / raw)
  To: linux-ext4

This patch fix most visible problems with delalloc+quota issues
- ext4_get_reserved_space() must return bytes instead of blocks.
- Claim allocated meta blocks. Do it as we do for data blocks
  but delay it until proper moment.
- Move space claiming to ext4_da_update_reserve_space()
  Only here we do know what we are dealing with data or metadata

The most useful test case for delalloc+quota is concurrent tasks
with write+truncate vs chown for a same file.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 fs/ext4/inode.c   |   13 ++++++++-----
 fs/ext4/mballoc.c |    6 ------
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index ab22297..84863e6 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1057,7 +1057,7 @@ qsize_t ext4_get_reserved_space(struct inode *inode)
 		EXT4_I(inode)->i_reserved_meta_blocks;
 	spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
 
-	return total;
+	return (total << inode->i_blkbits);
 }
 /*
  * Calculate the number of metadata blocks need to reserve
@@ -1096,7 +1096,7 @@ static int ext4_calc_metadata_amount(struct inode *inode, int blocks)
 static void ext4_da_update_reserve_space(struct inode *inode, int used)
 {
 	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
-	int total, mdb, mdb_free;
+	int total, mdb, mdb_free, mdb_claim = 0;
 
 	spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
 	/* recalculate the number of metablocks still need to be reserved */
@@ -1109,7 +1109,9 @@ static void ext4_da_update_reserve_space(struct inode *inode, int used)
 
 	if (mdb_free) {
 		/* Account for allocated meta_blocks */
-		mdb_free -= EXT4_I(inode)->i_allocated_meta_blocks;
+		mdb_claim = EXT4_I(inode)->i_allocated_meta_blocks;
+		BUG_ON(mdb_free < mdb_claim);
+		mdb_free -= mdb_claim;
 
 		/* update fs dirty blocks counter */
 		percpu_counter_sub(&sbi->s_dirtyblocks_counter, mdb_free);
@@ -1119,8 +1121,9 @@ static void ext4_da_update_reserve_space(struct inode *inode, int used)
 
 	/* update per-inode reservations */
 	BUG_ON(used  > EXT4_I(inode)->i_reserved_data_blocks);
-	EXT4_I(inode)->i_reserved_data_blocks -= used;
-	spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
+ 	EXT4_I(inode)->i_reserved_data_blocks -= used;
+	percpu_counter_sub(&sbi->s_dirtyblocks_counter, used + mdb_claim);
+	vfs_dq_claim_block(inode, used + mdb_claim);
 
 	/*
 	 * free those over-booking quota for metadata blocks
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index bba1282..d4c52db 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2750,12 +2750,6 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
 	if (!(ac->ac_flags & EXT4_MB_DELALLOC_RESERVED))
 		/* release all the reserved blocks if non delalloc */
 		percpu_counter_sub(&sbi->s_dirtyblocks_counter, reserv_blks);
-	else {
-		percpu_counter_sub(&sbi->s_dirtyblocks_counter,
-						ac->ac_b_ex.fe_len);
-		/* convert reserved quota blocks to real quota blocks */
-		vfs_dq_claim_block(ac->ac_inode, ac->ac_b_ex.fe_len);
-	}
 
 	if (sbi->s_log_groups_per_flex) {
 		ext4_group_t flex_group = ext4_flex_group(sbi,
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* ext4+quota patch series
@ 2009-11-23 18:13 Dmitry Monakhov
  2009-11-23 18:34 ` [PATCH 4/4] ext4: fix incorrect block reservation on quota transfer Dmitry Monakhov
  0 siblings, 1 reply; 16+ messages in thread
From: Dmitry Monakhov @ 2009-11-23 18:13 UTC (permalink / raw)
  To: linux-ext4

Hello, I've prepared patch-set which fixes some issues
in quota related code. With this patch-set applied i've
got success pass from all quota tests I use.

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

end of thread, other threads:[~2009-12-09  2:03 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-25  6:57 [PATCH 1/4] ext4: ext4_get_reserved_space() must return bytes instead of blocks Dmitry Monakhov
2009-11-25  6:57 ` [PATCH 2/4] ext4: fix reserved space transferring on chown() [V2] Dmitry Monakhov
2009-11-25  6:57   ` [PATCH 3/4] ext4: quota macros cleanup Dmitry Monakhov
2009-11-25  6:57     ` [PATCH 4/4] ext4: fix incorrect block reservation on quota transfer Dmitry Monakhov
2009-12-08  1:02       ` Mingming
2009-12-08  6:48         ` Dmitry Monakhov
2009-12-08  0:59     ` [PATCH 3/4] ext4: quota macros cleanup Mingming
2009-12-07 17:18   ` [PATCH 2/4] ext4: fix reserved space transferring on chown() [V2] Aneesh Kumar K.V
2009-12-07 19:41     ` Dmitry Monakhov
2009-12-09  1:42       ` tytso
2009-12-09  2:03         ` Dmitry Monakhov
2009-12-08 23:06   ` Mingming
2009-11-25 16:32 ` [PATCH 1/4] ext4: ext4_get_reserved_space() must return bytes instead of blocks Eric Sandeen
2009-12-08  1:04 ` Mingming
  -- strict thread matches above, loose matches on Subject: below --
2009-11-23 18:30 [PATCH 1/4] ext4: delalloc quota fixes Dmitry Monakhov
2009-11-23 22:58 ` Dmitry Monakhov
2009-11-23 22:58   ` [PATCH 2/4] ext4: fix race chown vs truncate Dmitry Monakhov
2009-11-23 22:58     ` [PATCH 3/4] ext4: quota macros cleanup Dmitry Monakhov
2009-11-23 22:58       ` [PATCH 4/4] ext4: fix incorrect block reservation on quota transfer Dmitry Monakhov
2009-11-23 18:13 ext4+quota patch series Dmitry Monakhov
2009-11-23 18:34 ` [PATCH 4/4] ext4: fix incorrect block reservation on quota transfer Dmitry Monakhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).