summaryrefslogtreecommitdiff
blob: 6abb6d2fda978422a9c0ecd9a765274e73f1bbaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
diff -NurpP linux-2.6.14.2-vs2.0.1-rc4/fs/reiserfs/bitmap.c linux-2.6.14.2-vs2.0.1-rc4.2/fs/reiserfs/bitmap.c
--- linux-2.6.14.2-vs2.0.1-rc4/fs/reiserfs/bitmap.c	2005-10-29 18:09:54 +0200
+++ linux-2.6.14.2-vs2.0.1-rc4.2/fs/reiserfs/bitmap.c	2005-12-04 06:11:17 +0100
@@ -412,8 +412,10 @@ static void _reiserfs_free_block(struct 
 	set_sb_free_blocks(rs, sb_free_blocks(rs) + 1);
 
 	journal_mark_dirty(th, s, sbh);
-	if (for_unformatted)
+	if (for_unformatted) {
+		DLIMIT_FREE_BLOCK(inode, 1);
 		DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
+	}
 }
 
 void reiserfs_free_block(struct reiserfs_transaction_handle *th,
@@ -1032,12 +1034,15 @@ static inline int blocknrs_and_prealloc_
 			       "reiserquota: allocating %d blocks id=%u",
 			       amount_needed, hint->inode->i_uid);
 #endif
-		quota_ret =
-		    DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
-		if (quota_ret)	/* Quota exceeded? */
+		quota_ret = DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode,
+			amount_needed);
+		if (quota_ret)
 			return QUOTA_EXCEEDED;
-		if (DLIMIT_ALLOC_BLOCK(hint->inode, amount_needed))
-			goto out_dlimit;
+		if (DLIMIT_ALLOC_BLOCK(hint->inode, amount_needed)) {
+			DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
+				amount_needed);
+			return NO_DISK_SPACE;
+		}
 
 		if (hint->preallocate && hint->prealloc_size) {
 #ifdef REISERQUOTA_DEBUG
@@ -1045,15 +1050,16 @@ static inline int blocknrs_and_prealloc_
 				       "reiserquota: allocating (prealloc) %d blocks id=%u",
 				       hint->prealloc_size, hint->inode->i_uid);
 #endif
-			quota_ret =
-			    DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
-							 hint->prealloc_size);
+			quota_ret = DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
+				hint->prealloc_size);
+			if (!quota_ret &&
+				DLIMIT_ALLOC_BLOCK(hint->inode, hint->prealloc_size)) {
+				DQUOT_FREE_BLOCK_NODIRTY(hint->inode,
+					hint->prealloc_size);
+				quota_ret = 1;
+			}
 			if (quota_ret)
 				hint->preallocate = hint->prealloc_size = 0;
-			if (DLIMIT_ALLOC_BLOCK(hint->inode, hint->prealloc_size)) {
-				DQUOT_FREE_BLOCK_NODIRTY(hint->inode, hint->prealloc_size);
-				hint->preallocate=hint->prealloc_size=0;
-			}
 		}
 
 		/* for unformatted nodes, force large allocations */
@@ -1145,10 +1151,6 @@ static inline int blocknrs_and_prealloc_
 	}
 
 	return CARRY_ON;
-
-out_dlimit:
-	DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed);
-	return NO_DISK_SPACE;
 }
 
 /* grab new blocknrs from preallocated list */