alistair23-linux/fs/btrfs
Liu Bo 67c9684f48 Btrfs: improve multi-thread buffer read
While testing with my buffer read fio jobs[1], I find that btrfs does not
perform well enough.

Here is a scenario in fio jobs:

We have 4 threads, "t1 t2 t3 t4", starting to buffer read a same file,
and all of them will race on add_to_page_cache_lru(), and if one thread
successfully puts its page into the page cache, it takes the responsibility
to read the page's data.

And what's more, reading a page needs a period of time to finish, in which
other threads can slide in and process rest pages:

     t1          t2          t3          t4
   add Page1
   read Page1  add Page2
     |         read Page2  add Page3
     |            |        read Page3  add Page4
     |            |           |        read Page4
-----|------------|-----------|-----------|--------
     v            v           v           v
    bio          bio         bio         bio

Now we have four bios, each of which holds only one page since we need to
maintain consecutive pages in bio.  Thus, we can end up with far more bios
than we need.

Here we're going to
a) delay the real read-page section and
b) try to put more pages into page cache.

With that said, we can make each bio hold more pages and reduce the number
of bios we need.

Here is some numbers taken from fio results:
         w/o patch                 w patch
       -------------  --------  ---------------
READ:    745MB/s        +25%       934MB/s

[1]:
[global]
group_reporting
thread
numjobs=4
bs=32k
rw=read
ioengine=sync
directory=/mnt/btrfs/

[READ]
filename=foobar
size=2000M
invalidate=1

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
2012-07-23 16:28:10 -04:00
..
acl.c Btrfs: cache no acl on new inodes 2012-05-30 10:23:27 -04:00
async-thread.c
async-thread.h
backref.c Btrfs: leave critical region in btrfs_find_all_roots as soon as possible 2012-06-27 16:34:39 +02:00
backref.h Btrfs: use the tree modification log for backref resolving 2012-05-30 15:17:34 +02:00
btrfs_inode.h Btrfs: kill free_space pointer from inode structure 2012-07-23 16:28:05 -04:00
check-integrity.c Btrfs: use rcu to protect device->name 2012-06-14 21:29:16 -04:00
check-integrity.h
compat.h
compression.c Merge branch 'for-linus-min' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs 2012-04-13 19:41:27 -07:00
compression.h
ctree.c Btrfs: fix buffer leak in btrfs_next_old_leaf 2012-07-23 16:28:03 -04:00
ctree.h Btrfs: rewrite BTRFS_SETGET_FUNCS 2012-07-23 16:28:06 -04:00
delayed-inode.c Btrfs: zero unused bytes in inode item 2012-07-23 16:28:05 -04:00
delayed-inode.h Btrfs: flush delayed inodes if we're short on space 2012-07-23 15:41:40 -04:00
delayed-ref.c Btrfs: use delayed ref sequence numbers for all fs-tree updates 2012-05-30 18:18:21 +02:00
delayed-ref.h Btrfs: use delayed ref sequence numbers for all fs-tree updates 2012-05-30 18:18:21 +02:00
dir-item.c
disk-io.c Btrfs: avoid I/O repair BUG() from btree_read_extent_buffer_pages() 2012-07-23 16:27:59 -04:00
disk-io.h btrfs: Drop unused function btrfs_abort_devices() 2012-05-30 10:23:39 -04:00
export.c ->encode_fh() API change 2012-05-29 23:28:33 -04:00
export.h
extent-tree.c Btrfs: make btrfs's allocation smoothly with preallocation 2012-07-23 16:28:10 -04:00
extent_io.c Btrfs: improve multi-thread buffer read 2012-07-23 16:28:10 -04:00
extent_io.h Merge branch 'for-chris' of git://git.jan-o-sch.net/btrfs-unstable into for-linus 2012-05-31 16:49:53 -04:00
extent_map.c
extent_map.h
file-item.c Btrfs: kill root from btrfs_is_free_space_inode 2012-07-23 16:28:00 -04:00
file.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs 2012-07-05 13:06:25 -07:00
free-space-cache.c Btrfs: do not count in readonly bytes 2012-07-23 16:28:03 -04:00
free-space-cache.h
hash.h
inode-item.c Merge branch 'error-handling' into for-linus 2012-03-28 20:31:37 -04:00
inode-map.c Btrfs: show useful info in space reservation tracepoint 2012-03-29 09:57:44 -04:00
inode-map.h
inode.c Btrfs: zero unused bytes in inode item 2012-07-23 16:28:05 -04:00
ioctl.c Btrfs: do not set subvolume flags in readonly mode 2012-07-23 16:27:58 -04:00
ioctl.h Btrfs: add DEVICE_READY ioctl 2012-07-23 16:27:42 -04:00
Kconfig
locking.c Btrfs: reduce calls to wake_up on uncontended locks 2012-07-23 15:36:18 -04:00
locking.h
lzo.c
Makefile
ordered-data.c Btrfs: call filemap_fdatawrite twice for compression 2012-06-14 21:30:54 -04:00
ordered-data.h Btrfs: finish ordered extents in their own thread 2012-05-30 10:23:33 -04:00
orphan.c
print-tree.c Btrfs: read device stats on mount, write modified ones during commit 2012-05-30 10:23:41 -04:00
print-tree.h
rcu-string.h Btrfs: use rcu to protect device->name 2012-06-14 21:29:16 -04:00
reada.c Btrfs: set ioprio of scrub readahead to idle 2012-05-30 10:23:43 -04:00
relocation.c Btrfs: fix error handling in __add_reloc_root() 2012-07-23 16:27:53 -04:00
root-tree.c
scrub.c Btrfs: use rcu to protect device->name 2012-06-14 21:29:16 -04:00
struct-funcs.c Btrfs: rewrite BTRFS_SETGET_FUNCS 2012-07-23 16:28:06 -04:00
super.c Btrfs: add DEVICE_READY ioctl 2012-07-23 16:27:42 -04:00
sysfs.c
transaction.c Btrfs: change how we indicate we're adding csums 2012-07-23 16:27:55 -04:00
transaction.h Btrfs: change how we indicate we're adding csums 2012-07-23 16:27:55 -04:00
tree-defrag.c
tree-log.c Btrfs: return error of btrfs_update_inode() to caller 2012-07-23 16:27:54 -04:00
tree-log.h
ulist.c Merge branch 'for-chris' of git://git.jan-o-sch.net/btrfs-unstable into for-linus 2012-05-31 16:49:53 -04:00
ulist.h Merge branch 'for-chris' of git://git.jan-o-sch.net/btrfs-unstable into for-linus 2012-05-31 16:49:53 -04:00
version.h
volumes.c Btrfs: suppress printk() if all device I/O stats are zero 2012-07-23 16:28:07 -04:00
volumes.h Btrfs: add DEVICE_READY ioctl 2012-07-23 16:27:42 -04:00
xattr.c Btrfs: use i_version instead of our own sequence 2012-05-30 10:23:27 -04:00
xattr.h
zlib.c