ext2fs: Optimize for Direct I/O

Allocate various memory structures to be properly aligned to avoid
needing to use a bounce buffer when doing direct I/O read/writes.
This should also help on FreeBSD systems which require aligned buffers
unconditionally.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
bitmap-optimize
Theodore Ts'o 2010-09-24 10:06:45 -04:00
parent 7f1a1fbf85
commit 00f0b14118
3 changed files with 14 additions and 8 deletions

View File

@ -156,9 +156,8 @@ errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks,
(fs->blocksize / scan->inode_size - 1)) *
scan->inode_size / fs->blocksize;
}
retval = ext2fs_get_array(scan->inode_buffer_blocks,
fs->blocksize,
&scan->inode_buffer);
retval = ext2fs_get_memalign(scan->inode_buffer_blocks * fs->blocksize,
fs->blocksize, &scan->inode_buffer);
scan->done_group = 0;
scan->done_group_data = 0;
scan->bad_block_ptr = 0;

View File

@ -131,7 +131,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
goto cleanup;
fs->image_io = fs->io;
fs->io->app_data = fs;
retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &fs->super);
retval = ext2fs_get_memalign(SUPERBLOCK_SIZE, 512, &fs->super);
if (retval)
goto cleanup;
if (flags & EXT2_FLAG_IMAGE_FILE) {

View File

@ -52,7 +52,8 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
inode_nbytes = block_nbytes = 0;
if (do_block) {
block_nbytes = EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
retval = ext2fs_get_mem(fs->blocksize, &block_buf);
retval = ext2fs_get_memalign(fs->blocksize, fs->blocksize,
&block_buf);
if (retval)
return retval;
memset(block_buf, 0xff, fs->blocksize);
@ -60,7 +61,8 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
if (do_inode) {
inode_nbytes = (size_t)
((EXT2_INODES_PER_GROUP(fs->super)+7) / 8);
retval = ext2fs_get_mem(fs->blocksize, &inode_buf);
retval = ext2fs_get_memalign(fs->blocksize, fs->blocksize,
&inode_buf);
if (retval)
return retval;
memset(inode_buf, 0xff, fs->blocksize);
@ -169,8 +171,13 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map);
if (retval)
goto cleanup;
retval = ext2fs_get_mem(do_image ? fs->blocksize :
(unsigned) block_nbytes, &block_bitmap);
if (do_image)
retval = ext2fs_get_mem(fs->blocksize, &block_bitmap);
else
retval = ext2fs_get_memalign((unsigned) block_nbytes,
fs->blocksize,
&block_bitmap);
if (retval)
goto cleanup;
} else