summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2010-09-24 10:06:45 -0400
committerTheodore Ts'o <tytso@mit.edu>2010-09-24 10:06:45 -0400
commit00f0b1411838db56e1e04816e4d369be332fd2b6 (patch)
treea1fc41399919d4ad0f0e7a092b666bdb4992c5cd
parent7f1a1fbf850f6b73b5c9c82365f01029fb250a1c (diff)
downloade2fsprogs-00f0b1411838db56e1e04816e4d369be332fd2b6.tar.gz
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>
-rw-r--r--lib/ext2fs/inode.c5
-rw-r--r--lib/ext2fs/openfs.c2
-rw-r--r--lib/ext2fs/rw_bitmaps.c15
3 files changed, 14 insertions, 8 deletions
diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c
index 988caff5..5088f9bb 100644
--- a/lib/ext2fs/inode.c
+++ b/lib/ext2fs/inode.c
@@ -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;
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index 52157d85..d638da03 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -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) {
diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c
index cfa3369a..4e77a8f1 100644
--- a/lib/ext2fs/rw_bitmaps.c
+++ b/lib/ext2fs/rw_bitmaps.c
@@ -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