mbox series

[0/8,v3] btrfs direct-io using iomap

Message ID 20191205155630.28817-1-rgoldwyn@suse.de
Headers show
Series btrfs direct-io using iomap | expand

Message

Goldwyn Rodrigues Dec. 5, 2019, 3:56 p.m. UTC
This is an effort to use iomap for direct I/O in btrfs. This would
change the call from __blockdev_direct_io() to iomap_dio_rw().

The main objective is to lose the buffer head and use bio defined by
iomap code, and hopefully to use more of generic-FS codebase.

These patches are based on xfs/iomap-for-next, though I tested it
against the patches on xfs/iomap-for-next on top of v5.4.1 (there are no
changes to existing patches). The tree is available at
https://github.com/goldwynr/linux/tree/btrfs-iomap-dio

I have tested it against xfstests/btrfs.

Changes since v1
- Incorporated back the efficiency change for inode locking
- Review comments about coding style and git comments
- Merge related patches into one
- Direct read to go through btrfs_direct_IO()
- Removal of no longer used function dio_end_io()

Changes since v2
- aligning iomap offset/length to the position/length of I/O
- Removed btrfs_dio_data
- Removed BTRFS_INODE_READDIO_NEED_LOCK
- Re-incorporating write efficiency changes caused lockdep_assert() in
  iomap to be triggered, remove that code.

 fs/btrfs/btrfs_inode.h |   18 ---
 fs/btrfs/ctree.h       |    1 
 fs/btrfs/extent_io.c   |   37 ++----
 fs/btrfs/extent_io.h   |    2 
 fs/btrfs/file.c        |   21 +++
 fs/btrfs/inode.c       |  267 ++++++++++++++++---------------------------------
 fs/direct-io.c         |   19 ---
 fs/iomap/direct-io.c   |   16 +-
 include/linux/fs.h     |    3 
 include/linux/iomap.h  |    2 
 mm/filemap.c           |   13 +-
 11 files changed, 149 insertions(+), 250 deletions(-)

Comments

David Sterba Dec. 6, 2019, 3:09 p.m. UTC | #1
On Thu, Dec 05, 2019 at 09:56:22AM -0600, Goldwyn Rodrigues wrote:
> This is an effort to use iomap for direct I/O in btrfs. This would
> change the call from __blockdev_direct_io() to iomap_dio_rw().
> 
> The main objective is to lose the buffer head and use bio defined by
> iomap code, and hopefully to use more of generic-FS codebase.
> 
> These patches are based on xfs/iomap-for-next, though I tested it
> against the patches on xfs/iomap-for-next on top of v5.4.1 (there are no
> changes to existing patches). The tree is available at
> https://github.com/goldwynr/linux/tree/btrfs-iomap-dio

The iomap-for-next seems to be all merged to master, so I'd like to add
the btrfs part to for-next early so we can have the full dev cycle to
test.

Fstests got stuck at generic/095, in llseek on the inode mutex. In version
5.4.1 it's inode_lock while in master it's inode_lock_shared and only used for
SEEK_DATA/HOLE.

I've also tested the rebased patchset on current master but due to the hangs
caused by pipe changes when send is done it only gets to test btrfs/016 (way
before the generic/095 starts).

generic/095             [21:12:03][ 9153.094902] run fstests generic/095 at 2019-12-05 21:12:03
[ 9153.355112] BTRFS info (device vda): using free space tree
[ 9153.357522] BTRFS info (device vda): has skinny extents
[ 9155.598524] BTRFS: device fsid 8f274c73-27d6-4a7c-96ad-4ae41fcd6916 devid 1 transid 5 /dev/vdb
[ 9155.626220] BTRFS info (device vdb): enabling free space tree
[ 9155.628257] BTRFS info (device vdb): using free space tree
[ 9155.630290] BTRFS info (device vdb): has skinny extents
[ 9155.632191] BTRFS info (device vdb): flagging fs with big metadata feature
[ 9155.640732] BTRFS info (device vdb): creating free space tree
[ 9155.643781] BTRFS info (device vdb): setting compat-ro feature flag for FREE_SPACE_TREE (0x1)
[ 9155.648664] BTRFS info (device vdb): setting compat-ro feature flag for FREE_SPACE_TREE_VALID (0x2)
[ 9155.652542] BTRFS info (device vdb): checking UUID tree
[ 9819.465520] INFO: task fio:19671 blocked for more than 491 seconds.
[ 9819.470928]       Tainted: G             L    5.4.1-default+ #889
[ 9819.475441] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 9819.480987] fio             D14632 19671  19669 0x00004000
[ 9819.483182] Call Trace:
[ 9819.484360]  ? __schedule+0x2d4/0x8f0
[ 9819.485779]  schedule+0x49/0xd0
[ 9819.487050]  rwsem_down_write_slowpath+0x3f6/0x7d0
[ 9819.488777]  ? down_write+0xa9/0x130
[ 9819.490203]  down_write+0xa9/0x130
[ 9819.491571]  btrfs_file_llseek+0x45/0x2b0 [btrfs]
[ 9819.493074]  ksys_lseek+0x63/0xb0
[ 9819.494153]  do_syscall_64+0x50/0x1f0
[ 9819.495122]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 9819.496328] RIP: 0033:0x7f6bce8c0627
[ 9819.503273] RSP: 002b:00007fffa3fdaab8 EFLAGS: 00000206 ORIG_RAX: 0000000000000008
[ 9819.505802] RAX: ffffffffffffffda RBX: 00007f6ba393f000 RCX: 00007f6bce8c0627
[ 9819.508045] RDX: 0000000000000000 RSI: 0000000000007800 RDI: 0000000000000003
[ 9819.510048] RBP: 00007f6ba393f000 R08: 0000000000000400 R09: 0000000000000000
[ 9819.512061] R10: fffffffffffffa85 R11: 0000000000000206 R12: 0000000000000000
[ 9819.514211] R13: 0000000000000400 R14: 00007f6ba393f000 R15: 000055fc96807b40
[ 9819.516181] INFO: task fio:19672 blocked for more than 491 seconds.
[ 9819.517970]       Tainted: G             L    5.4.1-default+ #889
[ 9819.519650] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 9819.522142] fio             D14712 19672  19669 0x00000000
[ 9819.523696] Call Trace:
[ 9819.524651]  ? __schedule+0x2d4/0x8f0
[ 9819.525871]  schedule+0x49/0xd0
[ 9819.527003]  rwsem_down_write_slowpath+0x3f6/0x7d0
[ 9819.528480]  ? down_write+0xa9/0x130
[ 9819.529705]  down_write+0xa9/0x130
[ 9819.530889]  btrfs_file_llseek+0x45/0x2b0 [btrfs]
[ 9819.532304]  ksys_lseek+0x63/0xb0
[ 9819.533482]  do_syscall_64+0x50/0x1f0
[ 9819.534721]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 9819.536567] RIP: 0033:0x7f6bce8c0627
[ 9819.544424] RSP: 002b:00007fffa3fdaab8 EFLAGS: 00000206 ORIG_RAX: 0000000000000008
[ 9819.547483] RAX: ffffffffffffffda RBX: 00007f6ba3958080 RCX: 00007f6bce8c0627
[ 9819.549937] RDX: 0000000000000000 RSI: 0000000000020800 RDI: 0000000000000003
[ 9819.552152] RBP: 00007f6ba3958080 R08: 0000000000000400 R09: 0000000000000000
[ 9819.554479] R10: fffffffffffffa85 R11: 0000000000000206 R12: 0000000000000000
[ 9819.556515] R13: 0000000000000400 R14: 00007f6ba3958080 R15: 000055fc96807b40
[ 9819.558536] INFO: task fio:19673 blocked for more than 491 seconds.
[ 9819.560332]       Tainted: G             L    5.4.1-default+ #889
[ 9819.562062] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 9819.564494] fio             D13480 19673  19669 0x00000000
[ 9819.566075] Call Trace:
[ 9819.567037]  ? __schedule+0x2d4/0x8f0
[ 9819.568325]  schedule+0x49/0xd0
[ 9819.569438]  rwsem_down_write_slowpath+0x3f6/0x7d0
[ 9819.570906]  ? down_write+0xa9/0x130
[ 9819.572072]  down_write+0xa9/0x130
[ 9819.573255]  btrfs_file_llseek+0x45/0x2b0 [btrfs]
[ 9819.574685]  ? vfs_read+0x14e/0x180
[ 9819.575871]  ksys_lseek+0x63/0xb0
[ 9819.577066]  do_syscall_64+0x50/0x1f0
[ 9819.578286]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 9819.579758] RIP: 0033:0x7f6bce8c0627