aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorZach Brown <zach.brown@oracle.com>2007-08-20 20:12:01 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-21 01:50:25 -0400
commit848c4dd5153c7a0de55470ce99a8e13a63b4703f (patch)
tree4defb21d98037a96a3a90e83eaf85a10b46f0571 /fs
parent38f061c5714265fa8481cc0b7795aa8fe81b45be (diff)
dio: zero struct dio with kzalloc instead of manually
This patch uses kzalloc to zero all of struct dio rather than manually trying to track which fields we rely on being zero. It passed aio+dio stress testing and some bug regression testing on ext3. This patch was introduced by Linus in the conversation that lead up to Badari's minimal fix to manually zero .map_bh.b_state in commit: 6a648fa72161d1f6468dabd96c5d3c0db04f598a It makes the code a bit smaller. Maybe a couple fewer cachelines to load, if we're lucky: text data bss dec hex filename 3285925 568506 1304616 5159047 4eb887 vmlinux 3285797 568506 1304616 5158919 4eb807 vmlinux.patched I was unable to measure a stable difference in the number of cpu cycles spent in blockdev_direct_IO() when pushing aio+dio 256K reads at ~340MB/s. So the resulting intent of the patch isn't a performance gain but to avoid exposing ourselves to the risk of finding another field like .map_bh.b_state where we rely on zeroing but don't enforce it in the code. Signed-off-by: Zach Brown <zach.brown@oracle.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/direct-io.c18
1 files changed, 1 insertions, 17 deletions
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 6874785bb65a..901dc55e9f54 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -958,36 +958,22 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
958 ssize_t ret2; 958 ssize_t ret2;
959 size_t bytes; 959 size_t bytes;
960 960
961 dio->bio = NULL;
962 dio->inode = inode; 961 dio->inode = inode;
963 dio->rw = rw; 962 dio->rw = rw;
964 dio->blkbits = blkbits; 963 dio->blkbits = blkbits;
965 dio->blkfactor = inode->i_blkbits - blkbits; 964 dio->blkfactor = inode->i_blkbits - blkbits;
966 dio->start_zero_done = 0;
967 dio->size = 0;
968 dio->block_in_file = offset >> blkbits; 965 dio->block_in_file = offset >> blkbits;
969 dio->blocks_available = 0;
970 dio->cur_page = NULL;
971 966
972 dio->boundary = 0;
973 dio->reap_counter = 0;
974 dio->get_block = get_block; 967 dio->get_block = get_block;
975 dio->end_io = end_io; 968 dio->end_io = end_io;
976 dio->map_bh.b_private = NULL;
977 dio->map_bh.b_state = 0;
978 dio->final_block_in_bio = -1; 969 dio->final_block_in_bio = -1;
979 dio->next_block_for_io = -1; 970 dio->next_block_for_io = -1;
980 971
981 dio->page_errors = 0;
982 dio->io_error = 0;
983 dio->result = 0;
984 dio->iocb = iocb; 972 dio->iocb = iocb;
985 dio->i_size = i_size_read(inode); 973 dio->i_size = i_size_read(inode);
986 974
987 spin_lock_init(&dio->bio_lock); 975 spin_lock_init(&dio->bio_lock);
988 dio->refcount = 1; 976 dio->refcount = 1;
989 dio->bio_list = NULL;
990 dio->waiter = NULL;
991 977
992 /* 978 /*
993 * In case of non-aligned buffers, we may need 2 more 979 * In case of non-aligned buffers, we may need 2 more
@@ -995,8 +981,6 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
995 */ 981 */
996 if (unlikely(dio->blkfactor)) 982 if (unlikely(dio->blkfactor))
997 dio->pages_in_io = 2; 983 dio->pages_in_io = 2;
998 else
999 dio->pages_in_io = 0;
1000 984
1001 for (seg = 0; seg < nr_segs; seg++) { 985 for (seg = 0; seg < nr_segs; seg++) {
1002 user_addr = (unsigned long)iov[seg].iov_base; 986 user_addr = (unsigned long)iov[seg].iov_base;
@@ -1184,7 +1168,7 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1184 } 1168 }
1185 } 1169 }
1186 1170
1187 dio = kmalloc(sizeof(*dio), GFP_KERNEL); 1171 dio = kzalloc(sizeof(*dio), GFP_KERNEL);
1188 retval = -ENOMEM; 1172 retval = -ENOMEM;
1189 if (!dio) 1173 if (!dio)
1190 goto out; 1174 goto out;