⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ext3-mballoc3-2.6.18.patch

📁 非常经典的一个分布式系统
💻 PATCH
📖 第 1 页 / 共 2 页
字号:
 		goto out2; 	} @@ -2151,6 +2172,7 @@ int ext3_ext_get_blocks(handle_t *handle  	/* previous routine could use block we allocated */ 	newblock = le32_to_cpu(newex.ee_start);+	allocated = le16_to_cpu(newex.ee_len); 	__set_bit(BH_New, &bh_result->b_state);  	ext3_ext_put_in_cache(inode, iblock, allocated, newblock,@@ -2202,6 +2224,9 @@ void ext3_ext_truncate(struct inode * in 	mutex_lock(&EXT3_I(inode)->truncate_mutex); 	ext3_ext_invalidate_cache(inode); +	/* it's important to discard preallocations under truncate_mutex */+	ext3_mb_discard_inode_preallocations(inode);+ 	/* 	 * TODO: optimization is possible here 	 * probably we need not scaning at all,Index: linux-2.6.18.8/fs/ext3/Makefile===================================================================--- linux-2.6.18.8.orig/fs/ext3/Makefile	2007-07-17 09:18:14.000000000 +0200+++ linux-2.6.18.8/fs/ext3/Makefile	2007-07-17 09:18:53.000000000 +0200@@ -5,7 +5,7 @@ obj-$(CONFIG_EXT3_FS) += ext3.o  ext3-y	:= balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \-	   ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o+	   ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o mballoc.o  ext3-$(CONFIG_EXT3_FS_XATTR)	 += xattr.o xattr_user.o xattr_trusted.o ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.oIndex: linux-2.6.18.8/fs/ext3/xattr.c===================================================================--- linux-2.6.18.8.orig/fs/ext3/xattr.c	2007-02-24 00:52:30.000000000 +0100+++ linux-2.6.18.8/fs/ext3/xattr.c	2007-07-17 09:18:53.000000000 +0200@@ -484,7 +484,7 @@ ext3_xattr_release_block(handle_t *handl 		ea_bdebug(bh, "refcount now=0; freeing"); 		if (ce) 			mb_cache_entry_free(ce);-		ext3_free_blocks(handle, inode, bh->b_blocknr, 1);+		ext3_free_blocks(handle, inode, bh->b_blocknr, 1, 1); 		get_bh(bh); 		ext3_forget(handle, 1, inode, bh, bh->b_blocknr); 	} else {@@ -805,7 +805,7 @@ inserted: 			new_bh = sb_getblk(sb, block); 			if (!new_bh) { getblk_failed:-				ext3_free_blocks(handle, inode, block, 1);+				ext3_free_blocks(handle, inode, block, 1, 1); 				error = -EIO; 				goto cleanup; 			}Index: linux-2.6.18.8/fs/ext3/balloc.c===================================================================--- linux-2.6.18.8.orig/fs/ext3/balloc.c	2007-02-24 00:52:30.000000000 +0100+++ linux-2.6.18.8/fs/ext3/balloc.c	2007-07-17 09:18:53.000000000 +0200@@ -79,7 +79,7 @@ struct ext3_group_desc * ext3_get_group_  *  * Return buffer_head on success or NULL in case of failure.  */-static struct buffer_head *+struct buffer_head * read_block_bitmap(struct super_block *sb, unsigned int block_group) { 	struct ext3_group_desc * desc;@@ -294,6 +294,8 @@ void ext3_discard_reservation(struct ino 	struct ext3_reserve_window_node *rsv; 	spinlock_t *rsv_lock = &EXT3_SB(inode->i_sb)->s_rsv_window_lock; +	ext3_mb_discard_inode_preallocations(inode);+ 	if (!block_i) 		return; @@ -490,21 +492,25 @@ error_return: 	return; } -/* Free given blocks, update quota and i_blocks field */ void ext3_free_blocks(handle_t *handle, struct inode *inode,-			ext3_fsblk_t block, unsigned long count)+			ext3_fsblk_t block, unsigned long count, int metadata) {-	struct super_block * sb;-	unsigned long dquot_freed_blocks;+	struct super_block *sb;+	unsigned long freed;++	/* this isn't the right place to decide whether block is metadata+	 * inode.c/extents.c knows better, but for safety ... */+	if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode) ||+			ext3_should_journal_data(inode))+		metadata = 1;  	sb = inode->i_sb;-	if (!sb) {-		printk ("ext3_free_blocks: nonexistent device");-		return;-	}-	ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);-	if (dquot_freed_blocks)-		DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);+	if (!test_opt(sb, MBALLOC) || !EXT3_SB(sb)->s_group_info)+		ext3_free_blocks_sb(handle, sb, block, count, &freed);+	else+		ext3_mb_free_blocks(handle, inode, block, count, metadata, &freed);+	if (freed)+		DQUOT_FREE_BLOCK(inode, freed); 	return; } @@ -1199,7 +1205,7 @@ int ext3_should_retry_alloc(struct super  * bitmap, and then for any free bit if that fails.  * This function also updates quota and i_blocks field.  */-ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,+ext3_fsblk_t ext3_new_blocks_old(handle_t *handle, struct inode *inode, 			ext3_fsblk_t goal, unsigned long *count, int *errp) { 	struct buffer_head *bitmap_bh = NULL;@@ -1463,7 +1469,7 @@ out: 	return 0; } -ext3_fsblk_t ext3_new_block(handle_t *handle, struct inode *inode,+ext3_fsblk_t ext3_new_block_old(handle_t *handle, struct inode *inode, 			ext3_fsblk_t goal, int *errp) { 	unsigned long count = 1;Index: linux-2.6.18.8/fs/ext3/inode.c===================================================================--- linux-2.6.18.8.orig/fs/ext3/inode.c	2007-07-17 09:18:14.000000000 +0200+++ linux-2.6.18.8/fs/ext3/inode.c	2007-07-17 09:18:53.000000000 +0200@@ -560,7 +560,7 @@ static int ext3_alloc_blocks(handle_t *h 	return ret; failed_out: 	for (i = 0; i <index; i++)-		ext3_free_blocks(handle, inode, new_blocks[i], 1);+		ext3_free_blocks(handle, inode, new_blocks[i], 1, 0); 	return ret; } @@ -659,9 +659,9 @@ failed: 		ext3_journal_forget(handle, branch[i].bh); 	} 	for (i = 0; i <indirect_blks; i++)-		ext3_free_blocks(handle, inode, new_blocks[i], 1);+		ext3_free_blocks(handle, inode, new_blocks[i], 1, 0); -	ext3_free_blocks(handle, inode, new_blocks[i], num);+	ext3_free_blocks(handle, inode, new_blocks[i], num, 0);  	return err; }@@ -758,9 +758,10 @@ err_out: 	for (i = 1; i <= num; i++) { 		BUFFER_TRACE(where[i].bh, "call journal_forget"); 		ext3_journal_forget(handle, where[i].bh);-		ext3_free_blocks(handle,inode,le32_to_cpu(where[i-1].key),1);+		ext3_free_blocks(handle,inode,le32_to_cpu(where[i-1].key), 1,+				 0); 	}-	ext3_free_blocks(handle, inode, le32_to_cpu(where[num].key), blks);+	ext3_free_blocks(handle, inode, le32_to_cpu(where[num].key), blks, 0);  	return err; }@@ -1996,7 +1997,7 @@ static void ext3_clear_blocks(handle_t * 		} 	} -	ext3_free_blocks(handle, inode, block_to_free, count);+	ext3_free_blocks(handle, inode, block_to_free, count, 0); }  /**@@ -2169,7 +2170,7 @@ static void ext3_free_branches(handle_t  				ext3_journal_test_restart(handle, inode); 			} -			ext3_free_blocks(handle, inode, nr, 1);+			ext3_free_blocks(handle, inode, nr, 1, 1);  			if (parent_bh) { 				/*Index: linux-2.6.18.8/fs/ext3/mballoc.c===================================================================--- linux-2.6.18.8.orig/fs/ext3/mballoc.c	2007-07-17 09:18:14.000000000 +0200+++ linux-2.6.18.8/fs/ext3/mballoc.c	2007-07-17 09:23:56.000000000 +0200@@ -350,8 +350,8 @@ struct ext3_prealloc_space { 	spinlock_t		pa_lock; 	atomic_t		pa_count; 	unsigned		pa_deleted;-	unsigned long		pa_pstart;	/* phys. block */-	unsigned long		pa_lstart;	/* log. block */+	ext3_fsblk_t		pa_pstart;	/* phys. block */+	ext3_fsblk_t		pa_lstart;	/* log. block */ 	unsigned short		pa_len;		/* len of preallocated chunk */ 	unsigned short		pa_free;	/* how many blocks are free */ 	unsigned short		pa_linear;	/* consumed in one direction@@ -460,8 +460,8 @@ static struct proc_dir_entry *proc_root_  int ext3_create (struct inode *, struct dentry *, int, struct nameidata *); struct buffer_head * read_block_bitmap(struct super_block *, unsigned int);-unsigned long ext3_new_blocks_old(handle_t *handle, struct inode *inode,-			unsigned long goal, unsigned long *count, int *errp);+ext3_fsblk_t ext3_new_blocks_old(handle_t *handle, struct inode *inode,+			ext3_fsblk_t goal, unsigned long *count, int *errp); void ext3_mb_release_blocks(struct super_block *, int); void ext3_mb_poll_new_transaction(struct super_block *, handle_t *); void ext3_mb_free_committed_blocks(struct super_block *);@@ -479,7 +479,7 @@ int ext3_mb_destroy_per_dev_proc(struct   * Calculate the block group number and offset, given a block number  */ static void ext3_get_group_no_and_offset(struct super_block *sb,-					unsigned long blocknr,+					ext3_fsblk_t blocknr, 					unsigned long *blockgrpp, 					unsigned long *offsetp) {@@ -517,12 +517,12 @@ ext3_is_group_locked(struct super_block  					&EXT3_GROUP_INFO(sb, group)->bb_state); } -unsigned long ext3_grp_offs_to_block(struct super_block *sb,+ext3_fsblk_t ext3_grp_offs_to_block(struct super_block *sb, 					struct ext3_free_extent *fex) {-	unsigned long block;+	ext3_fsblk_t block; -	block = (unsigned long) fex->fe_group * EXT3_BLOCKS_PER_GROUP(sb)+	block = (ext3_fsblk_t) fex->fe_group * EXT3_BLOCKS_PER_GROUP(sb) 			+ fex->fe_start 			+ le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block); 	return block;@@ -3174,7 +3174,7 @@ void ext3_mb_collect_stats(struct ext3_a void ext3_mb_use_inode_pa(struct ext3_allocation_context *ac, 				struct ext3_prealloc_space *pa) {-	unsigned long start, len;+	ext3_fsblk_t start, len;  	/* found preallocated blocks, use them */ 	start = pa->pa_pstart + (ac->ac_o_ex.fe_logical - pa->pa_lstart);@@ -4027,13 +4027,13 @@ int ext3_mb_discard_preallocations(struc  * it tries to use preallocation first, then falls back  * to usual allocation  */-unsigned long ext3_mb_new_blocks(handle_t *handle,+ext3_fsblk_t ext3_mb_new_blocks(handle_t *handle, 				 struct ext3_allocation_request *ar, int *errp) { 	struct ext3_allocation_context ac; 	struct ext3_sb_info *sbi; 	struct super_block *sb;-	unsigned long block = 0;+	ext3_fsblk_t block = 0; 	int freed, inquota;  	sb = ar->inode->i_sb;@@ -4044,8 +4044,8 @@ unsigned long ext3_mb_new_blocks(handle_ 		if (ext3_mballoc_warning++ == 0) 			printk(KERN_ERR "EXT3-fs: multiblock request with " 					"mballoc disabled!\n");-		ar->len = 1;-		block = ext3_new_block_old(handle, ar->inode, ar->goal, errp);+		block = ext3_new_blocks_old(handle, ar->inode, ar->goal,+					    &ar->len, errp); 		return block; 	} @@ -4109,11 +4109,11 @@ out: } EXPORT_SYMBOL(ext3_mb_new_blocks); -int ext3_new_block(handle_t *handle, struct inode *inode,-		   unsigned long goal, int *errp)+ext3_fsblk_t ext3_new_block(handle_t *handle, struct inode *inode,+		   ext3_fsblk_t goal, int *errp) { 	struct ext3_allocation_request ar;-	unsigned long ret;+	ext3_fsblk_t ret;  	if (!test_opt(inode->i_sb, MBALLOC)) { 		ret = ext3_new_block_old(handle, inode, goal, errp);@@ -4228,8 +4228,8 @@ int ext3_mb_free_metadata(handle_t *hand  * Main entry point into mballoc to free blocks  */ void ext3_mb_free_blocks(handle_t *handle, struct inode *inode,-			unsigned long block, unsigned long count,-			int metadata, int *freed)+			ext3_fsblk_t block, unsigned long count,+			int metadata, unsigned long *freed) { 	struct buffer_head *bitmap_bh = NULL; 	struct super_block *sb = inode->i_sb;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -