Messages in this thread Patch in this message | | | Date | Thu, 1 Jul 1999 20:42:37 +0200 | From | Pavel Machek <> | Subject | [PATH] altalloc for 2.3.8 |
| |
Hi!
Here's patch to speed up operations like fsck and rm. Impact on normal operation is ~1%, but fsck/rm are speeded up about 2 times... So it is probably worth it.
--- clean//include/linux/ext2_fs.h Sat Jun 26 22:37:33 1999 +++ linux/include/linux/ext2_fs.h Sat Jun 26 22:20:05 1999 @@ -310,6 +310,7 @@ #define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */ #define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */ #define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */ +#define EXT2_MOUNT_ALTALLOC 0x0100 /* Alloc indirect blocks close to each other */ #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt #define set_opt(o, opt) o |= EXT2_MOUNT_##opt --- clean//include/linux/ext2_fs_i.h Fri May 14 20:42:46 1999 +++ linux/include/linux/ext2_fs_i.h Wed Jun 9 00:14:59 1999 @@ -37,6 +37,8 @@ __u32 i_prealloc_count; __u32 i_high_size; int i_new_inode:1; /* Is a freshly allocated inode */ + int i_alloc_elsewhere:1; + __u32 i_elsewhere_goal; }; #endif /* _LINUX_EXT2_FS_I */ --- clean//fs/ext2/inode.c Sat Jun 26 22:37:27 1999 +++ linux/fs/ext2/inode.c Thu Jul 1 17:43:41 1999 @@ -18,6 +18,8 @@ * David S. Miller (davem@caip.rutgers.edu), 1995 * 64-bit file support on 64-bit platforms by Jakub Jelinek * (jj@sunsite.ms.mff.cuni.cz) + * altalloc for speeding up rm/fsck by Pavel Machek + * (pavel@ucw.cz) sponsored by SuSE */ #include <asm/uaccess.h> @@ -103,6 +105,26 @@ wait_on_super (inode->i_sb); #ifdef EXT2_PREALLOCATE + if (inode->u.ext2_i.i_alloc_elsewhere) { + if (!inode->u.ext2_i.i_elsewhere_goal) { + goal = (inode->u.ext2_i.i_block_group * + EXT2_BLOCKS_PER_GROUP(inode->i_sb)) + + le32_to_cpu(inode->i_sb->u.ext2_sb.s_es->s_first_data_block); + if (goal > 512) + goal -= 512; + } else goal = inode->u.ext2_i.i_elsewhere_goal; +// printk( "Allocating goal = %d, ", goal ); + result = ext2_new_block (inode, goal, 0, 0, err); + inode->u.ext2_i.i_elsewhere_goal = result; +// printk( "got = %d\n", result ); + if ((result > inode->u.ext2_i.i_next_alloc_goal) && + (result-32 < inode->u.ext2_i.i_next_alloc_goal)) { +// printk( "Making room for indirect blocks\n" ); + inode->u.ext2_i.i_next_alloc_goal += 32; + } + return result; + } + if (inode->u.ext2_i.i_prealloc_count && (goal == inode->u.ext2_i.i_prealloc_block || goal + 1 == inode->u.ext2_i.i_prealloc_block)) @@ -311,8 +333,8 @@ } ext2_debug ("goal = %d.\n", goal); - tmp = ext2_alloc_block (inode, goal, err); + if (!tmp) return NULL; if (metadata) { @@ -337,8 +359,11 @@ } *p = cpu_to_le32(tmp); - inode->u.ext2_i.i_next_alloc_block = new_block; - inode->u.ext2_i.i_next_alloc_goal = tmp; + if (!inode->u.ext2_i.i_alloc_elsewhere) { + inode->u.ext2_i.i_next_alloc_block = new_block; + inode->u.ext2_i.i_next_alloc_goal = tmp; + } + inode->i_ctime = CURRENT_TIME; inode->i_blocks += blocks; if (IS_SYNC(inode) || inode->u.ext2_i.i_osync) @@ -457,8 +482,10 @@ inode->i_ctime = CURRENT_TIME; inode->i_blocks += blocks; mark_inode_dirty(inode); - inode->u.ext2_i.i_next_alloc_block = new_block; - inode->u.ext2_i.i_next_alloc_goal = tmp; + if (!inode->u.ext2_i.i_alloc_elsewhere) { + inode->u.ext2_i.i_next_alloc_block = new_block; + inode->u.ext2_i.i_next_alloc_goal = tmp; + } brelse (bh); return result; } @@ -511,9 +538,12 @@ err, 0, &phys_block, created); goto out; } + if (test_opt(inode->i_sb, ALTALLOC)) + inode->u.ext2_i.i_alloc_elsewhere = 1; block -= EXT2_NDIR_BLOCKS; if (block < addr_per_block) { bh = inode_getblk (inode, EXT2_IND_BLOCK, create, b, err, 1, NULL, NULL); + inode->u.ext2_i.i_alloc_elsewhere = 0; tmp = block_getblk (inode, bh, block, create, inode->i_sb->s_blocksize, b, err, 0, &phys_block, created); goto out; @@ -523,6 +553,7 @@ bh = inode_getblk (inode, EXT2_DIND_BLOCK, create, b, err, 1, NULL, NULL); bh = block_getblk (inode, bh, block >> addr_per_block_bits, create, inode->i_sb->s_blocksize, b, err, 1, NULL, NULL); + inode->u.ext2_i.i_alloc_elsewhere = 0; tmp = block_getblk (inode, bh, block & (addr_per_block - 1), create, inode->i_sb->s_blocksize, b, err, 0, &phys_block, created); goto out; @@ -534,6 +565,7 @@ bh = block_getblk (inode, bh, (block >> addr_per_block_bits) & (addr_per_block - 1), create, inode->i_sb->s_blocksize, b, err, 1, NULL,NULL); + inode->u.ext2_i.i_alloc_elsewhere = 0; tmp = block_getblk (inode, bh, block & (addr_per_block - 1), create, inode->i_sb->s_blocksize, b, err, 0, &phys_block, created); @@ -684,6 +716,8 @@ inode->i_blocks = le32_to_cpu(raw_inode->i_blocks); inode->i_version = ++event; inode->u.ext2_i.i_new_inode = 0; + inode->u.ext2_i.i_alloc_elsewhere = 0; + inode->u.ext2_i.i_elsewhere_goal = 0; inode->u.ext2_i.i_flags = le32_to_cpu(raw_inode->i_flags); inode->u.ext2_i.i_faddr = le32_to_cpu(raw_inode->i_faddr); inode->u.ext2_i.i_frag_no = raw_inode->i_frag; --- clean//fs/ext2/super.c Tue Jun 15 11:25:38 1999 +++ linux/fs/ext2/super.c Sun Jun 20 00:10:44 1999 @@ -181,6 +181,8 @@ } else if (!strcmp (this_char, "debug")) set_opt (*mount_options, DEBUG); + else if (!strcmp (this_char, "altalloc")) + set_opt (*mount_options, ALTALLOC); else if (!strcmp (this_char, "errors")) { if (!value || !*value) { printk ("EXT2-fs: the errors option requires " Pavel -- I'm really pavel@ucw.cz. Look at http://195.113.31.123/~pavel. Pavel Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |