mirror of
				git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
				synced 2025-10-31 16:54:21 +00:00 
			
		
		
		
	[PATCH] ext3_get_blocks: Adjust reservation window size for mblocks
Optimize the block reservation and the multiple block allocation: with the knowledge of the total number of blocks ahead, set or adjust the reservation window size properly (based on the number of blocks needed) before block allocation happens: if there isn't any reservation yet, make sure the reservation window equals to or greater than the number of blocks needed, before create an reservation window; if a reservation window is already exists, try to extends the window size to match the number of blocks to allocate. This could increase the possibility of completing multiple blocks allocation in a single request, as blocks are only allocated in the range of the inode's reservation window. Signed-off-by: Mingming Cao <cmm@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
		
							parent
							
								
									faa569763a
								
							
						
					
					
						commit
						d48589bfad
					
				
					 1 changed files with 31 additions and 1 deletions
				
			
		|  | @ -1011,6 +1011,31 @@ retry: | ||||||
| 	goto retry; | 	goto retry; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static void try_to_extend_reservation(struct ext3_reserve_window_node *my_rsv, | ||||||
|  | 			struct super_block *sb, int size) | ||||||
|  | { | ||||||
|  | 	struct ext3_reserve_window_node *next_rsv; | ||||||
|  | 	struct rb_node *next; | ||||||
|  | 	spinlock_t *rsv_lock = &EXT3_SB(sb)->s_rsv_window_lock; | ||||||
|  | 
 | ||||||
|  | 	if (!spin_trylock(rsv_lock)) | ||||||
|  | 		return; | ||||||
|  | 
 | ||||||
|  | 	next = rb_next(&my_rsv->rsv_node); | ||||||
|  | 
 | ||||||
|  | 	if (!next) | ||||||
|  | 		my_rsv->rsv_end += size; | ||||||
|  | 	else { | ||||||
|  | 		next_rsv = list_entry(next, struct ext3_reserve_window_node, rsv_node); | ||||||
|  | 
 | ||||||
|  | 		if ((next_rsv->rsv_start - my_rsv->rsv_end - 1) >= size) | ||||||
|  | 			my_rsv->rsv_end += size; | ||||||
|  | 		else | ||||||
|  | 			my_rsv->rsv_end = next_rsv->rsv_start - 1; | ||||||
|  | 	} | ||||||
|  | 	spin_unlock(rsv_lock); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /*
 | /*
 | ||||||
|  * This is the main function used to allocate a new block and its reservation |  * This is the main function used to allocate a new block and its reservation | ||||||
|  * window. |  * window. | ||||||
|  | @ -1095,6 +1120,8 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle, | ||||||
| 	while (1) { | 	while (1) { | ||||||
| 		if (rsv_is_empty(&my_rsv->rsv_window) || (ret < 0) || | 		if (rsv_is_empty(&my_rsv->rsv_window) || (ret < 0) || | ||||||
| 			!goal_in_my_reservation(&my_rsv->rsv_window, goal, group, sb)) { | 			!goal_in_my_reservation(&my_rsv->rsv_window, goal, group, sb)) { | ||||||
|  | 			if (my_rsv->rsv_goal_size < *count) | ||||||
|  | 				my_rsv->rsv_goal_size = *count; | ||||||
| 			ret = alloc_new_reservation(my_rsv, goal, sb, | 			ret = alloc_new_reservation(my_rsv, goal, sb, | ||||||
| 							group, bitmap_bh); | 							group, bitmap_bh); | ||||||
| 			if (ret < 0) | 			if (ret < 0) | ||||||
|  | @ -1102,7 +1129,10 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle, | ||||||
| 
 | 
 | ||||||
| 			if (!goal_in_my_reservation(&my_rsv->rsv_window, goal, group, sb)) | 			if (!goal_in_my_reservation(&my_rsv->rsv_window, goal, group, sb)) | ||||||
| 				goal = -1; | 				goal = -1; | ||||||
| 		} | 		} else if (goal > 0 && (my_rsv->rsv_end-goal+1) < *count) | ||||||
|  | 			try_to_extend_reservation(my_rsv, sb, | ||||||
|  | 					*count-my_rsv->rsv_end + goal - 1); | ||||||
|  | 
 | ||||||
| 		if ((my_rsv->rsv_start >= group_first_block + EXT3_BLOCKS_PER_GROUP(sb)) | 		if ((my_rsv->rsv_start >= group_first_block + EXT3_BLOCKS_PER_GROUP(sb)) | ||||||
| 		    || (my_rsv->rsv_end < group_first_block)) | 		    || (my_rsv->rsv_end < group_first_block)) | ||||||
| 			BUG(); | 			BUG(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Mingming Cao
						Mingming Cao