Skip to contentSkip to conversation

ext3: Don't call dquot_free_block() if we don't update anything

PATCH In review Kazuya Mio 2 participants 2 messages Jan 30, 2012 – Feb 2, 2012

lore
Share & tools
lore

Kazuya Mio

author
#0 lore raw

PATCH 1/2 ext3: Don't call dquot_free_block() if we don't update anything

dquot_free_block() is called in the end of ext3_new_blocks() and updates information of the inode structure. However, this update is not necessary if the number of blocks we requested is equal to the number of allocated blocks.

---
 fs/ext3/balloc.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
fs/ext3/balloc.c +5 -2
index a203892..954a7d3 100644
@@ -1743,8 +1743,11 @@ allocated:
 
 	*errp = 0;
 	brelse(bitmap_bh);
-	dquot_free_block(inode, *count-num);
-	*count = num;
+
+	if (num < *count) {
+		dquot_free_block(inode, *count-num);
+		*count = num;
+	}
 
 	trace_ext3_allocate_blocks(inode, goal, num,
 				   (unsigned long long)ret_block);
#1 lore raw
Quoted 4 lines · Kazuya Mio

dquot_free_block() is called in the end of ext3_new_blocks() and updates information of the inode structure. However, this update is not necessary if the number of blocks we requested is equal to the number of allocated blocks.

This is obviously correct thing to do so I've merged this patch into
my tree. Thanks.

Honza

Quoted 23 lines
---
 fs/ext3/balloc.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
fs/ext3/balloc.c +5 -2
index a203892..954a7d3 100644
@@ -1743,8 +1743,11 @@ allocated:
 
 	*errp = 0;
 	brelse(bitmap_bh);
-	dquot_free_block(inode, *count-num);
-	*count = num;
+
+	if (num < *count) {
+		dquot_free_block(inode, *count-num);
+		*count = num;
+	}
 
 	trace_ext3_allocate_blocks(inode, goal, num,
 				   (unsigned long long)ret_block);
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR