From 12720557095321254db83fdc44167581ab7249d3 Mon Sep 17 00:00:00 2001 From: Jeff Moyer Date: Tue, 15 Dec 2009 16:47:49 -0800 Subject: [PATCH] --- yaml --- r: 176711 b: refs/heads/master c: 23aee091d804efa8cc732a31c1ae5d625e1ec886 h: refs/heads/master i: 176709: a44892f48e57251c4672775fbafe8f8d13fb6fac 176707: 236428e1ee81663e758792ac91280310495e6c23 176703: 213bff6f7d5c4aff0146aa1d7470a29f0ccd8d9d v: v3 --- [refs] | 2 +- trunk/fs/direct-io.c | 38 +++++++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/[refs] b/[refs] index 4206165a9ab1..5047551d53a9 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: fac046ad0b1ee2c4244ebf43a26433ef0ea29ae4 +refs/heads/master: 23aee091d804efa8cc732a31c1ae5d625e1ec886 diff --git a/trunk/fs/direct-io.c b/trunk/fs/direct-io.c index b912270942fa..9f34bb9b1ecb 100644 --- a/trunk/fs/direct-io.c +++ b/trunk/fs/direct-io.c @@ -104,6 +104,18 @@ struct dio { unsigned cur_page_len; /* Nr of bytes at cur_page_offset */ sector_t cur_page_block; /* Where it starts */ + /* BIO completion state */ + spinlock_t bio_lock; /* protects BIO fields below */ + unsigned long refcount; /* direct_io_worker() and bios */ + struct bio *bio_list; /* singly linked via bi_private */ + struct task_struct *waiter; /* waiting task (NULL if none) */ + + /* AIO related stuff */ + struct kiocb *iocb; /* kiocb */ + int is_async; /* is IO async ? */ + int io_error; /* IO error in completion path */ + ssize_t result; /* IO result */ + /* * Page fetching state. These variables belong to dio_refill_pages(). */ @@ -115,22 +127,16 @@ struct dio { * Page queue. These variables belong to dio_refill_pages() and * dio_get_page(). */ - struct page *pages[DIO_PAGES]; /* page buffer */ unsigned head; /* next page to process */ unsigned tail; /* last valid page + 1 */ int page_errors; /* errno from get_user_pages() */ - /* BIO completion state */ - spinlock_t bio_lock; /* protects BIO fields below */ - unsigned long refcount; /* direct_io_worker() and bios */ - struct bio *bio_list; /* singly linked via bi_private */ - struct task_struct *waiter; /* waiting task (NULL if none) */ - - /* AIO related stuff */ - struct kiocb *iocb; /* kiocb */ - int is_async; /* is IO async ? */ - int io_error; /* IO error in completion path */ - ssize_t result; /* IO result */ + /* + * pages[] (and any fields placed after it) are not zeroed out at + * allocation time. Don't add new fields after pages[] unless you + * wish that they not be zeroed. + */ + struct page *pages[DIO_PAGES]; /* page buffer */ }; /* @@ -1151,10 +1157,16 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, } } - dio = kzalloc(sizeof(*dio), GFP_KERNEL); + dio = kmalloc(sizeof(*dio), GFP_KERNEL); retval = -ENOMEM; if (!dio) goto out; + /* + * Believe it or not, zeroing out the page array caused a .5% + * performance regression in a database benchmark. So, we take + * care to only zero out what's needed. + */ + memset(dio, 0, offsetof(struct dio, pages)); /* * For block device access DIO_NO_LOCKING is used,