* Re: iov_iter_pipe warning.
[not found] ` <20170807201818.kykqzexce6ap6aik@codemonkey.org.uk>
@ 2017-08-28 20:31 ` Dave Jones
2017-08-29 4:25 ` Darrick J. Wong
0 siblings, 1 reply; 30+ messages in thread
From: Dave Jones @ 2017-08-28 20:31 UTC (permalink / raw)
To: Al Viro, Linux Kernel; +Cc: linux-xfs
On Mon, Aug 07, 2017 at 04:18:18PM -0400, Dave Jones wrote:
> On Fri, Apr 28, 2017 at 06:20:25PM +0100, Al Viro wrote:
> > On Fri, Apr 28, 2017 at 12:50:24PM -0400, Dave Jones wrote:
> > > currently running v4.11-rc8-75-gf83246089ca0
> > >
> > > sunrpc bit is for the other unrelated problem I'm chasing.
> > >
> > > note also, I saw the backtrace without the fs/splice.c changes.
> >
> > Interesting... Could you add this and see if that triggers?
> >
> > diff --git a/fs/splice.c b/fs/splice.c
> > index 540c4a44756c..12a12d9c313f 100644
> > --- a/fs/splice.c
> > +++ b/fs/splice.c
> > @@ -306,6 +306,9 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
> > kiocb.ki_pos = *ppos;
> > ret = call_read_iter(in, &kiocb, &to);
> > if (ret > 0) {
> > + if (WARN_ON(iov_iter_count(&to) != len - ret))
> > + printk(KERN_ERR "ops %p: was %zd, left %zd, returned %d\n",
> > + in->f_op, len, iov_iter_count(&to), ret);
> > *ppos = kiocb.ki_pos;
> > file_accessed(in);
> > } else if (ret < 0) {
>
> Hey Al,
> Due to a git stash screw up on my part, I've had this leftover WARN_ON
> in my tree for the last couple months. (That screw-up might turn out to be
> serendipitous if this is a real bug..)
>
> Today I decided to change things up and beat up on xfs for a change, and
> was able to trigger this again.
>
> Is this check no longer valid, or am I triggering the same bug we were chased
> down in nfs, but now in xfs ? (None of the other detritus from that debugging
> back in April made it, just those three lines above).
Revisiting this. I went back and dug out some of the other debug diffs [1]
from that old thread.
I can easily trigger this spew on xfs.
WARNING: CPU: 1 PID: 2251 at fs/splice.c:292 test_it+0xd4/0x1d0
CPU: 1 PID: 2251 Comm: trinity-c42 Not tainted 4.13.0-rc7-think+ #1
task: ffff880459173a40 task.stack: ffff88044f7d0000
RIP: 0010:test_it+0xd4/0x1d0
RSP: 0018:ffff88044f7d7878 EFLAGS: 00010283
RAX: 0000000000000000 RBX: ffff88044f44b968 RCX: ffffffff81511ea0
RDX: 0000000000000003 RSI: dffffc0000000000 RDI: ffff88044f44ba68
RBP: ffff88044f7d78c8 R08: ffff88046b218ec0 R09: 0000000000000000
R10: ffff88044f7d7518 R11: 0000000000000000 R12: 0000000000001000
R13: 0000000000000001 R14: 00000000ffffffff R15: 0000000000000001
FS: 00007fdbc09b2700(0000) GS:ffff88046b200000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 0000000459e1d000 CR4: 00000000001406e0
Call Trace:
generic_file_splice_read+0x414/0x4e0
? opipe_prep.part.14+0x180/0x180
? lockdep_init_map+0xb2/0x2b0
? rw_verify_area+0x65/0x150
do_splice_to+0xab/0xc0
splice_direct_to_actor+0x1f5/0x540
? generic_pipe_buf_nosteal+0x10/0x10
? do_splice_to+0xc0/0xc0
? rw_verify_area+0x9d/0x150
do_splice_direct+0x1b9/0x230
? splice_direct_to_actor+0x540/0x540
? __sb_start_write+0x164/0x1c0
? do_sendfile+0x7b3/0x840
do_sendfile+0x428/0x840
? do_compat_pwritev64+0xb0/0xb0
? __might_sleep+0x72/0xe0
? kasan_check_write+0x14/0x20
SyS_sendfile64+0xa4/0x120
? SyS_sendfile+0x150/0x150
? mark_held_locks+0x23/0xb0
? do_syscall_64+0xc0/0x3e0
? SyS_sendfile+0x150/0x150
do_syscall_64+0x1bc/0x3e0
? syscall_return_slowpath+0x240/0x240
? mark_held_locks+0x23/0xb0
? return_from_SYSCALL_64+0x2d/0x7a
? trace_hardirqs_on_caller+0x182/0x260
? trace_hardirqs_on_thunk+0x1a/0x1c
entry_SYSCALL64_slow_path+0x25/0x25
RIP: 0033:0x7fdbc02dd219
RSP: 002b:00007ffc5024fa48 EFLAGS: 00000246
ORIG_RAX: 0000000000000028
RAX: ffffffffffffffda RBX: 0000000000000028 RCX: 00007fdbc02dd219
RDX: 00007fdbbe348000 RSI: 0000000000000011 RDI: 0000000000000015
RBP: 00007ffc5024faf0 R08: 000000000000006d R09: 0094e82f2c730a50
R10: 0000000000001000 R11: 0000000000000246 R12: 0000000000000002
R13: 00007fdbc0885058 R14: 00007fdbc09b2698 R15: 00007fdbc0885000
---[ end trace a5847ef0f7be7e20 ]---
asked to read 4096, claims to have read 1
actual size of data in pipe 4096
[0:4096]
f_op: ffffffffa058c920, f_flags: 49154, pos: 0/1, size: 0
I'm still trying to narrow down an exact reproducer, but it seems having
trinity do a combination of sendfile & writev, with pipes and regular
files as fd's is the best repro.
Is this a real problem, or am I chasing ghosts ? That it doesn't happen
on ext4 or btrfs is making me wonder...
Dave
[1] https://lkml.org/lkml/2017/4/11/921
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-08-28 20:31 ` iov_iter_pipe warning Dave Jones
@ 2017-08-29 4:25 ` Darrick J. Wong
2017-08-30 17:05 ` Dave Jones
2017-09-06 20:03 ` Dave Jones
0 siblings, 2 replies; 30+ messages in thread
From: Darrick J. Wong @ 2017-08-29 4:25 UTC (permalink / raw)
To: Dave Jones, Al Viro, Linux Kernel, linux-xfs
On Mon, Aug 28, 2017 at 04:31:30PM -0400, Dave Jones wrote:
> On Mon, Aug 07, 2017 at 04:18:18PM -0400, Dave Jones wrote:
> > On Fri, Apr 28, 2017 at 06:20:25PM +0100, Al Viro wrote:
> > > On Fri, Apr 28, 2017 at 12:50:24PM -0400, Dave Jones wrote:
> > > > currently running v4.11-rc8-75-gf83246089ca0
> > > >
> > > > sunrpc bit is for the other unrelated problem I'm chasing.
> > > >
> > > > note also, I saw the backtrace without the fs/splice.c changes.
> > >
> > > Interesting... Could you add this and see if that triggers?
> > >
> > > diff --git a/fs/splice.c b/fs/splice.c
> > > index 540c4a44756c..12a12d9c313f 100644
> > > --- a/fs/splice.c
> > > +++ b/fs/splice.c
> > > @@ -306,6 +306,9 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
> > > kiocb.ki_pos = *ppos;
> > > ret = call_read_iter(in, &kiocb, &to);
> > > if (ret > 0) {
> > > + if (WARN_ON(iov_iter_count(&to) != len - ret))
> > > + printk(KERN_ERR "ops %p: was %zd, left %zd, returned %d\n",
> > > + in->f_op, len, iov_iter_count(&to), ret);
> > > *ppos = kiocb.ki_pos;
> > > file_accessed(in);
> > > } else if (ret < 0) {
> >
> > Hey Al,
> > Due to a git stash screw up on my part, I've had this leftover WARN_ON
> > in my tree for the last couple months. (That screw-up might turn out to be
> > serendipitous if this is a real bug..)
> >
> > Today I decided to change things up and beat up on xfs for a change, and
> > was able to trigger this again.
> >
> > Is this check no longer valid, or am I triggering the same bug we were chased
> > down in nfs, but now in xfs ? (None of the other detritus from that debugging
> > back in April made it, just those three lines above).
>
> Revisiting this. I went back and dug out some of the other debug diffs [1]
> from that old thread.
>
> I can easily trigger this spew on xfs.
>
>
> WARNING: CPU: 1 PID: 2251 at fs/splice.c:292 test_it+0xd4/0x1d0
> CPU: 1 PID: 2251 Comm: trinity-c42 Not tainted 4.13.0-rc7-think+ #1
> task: ffff880459173a40 task.stack: ffff88044f7d0000
> RIP: 0010:test_it+0xd4/0x1d0
> RSP: 0018:ffff88044f7d7878 EFLAGS: 00010283
> RAX: 0000000000000000 RBX: ffff88044f44b968 RCX: ffffffff81511ea0
> RDX: 0000000000000003 RSI: dffffc0000000000 RDI: ffff88044f44ba68
> RBP: ffff88044f7d78c8 R08: ffff88046b218ec0 R09: 0000000000000000
> R10: ffff88044f7d7518 R11: 0000000000000000 R12: 0000000000001000
> R13: 0000000000000001 R14: 00000000ffffffff R15: 0000000000000001
> FS: 00007fdbc09b2700(0000) GS:ffff88046b200000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 0000000000000000 CR3: 0000000459e1d000 CR4: 00000000001406e0
> Call Trace:
> generic_file_splice_read+0x414/0x4e0
> ? opipe_prep.part.14+0x180/0x180
> ? lockdep_init_map+0xb2/0x2b0
> ? rw_verify_area+0x65/0x150
> do_splice_to+0xab/0xc0
> splice_direct_to_actor+0x1f5/0x540
> ? generic_pipe_buf_nosteal+0x10/0x10
> ? do_splice_to+0xc0/0xc0
> ? rw_verify_area+0x9d/0x150
> do_splice_direct+0x1b9/0x230
> ? splice_direct_to_actor+0x540/0x540
> ? __sb_start_write+0x164/0x1c0
> ? do_sendfile+0x7b3/0x840
> do_sendfile+0x428/0x840
> ? do_compat_pwritev64+0xb0/0xb0
> ? __might_sleep+0x72/0xe0
> ? kasan_check_write+0x14/0x20
> SyS_sendfile64+0xa4/0x120
> ? SyS_sendfile+0x150/0x150
> ? mark_held_locks+0x23/0xb0
> ? do_syscall_64+0xc0/0x3e0
> ? SyS_sendfile+0x150/0x150
> do_syscall_64+0x1bc/0x3e0
> ? syscall_return_slowpath+0x240/0x240
> ? mark_held_locks+0x23/0xb0
> ? return_from_SYSCALL_64+0x2d/0x7a
> ? trace_hardirqs_on_caller+0x182/0x260
> ? trace_hardirqs_on_thunk+0x1a/0x1c
> entry_SYSCALL64_slow_path+0x25/0x25
> RIP: 0033:0x7fdbc02dd219
> RSP: 002b:00007ffc5024fa48 EFLAGS: 00000246
> ORIG_RAX: 0000000000000028
> RAX: ffffffffffffffda RBX: 0000000000000028 RCX: 00007fdbc02dd219
> RDX: 00007fdbbe348000 RSI: 0000000000000011 RDI: 0000000000000015
> RBP: 00007ffc5024faf0 R08: 000000000000006d R09: 0094e82f2c730a50
> R10: 0000000000001000 R11: 0000000000000246 R12: 0000000000000002
> R13: 00007fdbc0885058 R14: 00007fdbc09b2698 R15: 00007fdbc0885000
> ---[ end trace a5847ef0f7be7e20 ]---
> asked to read 4096, claims to have read 1
> actual size of data in pipe 4096
> [0:4096]
> f_op: ffffffffa058c920, f_flags: 49154, pos: 0/1, size: 0
>
>
> I'm still trying to narrow down an exact reproducer, but it seems having
> trinity do a combination of sendfile & writev, with pipes and regular
> files as fd's is the best repro.
>
> Is this a real problem, or am I chasing ghosts ? That it doesn't happen
> on ext4 or btrfs is making me wonder...
<shrug> I haven't heard of any problems w/ directio xfs lately, but OTOH
I think it's the only filesystem that uses iomap_dio_rw, which would
explain why ext4/btrfs don't have this problem.
Granted that's idle speculation; is there a reproducer/xfstest for this?
--D
>
> Dave
>
>
> [1] https://lkml.org/lkml/2017/4/11/921
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-08-29 4:25 ` Darrick J. Wong
@ 2017-08-30 17:05 ` Dave Jones
2017-08-30 17:13 ` Darrick J. Wong
2017-09-06 20:03 ` Dave Jones
1 sibling, 1 reply; 30+ messages in thread
From: Dave Jones @ 2017-08-30 17:05 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Al Viro, Linux Kernel, linux-xfs
On Mon, Aug 28, 2017 at 09:25:42PM -0700, Darrick J. Wong wrote:
> On Mon, Aug 28, 2017 at 04:31:30PM -0400, Dave Jones wrote:
> > On Mon, Aug 07, 2017 at 04:18:18PM -0400, Dave Jones wrote:
> > > On Fri, Apr 28, 2017 at 06:20:25PM +0100, Al Viro wrote:
> > > > On Fri, Apr 28, 2017 at 12:50:24PM -0400, Dave Jones wrote:
> > > >
> > > > diff --git a/fs/splice.c b/fs/splice.c
> > > > index 540c4a44756c..12a12d9c313f 100644
> > > > --- a/fs/splice.c
> > > > +++ b/fs/splice.c
> > > > @@ -306,6 +306,9 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
> > > > kiocb.ki_pos = *ppos;
> > > > ret = call_read_iter(in, &kiocb, &to);
> > > > if (ret > 0) {
> > > > + if (WARN_ON(iov_iter_count(&to) != len - ret))
> > > > + printk(KERN_ERR "ops %p: was %zd, left %zd, returned %d\n",
> > > > + in->f_op, len, iov_iter_count(&to), ret);
> > > > *ppos = kiocb.ki_pos;
> > > > file_accessed(in);
> > > > } else if (ret < 0) {
> > >
> > > Hey Al,
> > > Due to a git stash screw up on my part, I've had this leftover WARN_ON
> > > in my tree for the last couple months. (That screw-up might turn out to be
> > > serendipitous if this is a real bug..)
> > >
> > > Today I decided to change things up and beat up on xfs for a change, and
> > > was able to trigger this again.
> > >
> > > Is this check no longer valid, or am I triggering the same bug we were chased
> > > down in nfs, but now in xfs ? (None of the other detritus from that debugging
> > > back in April made it, just those three lines above).
> >
> > Revisiting this. I went back and dug out some of the other debug diffs [1]
> > from that old thread.
> >
> > I can easily trigger this spew on xfs.
> >
> > ...
> >
> > asked to read 4096, claims to have read 1
> > actual size of data in pipe 4096
> > [0:4096]
> > f_op: ffffffffa058c920, f_flags: 49154, pos: 0/1, size: 0
> >
> >
> > I'm still trying to narrow down an exact reproducer, but it seems having
> > trinity do a combination of sendfile & writev, with pipes and regular
> > files as fd's is the best repro.
> >
> > Is this a real problem, or am I chasing ghosts ? That it doesn't happen
> > on ext4 or btrfs is making me wonder...
>
> <shrug> I haven't heard of any problems w/ directio xfs lately, but OTOH
> I think it's the only filesystem that uses iomap_dio_rw, which would
> explain why ext4/btrfs don't have this problem.
>
> Granted that's idle speculation; is there a reproducer/xfstest for this?
I reverted the debug patches mentioned above, and ran trinity for a while again,
and got this which smells really suspiciously related
WARNING: CPU: 1 PID: 10380 at fs/iomap.c:993 iomap_dio_rw+0x825/0x840
CPU: 1 PID: 10380 Comm: trinity-c30 Not tainted 4.13.0-rc7-think+ #3
task: ffff8804613a5740 task.stack: ffff880432120000
RIP: 0010:iomap_dio_rw+0x825/0x840
RSP: 0018:ffff880432127890 EFLAGS: 00010286
RAX: 00000000fffffff0 RBX: ffff88046a64d0e8 RCX: 0000000000000000
RDX: ffffed0086424e9b RSI: 0000000000000000 RDI: ffffed0086424f03
RBP: ffff880432127a70 R08: ffff88046b239840 R09: 0000000000000001
R10: ffff880432126f50 R11: 0000000000000000 R12: ffff880432127c40
R13: 0000000000000e0a R14: 1ffff10086424f20 R15: ffff880432127ca0
FS: 00007f4cda32f700(0000) GS:ffff88046b200000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f181e02f000 CR3: 000000043d32a000 CR4: 00000000001406e0
Call Trace:
? iomap_seek_data+0xc0/0xc0
? down_read_non_owner+0x40/0x40
? xfs_ilock+0x3f2/0x490 [xfs]
? touch_atime+0x9c/0x180
? __atime_needs_update+0x440/0x440
xfs_file_dio_aio_read+0x12d/0x390 [xfs]
? xfs_file_dio_aio_read+0x12d/0x390 [xfs]
? xfs_file_fallocate+0x660/0x660 [xfs]
? cyc2ns_read_end+0x10/0x10
xfs_file_read_iter+0x1bb/0x1d0 [xfs]
__vfs_read+0x332/0x440
? default_llseek+0x140/0x140
? cyc2ns_read_end+0x10/0x10
? __fget_light+0x1ae/0x230
? rcu_is_watching+0x8d/0xd0
? exit_to_usermode_loop+0x1b0/0x1b0
? rw_verify_area+0x9d/0x150
vfs_read+0xc8/0x1c0
SyS_pread64+0x11a/0x140
? SyS_write+0x160/0x160
? do_syscall_64+0xc0/0x3e0
? SyS_write+0x160/0x160
do_syscall_64+0x1bc/0x3e0
? syscall_return_slowpath+0x240/0x240
? cpumask_check.part.2+0x10/0x10
? cpumask_check.part.2+0x10/0x10
? mark_held_locks+0x23/0xb0
? return_from_SYSCALL_64+0x2d/0x7a
? trace_hardirqs_on_caller+0x182/0x260
? trace_hardirqs_on_thunk+0x1a/0x1c
entry_SYSCALL64_slow_path+0x25/0x25
RIP: 0033:0x7f4cd9c5a219
RSP: 002b:00007ffce0d90888 EFLAGS: 00000246
ORIG_RAX: 0000000000000011
RAX: ffffffffffffffda RBX: 0000000000000011 RCX: 00007f4cd9c5a219
RDX: 0000000000000e0a RSI: 00007f4cd7ec5000 RDI: 000000000000000f
RBP: 00007ffce0d90930 R08: fffffffffffffffd R09: 000000000000001b
R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000002
R13: 00007f4cda256058 R14: 00007f4cda32f698 R15: 00007f4cda256000
Code: 83 bd 78 08 00 00 00 f 85 8e fd ff ff 4c 89 ef e8 d1 46 fa ff 85 c0 89 c2 0f 89 7c fd ff ff 31 c0 f0 0f b1 53 28 e9 70 fd ff ff <0f> ff e9 82 fc ff ff 48 c7 c1 f4 ff ff ff e9 0d f9 ff ff e8 93
---[ end trace 2f6189daedf1df6e ]---
That's this..
987 ret = filemap_write_and_wait_range(mapping, start, end);
988 if (ret)
989 goto out_free_dio;
990
991 ret = invalidate_inode_pages2_range(mapping,
992 start >> PAGE_SHIFT, end >> PAGE_SHIFT);
993 WARN_ON_ONCE(ret);
Plot thickens..
Dave
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-08-30 17:05 ` Dave Jones
@ 2017-08-30 17:13 ` Darrick J. Wong
2017-08-30 17:17 ` Dave Jones
0 siblings, 1 reply; 30+ messages in thread
From: Darrick J. Wong @ 2017-08-30 17:13 UTC (permalink / raw)
To: Dave Jones, Al Viro, Linux Kernel, linux-xfs
On Wed, Aug 30, 2017 at 01:05:23PM -0400, Dave Jones wrote:
> On Mon, Aug 28, 2017 at 09:25:42PM -0700, Darrick J. Wong wrote:
> > On Mon, Aug 28, 2017 at 04:31:30PM -0400, Dave Jones wrote:
> > > On Mon, Aug 07, 2017 at 04:18:18PM -0400, Dave Jones wrote:
> > > > On Fri, Apr 28, 2017 at 06:20:25PM +0100, Al Viro wrote:
> > > > > On Fri, Apr 28, 2017 at 12:50:24PM -0400, Dave Jones wrote:
> > > > >
> > > > > diff --git a/fs/splice.c b/fs/splice.c
> > > > > index 540c4a44756c..12a12d9c313f 100644
> > > > > --- a/fs/splice.c
> > > > > +++ b/fs/splice.c
> > > > > @@ -306,6 +306,9 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
> > > > > kiocb.ki_pos = *ppos;
> > > > > ret = call_read_iter(in, &kiocb, &to);
> > > > > if (ret > 0) {
> > > > > + if (WARN_ON(iov_iter_count(&to) != len - ret))
> > > > > + printk(KERN_ERR "ops %p: was %zd, left %zd, returned %d\n",
> > > > > + in->f_op, len, iov_iter_count(&to), ret);
> > > > > *ppos = kiocb.ki_pos;
> > > > > file_accessed(in);
> > > > > } else if (ret < 0) {
> > > >
> > > > Hey Al,
> > > > Due to a git stash screw up on my part, I've had this leftover WARN_ON
> > > > in my tree for the last couple months. (That screw-up might turn out to be
> > > > serendipitous if this is a real bug..)
> > > >
> > > > Today I decided to change things up and beat up on xfs for a change, and
> > > > was able to trigger this again.
> > > >
> > > > Is this check no longer valid, or am I triggering the same bug we were chased
> > > > down in nfs, but now in xfs ? (None of the other detritus from that debugging
> > > > back in April made it, just those three lines above).
> > >
> > > Revisiting this. I went back and dug out some of the other debug diffs [1]
> > > from that old thread.
> > >
> > > I can easily trigger this spew on xfs.
> > >
> > > ...
> > >
> > > asked to read 4096, claims to have read 1
> > > actual size of data in pipe 4096
> > > [0:4096]
> > > f_op: ffffffffa058c920, f_flags: 49154, pos: 0/1, size: 0
> > >
> > >
> > > I'm still trying to narrow down an exact reproducer, but it seems having
> > > trinity do a combination of sendfile & writev, with pipes and regular
> > > files as fd's is the best repro.
> > >
> > > Is this a real problem, or am I chasing ghosts ? That it doesn't happen
> > > on ext4 or btrfs is making me wonder...
> >
> > <shrug> I haven't heard of any problems w/ directio xfs lately, but OTOH
> > I think it's the only filesystem that uses iomap_dio_rw, which would
> > explain why ext4/btrfs don't have this problem.
> >
> > Granted that's idle speculation; is there a reproducer/xfstest for this?
>
> I reverted the debug patches mentioned above, and ran trinity for a while again,
> and got this which smells really suspiciously related
>
> WARNING: CPU: 1 PID: 10380 at fs/iomap.c:993 iomap_dio_rw+0x825/0x840
> CPU: 1 PID: 10380 Comm: trinity-c30 Not tainted 4.13.0-rc7-think+ #3
> task: ffff8804613a5740 task.stack: ffff880432120000
> RIP: 0010:iomap_dio_rw+0x825/0x840
> RSP: 0018:ffff880432127890 EFLAGS: 00010286
> RAX: 00000000fffffff0 RBX: ffff88046a64d0e8 RCX: 0000000000000000
> RDX: ffffed0086424e9b RSI: 0000000000000000 RDI: ffffed0086424f03
> RBP: ffff880432127a70 R08: ffff88046b239840 R09: 0000000000000001
> R10: ffff880432126f50 R11: 0000000000000000 R12: ffff880432127c40
> R13: 0000000000000e0a R14: 1ffff10086424f20 R15: ffff880432127ca0
> FS: 00007f4cda32f700(0000) GS:ffff88046b200000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007f181e02f000 CR3: 000000043d32a000 CR4: 00000000001406e0
> Call Trace:
> ? iomap_seek_data+0xc0/0xc0
> ? down_read_non_owner+0x40/0x40
> ? xfs_ilock+0x3f2/0x490 [xfs]
> ? touch_atime+0x9c/0x180
> ? __atime_needs_update+0x440/0x440
> xfs_file_dio_aio_read+0x12d/0x390 [xfs]
> ? xfs_file_dio_aio_read+0x12d/0x390 [xfs]
> ? xfs_file_fallocate+0x660/0x660 [xfs]
> ? cyc2ns_read_end+0x10/0x10
> xfs_file_read_iter+0x1bb/0x1d0 [xfs]
> __vfs_read+0x332/0x440
> ? default_llseek+0x140/0x140
> ? cyc2ns_read_end+0x10/0x10
> ? __fget_light+0x1ae/0x230
> ? rcu_is_watching+0x8d/0xd0
> ? exit_to_usermode_loop+0x1b0/0x1b0
> ? rw_verify_area+0x9d/0x150
> vfs_read+0xc8/0x1c0
> SyS_pread64+0x11a/0x140
> ? SyS_write+0x160/0x160
> ? do_syscall_64+0xc0/0x3e0
> ? SyS_write+0x160/0x160
> do_syscall_64+0x1bc/0x3e0
> ? syscall_return_slowpath+0x240/0x240
> ? cpumask_check.part.2+0x10/0x10
> ? cpumask_check.part.2+0x10/0x10
> ? mark_held_locks+0x23/0xb0
> ? return_from_SYSCALL_64+0x2d/0x7a
> ? trace_hardirqs_on_caller+0x182/0x260
> ? trace_hardirqs_on_thunk+0x1a/0x1c
> entry_SYSCALL64_slow_path+0x25/0x25
> RIP: 0033:0x7f4cd9c5a219
> RSP: 002b:00007ffce0d90888 EFLAGS: 00000246
> ORIG_RAX: 0000000000000011
> RAX: ffffffffffffffda RBX: 0000000000000011 RCX: 00007f4cd9c5a219
> RDX: 0000000000000e0a RSI: 00007f4cd7ec5000 RDI: 000000000000000f
> RBP: 00007ffce0d90930 R08: fffffffffffffffd R09: 000000000000001b
> R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000002
> R13: 00007f4cda256058 R14: 00007f4cda32f698 R15: 00007f4cda256000
> Code: 83 bd 78 08 00 00 00 f 85 8e fd ff ff 4c 89 ef e8 d1 46 fa ff 85 c0 89 c2 0f 89 7c fd ff ff 31 c0 f0 0f b1 53 28 e9 70 fd ff ff <0f> ff e9 82 fc ff ff 48 c7 c1 f4 ff ff ff e9 0d f9 ff ff e8 93
> ---[ end trace 2f6189daedf1df6e ]---
>
>
>
> That's this..
>
> 987 ret = filemap_write_and_wait_range(mapping, start, end);
> 988 if (ret)
> 989 goto out_free_dio;
> 990
> 991 ret = invalidate_inode_pages2_range(mapping,
> 992 start >> PAGE_SHIFT, end >> PAGE_SHIFT);
> 993 WARN_ON_ONCE(ret);
>
>
> Plot thickens..
Hm, that's the WARN_ON that comes from a failed pagecache invalidation
prior to a dio operation, which implies that something's mixing buffered
and dio?
Given that it's syzkaller it wouldn't surprise me to hear that it's
doing that... :)
--D
>
> Dave
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-08-30 17:13 ` Darrick J. Wong
@ 2017-08-30 17:17 ` Dave Jones
0 siblings, 0 replies; 30+ messages in thread
From: Dave Jones @ 2017-08-30 17:17 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Al Viro, Linux Kernel, linux-xfs
On Wed, Aug 30, 2017 at 10:13:43AM -0700, Darrick J. Wong wrote:
> > I reverted the debug patches mentioned above, and ran trinity for a while again,
> > and got this which smells really suspiciously related
> >
> > WARNING: CPU: 1 PID: 10380 at fs/iomap.c:993 iomap_dio_rw+0x825/0x840
> > RAX: 00000000fffffff0 RBX: ffff88046a64d0e8 RCX: 0000000000000000
> >
> >
> >
> > That's this..
> >
> > 987 ret = filemap_write_and_wait_range(mapping, start, end);
> > 988 if (ret)
> > 989 goto out_free_dio;
> > 990
> > 991 ret = invalidate_inode_pages2_range(mapping,
> > 992 start >> PAGE_SHIFT, end >> PAGE_SHIFT);
> > 993 WARN_ON_ONCE(ret);
> >
> >
> > Plot thickens..
>
> Hm, that's the WARN_ON that comes from a failed pagecache invalidation
> prior to a dio operation, which implies that something's mixing buffered
> and dio?
Plausible. Judging by RAX, we got -EBUSY
> Given that it's syzkaller it wouldn't surprise me to hear that it's
> doing that... :)
s/syzkaller/trinity/, but yes.
Dave
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-08-29 4:25 ` Darrick J. Wong
2017-08-30 17:05 ` Dave Jones
@ 2017-09-06 20:03 ` Dave Jones
2017-09-06 23:46 ` Dave Chinner
1 sibling, 1 reply; 30+ messages in thread
From: Dave Jones @ 2017-09-06 20:03 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Al Viro, Linux Kernel, linux-xfs
On Mon, Aug 28, 2017 at 09:25:42PM -0700, Darrick J. Wong wrote:
> On Mon, Aug 28, 2017 at 04:31:30PM -0400, Dave Jones wrote:
> > On Mon, Aug 07, 2017 at 04:18:18PM -0400, Dave Jones wrote:
> > > On Fri, Apr 28, 2017 at 06:20:25PM +0100, Al Viro wrote:
> > > > On Fri, Apr 28, 2017 at 12:50:24PM -0400, Dave Jones wrote:
> > > > > currently running v4.11-rc8-75-gf83246089ca0
> > > > >
> > > > > sunrpc bit is for the other unrelated problem I'm chasing.
> > > > >
> > > > > note also, I saw the backtrace without the fs/splice.c changes.
> > > >
> > > > Interesting... Could you add this and see if that triggers?
> > > >
> > > > diff --git a/fs/splice.c b/fs/splice.c
> > > > index 540c4a44756c..12a12d9c313f 100644
> > > > --- a/fs/splice.c
> > > > +++ b/fs/splice.c
> > > > @@ -306,6 +306,9 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
> > > > kiocb.ki_pos = *ppos;
> > > > ret = call_read_iter(in, &kiocb, &to);
> > > > if (ret > 0) {
> > > > + if (WARN_ON(iov_iter_count(&to) != len - ret))
> > > > + printk(KERN_ERR "ops %p: was %zd, left %zd, returned %d\n",
> > > > + in->f_op, len, iov_iter_count(&to), ret);
> > > > *ppos = kiocb.ki_pos;
> > > > file_accessed(in);
> > > > } else if (ret < 0) {
> > >
> > > Hey Al,
> > > Due to a git stash screw up on my part, I've had this leftover WARN_ON
> > > in my tree for the last couple months. (That screw-up might turn out to be
> > > serendipitous if this is a real bug..)
> > >
> > > Today I decided to change things up and beat up on xfs for a change, and
> > > was able to trigger this again.
> > >
> > > Is this check no longer valid, or am I triggering the same bug we were chased
> > > down in nfs, but now in xfs ? (None of the other detritus from that debugging
> > > back in April made it, just those three lines above).
> >
> > Revisiting this. I went back and dug out some of the other debug diffs [1]
> > from that old thread.
> >
> > I can easily trigger this spew on xfs.
> >
> >
> > WARNING: CPU: 1 PID: 2251 at fs/splice.c:292 test_it+0xd4/0x1d0
> > CPU: 1 PID: 2251 Comm: trinity-c42 Not tainted 4.13.0-rc7-think+ #1
> > task: ffff880459173a40 task.stack: ffff88044f7d0000
> > RIP: 0010:test_it+0xd4/0x1d0
> > RSP: 0018:ffff88044f7d7878 EFLAGS: 00010283
> > RAX: 0000000000000000 RBX: ffff88044f44b968 RCX: ffffffff81511ea0
> > RDX: 0000000000000003 RSI: dffffc0000000000 RDI: ffff88044f44ba68
> > RBP: ffff88044f7d78c8 R08: ffff88046b218ec0 R09: 0000000000000000
> > R10: ffff88044f7d7518 R11: 0000000000000000 R12: 0000000000001000
> > R13: 0000000000000001 R14: 00000000ffffffff R15: 0000000000000001
> > FS: 00007fdbc09b2700(0000) GS:ffff88046b200000(0000) knlGS:0000000000000000
> > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> > CR2: 0000000000000000 CR3: 0000000459e1d000 CR4: 00000000001406e0
> > Call Trace:
> > generic_file_splice_read+0x414/0x4e0
> > ? opipe_prep.part.14+0x180/0x180
> > ? lockdep_init_map+0xb2/0x2b0
> > ? rw_verify_area+0x65/0x150
> > do_splice_to+0xab/0xc0
> > splice_direct_to_actor+0x1f5/0x540
> > ? generic_pipe_buf_nosteal+0x10/0x10
> > ? do_splice_to+0xc0/0xc0
> > ? rw_verify_area+0x9d/0x150
> > do_splice_direct+0x1b9/0x230
> > ? splice_direct_to_actor+0x540/0x540
> > ? __sb_start_write+0x164/0x1c0
> > ? do_sendfile+0x7b3/0x840
> > do_sendfile+0x428/0x840
> > ? do_compat_pwritev64+0xb0/0xb0
> > ? __might_sleep+0x72/0xe0
> > ? kasan_check_write+0x14/0x20
> > SyS_sendfile64+0xa4/0x120
> > ? SyS_sendfile+0x150/0x150
> > ? mark_held_locks+0x23/0xb0
> > ? do_syscall_64+0xc0/0x3e0
> > ? SyS_sendfile+0x150/0x150
> > do_syscall_64+0x1bc/0x3e0
> > ? syscall_return_slowpath+0x240/0x240
> > ? mark_held_locks+0x23/0xb0
> > ? return_from_SYSCALL_64+0x2d/0x7a
> > ? trace_hardirqs_on_caller+0x182/0x260
> > ? trace_hardirqs_on_thunk+0x1a/0x1c
> > entry_SYSCALL64_slow_path+0x25/0x25
> > RIP: 0033:0x7fdbc02dd219
> > RSP: 002b:00007ffc5024fa48 EFLAGS: 00000246
> > ORIG_RAX: 0000000000000028
> > RAX: ffffffffffffffda RBX: 0000000000000028 RCX: 00007fdbc02dd219
> > RDX: 00007fdbbe348000 RSI: 0000000000000011 RDI: 0000000000000015
> > RBP: 00007ffc5024faf0 R08: 000000000000006d R09: 0094e82f2c730a50
> > R10: 0000000000001000 R11: 0000000000000246 R12: 0000000000000002
> > R13: 00007fdbc0885058 R14: 00007fdbc09b2698 R15: 00007fdbc0885000
> > ---[ end trace a5847ef0f7be7e20 ]---
> > asked to read 4096, claims to have read 1
> > actual size of data in pipe 4096
> > [0:4096]
> > f_op: ffffffffa058c920, f_flags: 49154, pos: 0/1, size: 0
> >
> >
> > I'm still trying to narrow down an exact reproducer, but it seems having
> > trinity do a combination of sendfile & writev, with pipes and regular
> > files as fd's is the best repro.
> >
> > Is this a real problem, or am I chasing ghosts ? That it doesn't happen
> > on ext4 or btrfs is making me wonder...
>
> <shrug> I haven't heard of any problems w/ directio xfs lately, but OTOH
> I think it's the only filesystem that uses iomap_dio_rw, which would
> explain why ext4/btrfs don't have this problem.
Another warning, from likely the same root cause.
WARNING: CPU: 3 PID: 572 at lib/iov_iter.c:962 iov_iter_pipe+0xe2/0xf0
CPU: 3 PID: 572 Comm: trinity-c45 Not tainted 4.13.0-think+ #5
task: ffff88042e5f8040 task.stack: ffff880454cb0000
RIP: 0010:iov_iter_pipe+0xe2/0xf0
RSP: 0018:ffff880454cb7950 EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffff880454cb79c0 RCX: ffffffff818fc581
RDX: 0000000000000003 RSI: dffffc0000000000 RDI: ffff88043f07fa80
RBP: ffff88043f07f968 R08: 0000000000000000 R09: 0000000000000000
R10: ffff880454cb7468 R11: 0000000000000000 R12: 000000000003fff8
R13: 0000000000000010 R14: ffff88043f07fa80 R15: ffff88043f07fa78
FS: 00007fac217a1700(0000) GS:ffff88046b400000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 000000043f37e001 CR4: 00000000001606e0
Call Trace:
generic_file_splice_read+0x8d/0x340
? pipe_unlock+0x15/0x30
? splice_from_pipe+0x10e/0x160
? pipe_to_user+0x80/0x80
? splice_shrink_spd+0x40/0x40
? init_wait_entry+0x100/0x100
? rw_verify_area+0x87/0x130
splice_direct_to_actor+0x186/0x420
? generic_pipe_buf_nosteal+0x10/0x10
? do_splice_to+0xc0/0xc0
? __fget_light+0x181/0x200
do_splice_direct+0x173/0x1e0
? splice_direct_to_actor+0x420/0x420
? mark_held_locks+0x1c/0x90
? retint_kernel+0x10/0x10
do_sendfile+0x3a2/0x6d0
? do_compat_pwritev64+0xa0/0xa0
? copy_user_generic_unrolled+0x83/0xb0
SyS_sendfile64+0xa4/0x130
? SyS_sendfile+0x140/0x140
? mark_held_locks+0x1c/0x90
? do_syscall_64+0xae/0x3e0
? SyS_sendfile+0x140/0x140
do_syscall_64+0x182/0x3e0
? syscall_return_slowpath+0x250/0x250
? rcu_read_lock_sched_held+0x90/0xa0
? __context_tracking_exit.part.5+0x226/0x290
? mark_held_locks+0x1c/0x90
? return_from_SYSCALL_64+0x2d/0x7a
? trace_hardirqs_on_caller+0x17a/0x250
? trace_hardirqs_on_thunk+0x1a/0x1c
entry_SYSCALL64_slow_path+0x25/0x25
RIP: 0033:0x7fac210cc219
RSP: 002b:00007ffd7fe8ab38 EFLAGS: 00000246
ORIG_RAX: 0000000000000028
RAX: ffffffffffffffda RBX: 0000000000000028 RCX: 00007fac210cc219
RDX: 00007fac215de000 RSI: 000000000000001b RDI: 000000000000000b
RBP: 00007ffd7fe8abe0 R08: 00000000c8c8c8c8 R09: 00000000000000c9
R10: 0000000000040000 R11: 0000000000000246 R12: 0000000000000002
R13: 00007fac2165f058 R14: 00007fac217a1698 R15: 00007fac2165f000
Code: 10 48 c7 43 08 00 00 00 00 e8 bb 79 b1 ff 4c 89 63 10 48 8d 7b 24 e8 ae 78 b1 ff 89 6b 24 5b 5d 41 5c 41 5d 41 5e 41 5f c3 0f 0b <0f> ff e9 65 ff ff ff 0f 1f 80 00 00 00 00 41 57 41 56 41 55 49
---[ end trace 4507dec15e49aca7 ]---
962 WARN_ON(pipe->nrbufs == pipe->buffers);
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-06 20:03 ` Dave Jones
@ 2017-09-06 23:46 ` Dave Chinner
2017-09-07 3:48 ` Dave Jones
2017-09-08 1:04 ` Al Viro
0 siblings, 2 replies; 30+ messages in thread
From: Dave Chinner @ 2017-09-06 23:46 UTC (permalink / raw)
To: Dave Jones, Darrick J. Wong, Al Viro, Linux Kernel, linux-xfs
On Wed, Sep 06, 2017 at 04:03:37PM -0400, Dave Jones wrote:
> On Mon, Aug 28, 2017 at 09:25:42PM -0700, Darrick J. Wong wrote:
> > On Mon, Aug 28, 2017 at 04:31:30PM -0400, Dave Jones wrote:
> > > I'm still trying to narrow down an exact reproducer, but it seems having
> > > trinity do a combination of sendfile & writev, with pipes and regular
> > > files as fd's is the best repro.
> > >
> > > Is this a real problem, or am I chasing ghosts ? That it doesn't happen
> > > on ext4 or btrfs is making me wonder...
> >
> > <shrug> I haven't heard of any problems w/ directio xfs lately, but OTOH
> > I think it's the only filesystem that uses iomap_dio_rw, which would
> > explain why ext4/btrfs don't have this problem.
>
> Another warning, from likely the same root cause.
>
> WARNING: CPU: 3 PID: 572 at lib/iov_iter.c:962 iov_iter_pipe+0xe2/0xf0
WARN_ON(pipe->nrbufs == pipe->buffers);
* @nrbufs: the number of non-empty pipe buffers in this pipe
* @buffers: total number of buffers (should be a power of 2)
So that's warning that the pipe buffer is already full before we
try to read from the filesystem?
That doesn't seem like an XFS problem - it indicates the pipe we are
filling in generic_file_splice_read() is not being emptied by
whatever we are splicing the file data to....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-06 23:46 ` Dave Chinner
@ 2017-09-07 3:48 ` Dave Jones
2017-09-07 4:33 ` Al Viro
2017-09-08 1:04 ` Al Viro
1 sibling, 1 reply; 30+ messages in thread
From: Dave Jones @ 2017-09-07 3:48 UTC (permalink / raw)
To: Dave Chinner; +Cc: Darrick J. Wong, Al Viro, Linux Kernel, linux-xfs
On Thu, Sep 07, 2017 at 09:46:17AM +1000, Dave Chinner wrote:
> On Wed, Sep 06, 2017 at 04:03:37PM -0400, Dave Jones wrote:
> > On Mon, Aug 28, 2017 at 09:25:42PM -0700, Darrick J. Wong wrote:
> > > On Mon, Aug 28, 2017 at 04:31:30PM -0400, Dave Jones wrote:
> > > > I'm still trying to narrow down an exact reproducer, but it seems having
> > > > trinity do a combination of sendfile & writev, with pipes and regular
> > > > files as fd's is the best repro.
> > > >
> > > > Is this a real problem, or am I chasing ghosts ? That it doesn't happen
> > > > on ext4 or btrfs is making me wonder...
> > >
> > > <shrug> I haven't heard of any problems w/ directio xfs lately, but OTOH
> > > I think it's the only filesystem that uses iomap_dio_rw, which would
> > > explain why ext4/btrfs don't have this problem.
> >
> > Another warning, from likely the same root cause.
> >
> > WARNING: CPU: 3 PID: 572 at lib/iov_iter.c:962 iov_iter_pipe+0xe2/0xf0
>
> WARN_ON(pipe->nrbufs == pipe->buffers);
>
> * @nrbufs: the number of non-empty pipe buffers in this pipe
> * @buffers: total number of buffers (should be a power of 2)
>
> So that's warning that the pipe buffer is already full before we
> try to read from the filesystem?
>
> That doesn't seem like an XFS problem - it indicates the pipe we are
> filling in generic_file_splice_read() is not being emptied by
> whatever we are splicing the file data to....
The puzzling part is this runs for a day on ext4 or btrfs, whereas I can
make xfs fall over pretty quickly. As Darrick pointed out though, this
could be due to xfs being the only user of iomap_dio_rw.
I'm juggling a few other things right now, so probably not going to
have much time to dig further on this until after plumbers + 1 wk.
Dave
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-07 3:48 ` Dave Jones
@ 2017-09-07 4:33 ` Al Viro
0 siblings, 0 replies; 30+ messages in thread
From: Al Viro @ 2017-09-07 4:33 UTC (permalink / raw)
To: Dave Jones, Dave Chinner, Darrick J. Wong, Linux Kernel,
linux-xfs
On Wed, Sep 06, 2017 at 11:48:35PM -0400, Dave Jones wrote:
> > That doesn't seem like an XFS problem - it indicates the pipe we are
> > filling in generic_file_splice_read() is not being emptied by
> > whatever we are splicing the file data to....
>
> The puzzling part is this runs for a day on ext4 or btrfs, whereas I can
> make xfs fall over pretty quickly. As Darrick pointed out though, this
> could be due to xfs being the only user of iomap_dio_rw.
>
> I'm juggling a few other things right now, so probably not going to
> have much time to dig further on this until after plumbers + 1 wk.
I'll look into that tomorrow...
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-06 23:46 ` Dave Chinner
2017-09-07 3:48 ` Dave Jones
@ 2017-09-08 1:04 ` Al Viro
2017-09-10 1:07 ` Dave Jones
1 sibling, 1 reply; 30+ messages in thread
From: Al Viro @ 2017-09-08 1:04 UTC (permalink / raw)
To: Dave Chinner; +Cc: Dave Jones, Darrick J. Wong, Linux Kernel, linux-xfs
On Thu, Sep 07, 2017 at 09:46:17AM +1000, Dave Chinner wrote:
> On Wed, Sep 06, 2017 at 04:03:37PM -0400, Dave Jones wrote:
> > On Mon, Aug 28, 2017 at 09:25:42PM -0700, Darrick J. Wong wrote:
> > > On Mon, Aug 28, 2017 at 04:31:30PM -0400, Dave Jones wrote:
> > > > I'm still trying to narrow down an exact reproducer, but it seems having
> > > > trinity do a combination of sendfile & writev, with pipes and regular
> > > > files as fd's is the best repro.
> > > >
> > > > Is this a real problem, or am I chasing ghosts ? That it doesn't happen
> > > > on ext4 or btrfs is making me wonder...
> > >
> > > <shrug> I haven't heard of any problems w/ directio xfs lately, but OTOH
> > > I think it's the only filesystem that uses iomap_dio_rw, which would
> > > explain why ext4/btrfs don't have this problem.
> >
> > Another warning, from likely the same root cause.
> >
> > WARNING: CPU: 3 PID: 572 at lib/iov_iter.c:962 iov_iter_pipe+0xe2/0xf0
>
> WARN_ON(pipe->nrbufs == pipe->buffers);
>
> * @nrbufs: the number of non-empty pipe buffers in this pipe
> * @buffers: total number of buffers (should be a power of 2)
>
> So that's warning that the pipe buffer is already full before we
> try to read from the filesystem?
>
> That doesn't seem like an XFS problem - it indicates the pipe we are
> filling in generic_file_splice_read() is not being emptied by
> whatever we are splicing the file data to....
Or that XFS in some conditions shoves into pipe more than it reports,
so not all of that gets emptied, filling the sucker up after sufficient
amount of iterations...
There's at least one suspicious place in iomap_dio_actor() -
if (!(dio->flags & IOMAP_DIO_WRITE)) {
iov_iter_zero(length, dio->submit.iter);
dio->size += length;
return length;
}
which assumes that iov_iter_zero() always succeeds. That's very
much _not_ true - neither for iovec-backed, not for pipe-backed.
Orangefs read_one_page() is fine (it calls that sucker for bvec-backed
iov_iter it's just created), but iomap_dio_actor() is not.
I'm not saying that it will suffice, but we definitely need this:
diff --git a/fs/iomap.c b/fs/iomap.c
index 269b24a01f32..4a671263475f 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -843,7 +843,7 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
/*FALLTHRU*/
case IOMAP_UNWRITTEN:
if (!(dio->flags & IOMAP_DIO_WRITE)) {
- iov_iter_zero(length, dio->submit.iter);
+ length = iov_iter_zero(length, dio->submit.iter);
dio->size += length;
return length;
}
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-08 1:04 ` Al Viro
@ 2017-09-10 1:07 ` Dave Jones
2017-09-10 2:57 ` Al Viro
0 siblings, 1 reply; 30+ messages in thread
From: Dave Jones @ 2017-09-10 1:07 UTC (permalink / raw)
To: Al Viro; +Cc: Dave Chinner, Darrick J. Wong, Linux Kernel, linux-xfs
On Fri, Sep 08, 2017 at 02:04:41AM +0100, Al Viro wrote:
> There's at least one suspicious place in iomap_dio_actor() -
> if (!(dio->flags & IOMAP_DIO_WRITE)) {
> iov_iter_zero(length, dio->submit.iter);
> dio->size += length;
> return length;
> }
> which assumes that iov_iter_zero() always succeeds. That's very
> much _not_ true - neither for iovec-backed, not for pipe-backed.
> Orangefs read_one_page() is fine (it calls that sucker for bvec-backed
> iov_iter it's just created), but iomap_dio_actor() is not.
>
> I'm not saying that it will suffice, but we definitely need this:
>
> diff --git a/fs/iomap.c b/fs/iomap.c
> index 269b24a01f32..4a671263475f 100644
> --- a/fs/iomap.c
> +++ b/fs/iomap.c
> @@ -843,7 +843,7 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
> /*FALLTHRU*/
> case IOMAP_UNWRITTEN:
> if (!(dio->flags & IOMAP_DIO_WRITE)) {
> - iov_iter_zero(length, dio->submit.iter);
> + length = iov_iter_zero(length, dio->submit.iter);
> dio->size += length;
> return length;
With this in place, I'm still seeing -EBUSY from invalidate_inode_pages2_range
which doesn't end well...
WARNING: CPU: 3 PID: 11443 at fs/iomap.c:993 iomap_dio_rw+0x825/0x840
CPU: 3 PID: 11443 Comm: trinity-c39 Not tainted 4.13.0-think+ #9
task: ffff880461080040 task.stack: ffff88043d720000
RIP: 0010:iomap_dio_rw+0x825/0x840
RSP: 0018:ffff88043d727730 EFLAGS: 00010286
RAX: 00000000fffffff0 RBX: ffff88044f036428 RCX: 0000000000000000
RDX: ffffed0087ae4e67 RSI: 0000000000000000 RDI: ffffed0087ae4ed7
RBP: ffff88043d727910 R08: ffff88046b4176c0 R09: 0000000000000000
R10: ffff88043d726d20 R11: 0000000000000001 R12: ffff88043d727a90
R13: 00000000027253f7 R14: 1ffff10087ae4ef4 R15: ffff88043d727c10
FS: 00007f5d8613e700(0000) GS:ffff88046b400000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f5d84503000 CR3: 00000004594e1000 CR4: 00000000001606e0
Call Trace:
? iomap_seek_data+0xb0/0xb0
? down_read_nested+0xd3/0x160
? down_read_non_owner+0x40/0x40
? xfs_ilock+0x3cb/0x460 [xfs]
? sched_clock_cpu+0x14/0xf0
? __lock_is_held+0x51/0xc0
? xfs_file_dio_aio_read+0x123/0x350 [xfs]
xfs_file_dio_aio_read+0x123/0x350 [xfs]
? xfs_file_fallocate+0x550/0x550 [xfs]
? lock_release+0xa00/0xa00
? ___might_sleep.part.70+0x118/0x320
xfs_file_read_iter+0x1b1/0x1d0 [xfs]
do_iter_readv_writev+0x2ea/0x330
? vfs_dedupe_file_range+0x400/0x400
do_iter_read+0x149/0x280
vfs_readv+0x107/0x180
? vfs_iter_read+0x60/0x60
? fget_raw+0x10/0x10
? native_sched_clock+0xf9/0x1a0
? __fdget_pos+0xd6/0x110
? __fdget_pos+0xd6/0x110
? __fdget_raw+0x10/0x10
? do_readv+0xc0/0x1b0
do_readv+0xc0/0x1b0
? vfs_readv+0x180/0x180
? mark_held_locks+0x1c/0x90
? do_syscall_64+0xae/0x3e0
? compat_rw_copy_check_uvector+0x1b0/0x1b0
do_syscall_64+0x182/0x3e0
? syscall_return_slowpath+0x250/0x250
? rcu_read_lock_sched_held+0x90/0xa0
? mark_held_locks+0x1c/0x90
? return_from_SYSCALL_64+0x2d/0x7a
? trace_hardirqs_on_caller+0x17a/0x250
? trace_hardirqs_on_thunk+0x1a/0x1c
entry_SYSCALL64_slow_path+0x25/0x25
RIP: 0033:0x7f5d85a69219
RSP: 002b:00007ffdf090afd8 EFLAGS: 00000246
ORIG_RAX: 0000000000000013
RAX: ffffffffffffffda RBX: 0000000000000013 RCX: 00007f5d85a69219
RDX: 00000000000000ae RSI: 0000565183cd5490 RDI: 0000000000000056
RBP: 00007ffdf090b080 R08: 0141082b00011c63 R09: 0000000000000000
R10: 00000000ffffe000 R11: 0000000000000246 R12: 0000000000000002
R13: 00007f5d86026058 R14: 00007f5d8613e698 R15: 00007f5d86026000
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-10 1:07 ` Dave Jones
@ 2017-09-10 2:57 ` Al Viro
2017-09-10 16:07 ` Dave Jones
2017-09-10 21:11 ` Dave Chinner
0 siblings, 2 replies; 30+ messages in thread
From: Al Viro @ 2017-09-10 2:57 UTC (permalink / raw)
To: Dave Jones, Dave Chinner, Darrick J. Wong, Linux Kernel,
linux-xfs
On Sat, Sep 09, 2017 at 09:07:56PM -0400, Dave Jones wrote:
> With this in place, I'm still seeing -EBUSY from invalidate_inode_pages2_range
> which doesn't end well...
Different issue, and I'm not sure why that WARN_ON() is there in the
first place. Note that in a similar situation generic_file_direct_write()
simply buggers off and lets the caller do buffered write...
iov_iter_pipe() warning is a sign of ->read_iter() on pipe-backed iov_iter
putting into the pipe more than it claims to have done.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-10 2:57 ` Al Viro
@ 2017-09-10 16:07 ` Dave Jones
2017-09-10 20:05 ` Al Viro
2017-09-10 21:11 ` Dave Chinner
1 sibling, 1 reply; 30+ messages in thread
From: Dave Jones @ 2017-09-10 16:07 UTC (permalink / raw)
To: Al Viro; +Cc: Dave Chinner, Darrick J. Wong, Linux Kernel, linux-xfs
On Sun, Sep 10, 2017 at 03:57:21AM +0100, Al Viro wrote:
> On Sat, Sep 09, 2017 at 09:07:56PM -0400, Dave Jones wrote:
>
> > With this in place, I'm still seeing -EBUSY from invalidate_inode_pages2_range
> > which doesn't end well...
>
> Different issue, and I'm not sure why that WARN_ON() is there in the
> first place. Note that in a similar situation generic_file_direct_write()
> simply buggers off and lets the caller do buffered write...
>
> iov_iter_pipe() warning is a sign of ->read_iter() on pipe-backed iov_iter
> putting into the pipe more than it claims to have done.
(from a rerun after hitting that EBUSY warn; hence the taint)
WARNING: CPU: 0 PID: 14154 at fs/iomap.c:1055 iomap_dio_rw+0x78e/0x840
CPU: 0 PID: 14154 Comm: trinity-c33 Tainted: G W 4.13.0-think+ #9
task: ffff8801027e3e40 task.stack: ffff8801632d8000
RIP: 0010:iomap_dio_rw+0x78e/0x840
RSP: 0018:ffff8801632df370 EFLAGS: 00010286
RAX: 00000000fffffff0 RBX: ffff880428666428 RCX: ffffffffffffffea
RDX: ffffed002c65bdef RSI: 0000000000000000 RDI: ffffed002c65be5f
RBP: ffff8801632df550 R08: ffff88046ae176c0 R09: 0000000000000000
R10: ffff8801632de960 R11: 0000000000000001 R12: ffff8801632df7f0
R13: ffffffffffffffea R14: 1ffff1002c65be7c R15: ffff8801632df988
FS: 00007f3da2100700(0000) GS:ffff88046ae00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 00000002f6223001 CR4: 00000000001606f0
DR0: 00007f3da1f3d000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600
Call Trace:
? iomap_seek_data+0xb0/0xb0
? find_inode_fast+0xd0/0xd0
? xfs_file_aio_write_checks+0x295/0x320 [xfs]
? __lock_is_held+0x51/0xc0
? xfs_file_dio_aio_write+0x286/0x7e0 [xfs]
? rcu_read_lock_sched_held+0x90/0xa0
xfs_file_dio_aio_write+0x286/0x7e0 [xfs]
? xfs_file_aio_write_checks+0x320/0x320 [xfs]
? unwind_get_return_address+0x2f/0x50
? __save_stack_trace+0x92/0x100
? memcmp+0x45/0x70
? depot_save_stack+0x12e/0x480
? save_stack+0x89/0xb0
? save_stack+0x32/0xb0
? kasan_kmalloc+0xa0/0xd0
? __kmalloc+0x157/0x360
? iter_file_splice_write+0x154/0x760
? direct_splice_actor+0x86/0xa0
? splice_direct_to_actor+0x1c4/0x420
? do_splice_direct+0x173/0x1e0
? do_sendfile+0x3a2/0x6d0
? SyS_sendfile64+0xa4/0x130
? do_syscall_64+0x182/0x3e0
? entry_SYSCALL64_slow_path+0x25/0x25
? match_held_lock+0xa6/0x410
? iter_file_splice_write+0x154/0x760
xfs_file_write_iter+0x227/0x280 [xfs]
do_iter_readv_writev+0x267/0x330
? vfs_dedupe_file_range+0x400/0x400
do_iter_write+0xd7/0x280
? splice_from_pipe_next.part.9+0x28/0x160
iter_file_splice_write+0x4d5/0x760
? page_cache_pipe_buf_steal+0x2b0/0x2b0
? generic_file_splice_read+0x2e1/0x340
? pipe_to_user+0x80/0x80
direct_splice_actor+0x86/0xa0
splice_direct_to_actor+0x1c4/0x420
? generic_pipe_buf_nosteal+0x10/0x10
? do_splice_to+0xc0/0xc0
do_splice_direct+0x173/0x1e0
? splice_direct_to_actor+0x420/0x420
? rcu_read_lock_sched_held+0x90/0xa0
? rcu_sync_lockdep_assert+0x43/0x70
? __sb_start_write+0x179/0x1e0
do_sendfile+0x3a2/0x6d0
? do_compat_pwritev64+0xa0/0xa0
? __lock_is_held+0x2e/0xc0
SyS_sendfile64+0xa4/0x130
? SyS_sendfile+0x140/0x140
? mark_held_locks+0x1c/0x90
? do_syscall_64+0xae/0x3e0
? SyS_sendfile+0x140/0x140
do_syscall_64+0x182/0x3e0
? syscall_return_slowpath+0x250/0x250
? rcu_read_lock_sched_held+0x90/0xa0
? __context_tracking_exit.part.4+0x223/0x290
? mark_held_locks+0x1c/0x90
? return_from_SYSCALL_64+0x2d/0x7a
? trace_hardirqs_on_caller+0x17a/0x250
? trace_hardirqs_on_thunk+0x1a/0x1c
entry_SYSCALL64_slow_path+0x25/0x25
RIP: 0033:0x7f3da1a2b219
RSP: 002b:00007ffdd1642f38 EFLAGS: 00000246
ORIG_RAX: 0000000000000028
RAX: ffffffffffffffda RBX: 0000000000000028 RCX: 00007f3da1a2b219
RDX: 00007f3da1f3d000 RSI: 000000000000005f RDI: 0000000000000060
RBP: 00007ffdd1642fe0 R08: 30503123188dbe3f R09: ffffffffe7e7e7e7
R10: 000000000000f000 R11: 0000000000000246 R12: 0000000000000002
R13: 00007f3da2012058 R14: 00007f3da2100698 R15: 00007f3da2012000
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-10 16:07 ` Dave Jones
@ 2017-09-10 20:05 ` Al Viro
2017-09-10 20:07 ` Dave Jones
0 siblings, 1 reply; 30+ messages in thread
From: Al Viro @ 2017-09-10 20:05 UTC (permalink / raw)
To: Dave Jones, Dave Chinner, Darrick J. Wong, Linux Kernel,
linux-xfs
On Sun, Sep 10, 2017 at 12:07:10PM -0400, Dave Jones wrote:
> On Sun, Sep 10, 2017 at 03:57:21AM +0100, Al Viro wrote:
> > On Sat, Sep 09, 2017 at 09:07:56PM -0400, Dave Jones wrote:
> >
> > > With this in place, I'm still seeing -EBUSY from invalidate_inode_pages2_range
> > > which doesn't end well...
> >
> > Different issue, and I'm not sure why that WARN_ON() is there in the
> > first place. Note that in a similar situation generic_file_direct_write()
> > simply buggers off and lets the caller do buffered write...
> >
> > iov_iter_pipe() warning is a sign of ->read_iter() on pipe-backed iov_iter
> > putting into the pipe more than it claims to have done.
>
> (from a rerun after hitting that EBUSY warn; hence the taint)
>
> WARNING: CPU: 0 PID: 14154 at fs/iomap.c:1055 iomap_dio_rw+0x78e/0x840
... and that's another invalidate_inode_pages2_range() in the same
sucker. Again, compare with generic_file_direct_write()...
I don't believe that this one has anything splice-specific to do with it.
And its only relation to iov_iter_pipe() splat is that it's in the same
fs/iomap.c...
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-10 20:05 ` Al Viro
@ 2017-09-10 20:07 ` Dave Jones
2017-09-10 20:33 ` Al Viro
0 siblings, 1 reply; 30+ messages in thread
From: Dave Jones @ 2017-09-10 20:07 UTC (permalink / raw)
To: Al Viro; +Cc: Dave Chinner, Darrick J. Wong, Linux Kernel, linux-xfs
On Sun, Sep 10, 2017 at 09:05:48PM +0100, Al Viro wrote:
> On Sun, Sep 10, 2017 at 12:07:10PM -0400, Dave Jones wrote:
> > On Sun, Sep 10, 2017 at 03:57:21AM +0100, Al Viro wrote:
> > > On Sat, Sep 09, 2017 at 09:07:56PM -0400, Dave Jones wrote:
> > >
> > > > With this in place, I'm still seeing -EBUSY from invalidate_inode_pages2_range
> > > > which doesn't end well...
> > >
> > > Different issue, and I'm not sure why that WARN_ON() is there in the
> > > first place. Note that in a similar situation generic_file_direct_write()
> > > simply buggers off and lets the caller do buffered write...
> > >
> > > iov_iter_pipe() warning is a sign of ->read_iter() on pipe-backed iov_iter
> > > putting into the pipe more than it claims to have done.
> >
> > (from a rerun after hitting that EBUSY warn; hence the taint)
> >
> > WARNING: CPU: 0 PID: 14154 at fs/iomap.c:1055 iomap_dio_rw+0x78e/0x840
>
> ... and that's another invalidate_inode_pages2_range() in the same
> sucker. Again, compare with generic_file_direct_write()...
>
> I don't believe that this one has anything splice-specific to do with it.
> And its only relation to iov_iter_pipe() splat is that it's in the same
> fs/iomap.c...
The interesting part is that I'm hitting these two over and over now
rather than the iov_iter_pipe warning. Could just be unlucky
randomness though..
Dave
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-10 20:07 ` Dave Jones
@ 2017-09-10 20:33 ` Al Viro
0 siblings, 0 replies; 30+ messages in thread
From: Al Viro @ 2017-09-10 20:33 UTC (permalink / raw)
To: Dave Jones, Dave Chinner, Darrick J. Wong, Linux Kernel,
linux-xfs, Christoph Hellwig
On Sun, Sep 10, 2017 at 04:07:24PM -0400, Dave Jones wrote:
> On Sun, Sep 10, 2017 at 09:05:48PM +0100, Al Viro wrote:
> > On Sun, Sep 10, 2017 at 12:07:10PM -0400, Dave Jones wrote:
> > > On Sun, Sep 10, 2017 at 03:57:21AM +0100, Al Viro wrote:
> > > > On Sat, Sep 09, 2017 at 09:07:56PM -0400, Dave Jones wrote:
> > > >
> > > > > With this in place, I'm still seeing -EBUSY from invalidate_inode_pages2_range
> > > > > which doesn't end well...
> > > >
> > > > Different issue, and I'm not sure why that WARN_ON() is there in the
> > > > first place. Note that in a similar situation generic_file_direct_write()
> > > > simply buggers off and lets the caller do buffered write...
> > > >
> > > > iov_iter_pipe() warning is a sign of ->read_iter() on pipe-backed iov_iter
> > > > putting into the pipe more than it claims to have done.
> > >
> > > (from a rerun after hitting that EBUSY warn; hence the taint)
> > >
> > > WARNING: CPU: 0 PID: 14154 at fs/iomap.c:1055 iomap_dio_rw+0x78e/0x840
> >
> > ... and that's another invalidate_inode_pages2_range() in the same
> > sucker. Again, compare with generic_file_direct_write()...
> >
> > I don't believe that this one has anything splice-specific to do with it.
> > And its only relation to iov_iter_pipe() splat is that it's in the same
> > fs/iomap.c...
>
> The interesting part is that I'm hitting these two over and over now
> rather than the iov_iter_pipe warning. Could just be unlucky
> randomness though..
Well, if you are still running the same reproducer and it used to hit the "read
from hole longer than the amount of space left in pipe" case, fixing the other
bug would have led to a lot more data shoved through the pipe without choking.
So the write side would be exercised more than before...
Hell knows; the question I have right now is what the devil are those WARN_ON_ONCE()
doing there. Again, the same conditions are possible on other filesystems, only
there we don't yell; invalidation failure before starting O_DIRECT write is
handled by quiet fallback to buffered IO, the one after the write is simply
ignored.
Doing those WARN_ON_ONCE() is an explicit choice in "iomap: implement direct I/O",
so it's a question to Christoph, AFAICS...
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-10 2:57 ` Al Viro
2017-09-10 16:07 ` Dave Jones
@ 2017-09-10 21:11 ` Dave Chinner
2017-09-10 21:19 ` Al Viro
1 sibling, 1 reply; 30+ messages in thread
From: Dave Chinner @ 2017-09-10 21:11 UTC (permalink / raw)
To: Al Viro; +Cc: Dave Jones, Darrick J. Wong, Linux Kernel, linux-xfs
On Sun, Sep 10, 2017 at 03:57:21AM +0100, Al Viro wrote:
> On Sat, Sep 09, 2017 at 09:07:56PM -0400, Dave Jones wrote:
>
> > With this in place, I'm still seeing -EBUSY from invalidate_inode_pages2_range
> > which doesn't end well...
>
> Different issue, and I'm not sure why that WARN_ON() is there in the
> first place. Note that in a similar situation generic_file_direct_write()
> simply buggers off and lets the caller do buffered write...
XFS does not fall back to buffered IO when direct IO fails. A
direct IO failure is indicative of a problem that needs to be fixed,
not use a "let's hope we can hide this" fallback path. Especially in
this case - EBUSY usually comes from the app is doing something we
/know/ is dangerous and it's occurrence to completely timing
dependent - if the timing is slightly different, we miss detection
and that can lead to silent data corruption. Hence if we detect it,
and our coherency guards can't fix up the coherency problem, we
issue a warning and fail the IO.
The warning is mostly there for us developers and it's been there
for years - it's so we don't end up chasing ghosts when we see that
warning in the logs. The usual vector is an app that mixes
concurrent DIO with mmap access to the same file, which we
explicitly say "don't do this because data corruption" in the
open(2) man page....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-10 21:11 ` Dave Chinner
@ 2017-09-10 21:19 ` Al Viro
2017-09-10 22:08 ` Dave Chinner
0 siblings, 1 reply; 30+ messages in thread
From: Al Viro @ 2017-09-10 21:19 UTC (permalink / raw)
To: Dave Chinner; +Cc: Dave Jones, Darrick J. Wong, Linux Kernel, linux-xfs
On Mon, Sep 11, 2017 at 07:11:10AM +1000, Dave Chinner wrote:
> On Sun, Sep 10, 2017 at 03:57:21AM +0100, Al Viro wrote:
> > On Sat, Sep 09, 2017 at 09:07:56PM -0400, Dave Jones wrote:
> >
> > > With this in place, I'm still seeing -EBUSY from invalidate_inode_pages2_range
> > > which doesn't end well...
> >
> > Different issue, and I'm not sure why that WARN_ON() is there in the
> > first place. Note that in a similar situation generic_file_direct_write()
> > simply buggers off and lets the caller do buffered write...
>
> XFS does not fall back to buffered IO when direct IO fails. A
> direct IO failure is indicative of a problem that needs to be fixed,
> not use a "let's hope we can hide this" fallback path. Especially in
> this case - EBUSY usually comes from the app is doing something we
> /know/ is dangerous and it's occurrence to completely timing
> dependent - if the timing is slightly different, we miss detection
> and that can lead to silent data corruption.
In this case app is a fuzzer, which is bloody well supposed to poke
into all kinds of odd usage patterns, though...
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-10 21:19 ` Al Viro
@ 2017-09-10 22:08 ` Dave Chinner
2017-09-10 23:07 ` Al Viro
0 siblings, 1 reply; 30+ messages in thread
From: Dave Chinner @ 2017-09-10 22:08 UTC (permalink / raw)
To: Al Viro; +Cc: Dave Jones, Darrick J. Wong, Linux Kernel, linux-xfs
On Sun, Sep 10, 2017 at 10:19:07PM +0100, Al Viro wrote:
> On Mon, Sep 11, 2017 at 07:11:10AM +1000, Dave Chinner wrote:
> > On Sun, Sep 10, 2017 at 03:57:21AM +0100, Al Viro wrote:
> > > On Sat, Sep 09, 2017 at 09:07:56PM -0400, Dave Jones wrote:
> > >
> > > > With this in place, I'm still seeing -EBUSY from invalidate_inode_pages2_range
> > > > which doesn't end well...
> > >
> > > Different issue, and I'm not sure why that WARN_ON() is there in the
> > > first place. Note that in a similar situation generic_file_direct_write()
> > > simply buggers off and lets the caller do buffered write...
> >
> > XFS does not fall back to buffered IO when direct IO fails. A
> > direct IO failure is indicative of a problem that needs to be fixed,
> > not use a "let's hope we can hide this" fallback path. Especially in
> > this case - EBUSY usually comes from the app is doing something we
> > /know/ is dangerous and it's occurrence to completely timing
> > dependent - if the timing is slightly different, we miss detection
> > and that can lead to silent data corruption.
>
> In this case app is a fuzzer, which is bloody well supposed to poke
> into all kinds of odd usage patterns, though...
Yup, and we have quite a few tests in xfstests that specifically
exercise this same dark corner. We filter out these warnings from
the xfstests that exercise this case, though, because we know they
are going to be emitted and so aren't a sign of test failures...
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-10 22:08 ` Dave Chinner
@ 2017-09-10 23:07 ` Al Viro
2017-09-10 23:15 ` Al Viro
` (2 more replies)
0 siblings, 3 replies; 30+ messages in thread
From: Al Viro @ 2017-09-10 23:07 UTC (permalink / raw)
To: Dave Chinner; +Cc: Dave Jones, Darrick J. Wong, Linux Kernel, linux-xfs
On Mon, Sep 11, 2017 at 08:08:14AM +1000, Dave Chinner wrote:
> On Sun, Sep 10, 2017 at 10:19:07PM +0100, Al Viro wrote:
> > On Mon, Sep 11, 2017 at 07:11:10AM +1000, Dave Chinner wrote:
> > > On Sun, Sep 10, 2017 at 03:57:21AM +0100, Al Viro wrote:
> > > > On Sat, Sep 09, 2017 at 09:07:56PM -0400, Dave Jones wrote:
> > > >
> > > > > With this in place, I'm still seeing -EBUSY from invalidate_inode_pages2_range
> > > > > which doesn't end well...
> > > >
> > > > Different issue, and I'm not sure why that WARN_ON() is there in the
> > > > first place. Note that in a similar situation generic_file_direct_write()
> > > > simply buggers off and lets the caller do buffered write...
> > >
> > > XFS does not fall back to buffered IO when direct IO fails. A
> > > direct IO failure is indicative of a problem that needs to be fixed,
> > > not use a "let's hope we can hide this" fallback path. Especially in
> > > this case - EBUSY usually comes from the app is doing something we
> > > /know/ is dangerous and it's occurrence to completely timing
> > > dependent - if the timing is slightly different, we miss detection
> > > and that can lead to silent data corruption.
> >
> > In this case app is a fuzzer, which is bloody well supposed to poke
> > into all kinds of odd usage patterns, though...
>
> Yup, and we have quite a few tests in xfstests that specifically
> exercise this same dark corner. We filter out these warnings from
> the xfstests that exercise this case, though, because we know they
> are going to be emitted and so aren't a sign of test failures...
BTW, another problem I see there is that iomap_dio_actor() should *NOT*
assume that do-while loop in there will always manage to shove 'length'
bytes out in case of success. That is simply not true for pipe-backed
destination. And I'm not sure if outright failures halfway through
are handled correctly. What does it need a copy of dio->submit.iter for,
anyway? Why not work with dio->submit.iter directly?
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-10 23:07 ` Al Viro
@ 2017-09-10 23:15 ` Al Viro
2017-09-11 0:31 ` Dave Chinner
2017-09-11 12:07 ` Christoph Hellwig
2 siblings, 0 replies; 30+ messages in thread
From: Al Viro @ 2017-09-10 23:15 UTC (permalink / raw)
To: Dave Chinner
Cc: Dave Jones, Darrick J. Wong, Linux Kernel, linux-xfs,
Christoph Hellwig
On Mon, Sep 11, 2017 at 12:07:23AM +0100, Al Viro wrote:
> BTW, another problem I see there is that iomap_dio_actor() should *NOT*
> assume that do-while loop in there will always manage to shove 'length'
> bytes out in case of success. That is simply not true for pipe-backed
> destination. And I'm not sure if outright failures halfway through
> are handled correctly. What does it need a copy of dio->submit.iter for,
> anyway? Why not work with dio->submit.iter directly?
I mean, if it's just a matter of iov_iter_truncate() to be undone in
the end, that's not hard to do - iov_iter_reexpand() is there. Or is there
something more subtle in the play?
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-10 23:07 ` Al Viro
2017-09-10 23:15 ` Al Viro
@ 2017-09-11 0:31 ` Dave Chinner
2017-09-11 3:32 ` Al Viro
2017-09-11 12:07 ` Christoph Hellwig
2 siblings, 1 reply; 30+ messages in thread
From: Dave Chinner @ 2017-09-11 0:31 UTC (permalink / raw)
To: Al Viro; +Cc: Dave Jones, Darrick J. Wong, Linux Kernel, linux-xfs
On Mon, Sep 11, 2017 at 12:07:23AM +0100, Al Viro wrote:
> On Mon, Sep 11, 2017 at 08:08:14AM +1000, Dave Chinner wrote:
> > On Sun, Sep 10, 2017 at 10:19:07PM +0100, Al Viro wrote:
> > > On Mon, Sep 11, 2017 at 07:11:10AM +1000, Dave Chinner wrote:
> > > > On Sun, Sep 10, 2017 at 03:57:21AM +0100, Al Viro wrote:
> > > > > On Sat, Sep 09, 2017 at 09:07:56PM -0400, Dave Jones wrote:
> > > > >
> > > > > > With this in place, I'm still seeing -EBUSY from invalidate_inode_pages2_range
> > > > > > which doesn't end well...
> > > > >
> > > > > Different issue, and I'm not sure why that WARN_ON() is there in the
> > > > > first place. Note that in a similar situation generic_file_direct_write()
> > > > > simply buggers off and lets the caller do buffered write...
> > > >
> > > > XFS does not fall back to buffered IO when direct IO fails. A
> > > > direct IO failure is indicative of a problem that needs to be fixed,
> > > > not use a "let's hope we can hide this" fallback path. Especially in
> > > > this case - EBUSY usually comes from the app is doing something we
> > > > /know/ is dangerous and it's occurrence to completely timing
> > > > dependent - if the timing is slightly different, we miss detection
> > > > and that can lead to silent data corruption.
> > >
> > > In this case app is a fuzzer, which is bloody well supposed to poke
> > > into all kinds of odd usage patterns, though...
> >
> > Yup, and we have quite a few tests in xfstests that specifically
> > exercise this same dark corner. We filter out these warnings from
> > the xfstests that exercise this case, though, because we know they
> > are going to be emitted and so aren't a sign of test failures...
>
> BTW, another problem I see there is that iomap_dio_actor() should *NOT*
> assume that do-while loop in there will always manage to shove 'length'
> bytes out in case of success. That is simply not true for pipe-backed
> destination.
splice does not go down the direct IO path, so iomap_dio_actor()
should never be handled a pipe as the destination for the IO data.
Indeed, splice read has to supply the pages to be put into the pipe,
which the DIO path does not do - it requires pages be supplied to
it. So I'm not sure why we'd care about pipe destination limitations
in the DIO path?
> And I'm not sure if outright failures halfway through
> are handled correctly. What does it need a copy of dio->submit.iter for,
> anyway? Why not work with dio->submit.iter directly?
No idea - that's a question for Christoph...
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-11 0:31 ` Dave Chinner
@ 2017-09-11 3:32 ` Al Viro
2017-09-11 6:44 ` Dave Chinner
0 siblings, 1 reply; 30+ messages in thread
From: Al Viro @ 2017-09-11 3:32 UTC (permalink / raw)
To: Dave Chinner; +Cc: Dave Jones, Darrick J. Wong, Linux Kernel, linux-xfs
On Mon, Sep 11, 2017 at 10:31:13AM +1000, Dave Chinner wrote:
> splice does not go down the direct IO path, so iomap_dio_actor()
> should never be handled a pipe as the destination for the IO data.
> Indeed, splice read has to supply the pages to be put into the pipe,
> which the DIO path does not do - it requires pages be supplied to
> it. So I'm not sure why we'd care about pipe destination limitations
> in the DIO path?
splice doesn't give a rat's arse for direct IO; it's up to filesystem.
generic_file_splice_read() simply sets up a pipe-backed iov_iter and
calls ->read_iter(), period.
iov_iter_get_pages() for pipe-backed destination does page allocation
and inserts freshly allocated pages into pipe. copy_to_iter() does
the same + copies data; copy_page_to_iter() grabs an extra reference
to page and inserts it into pipe, not that O_DIRECT ->read_iter()
had been likely to use the last one.
Normally O_DIRECT would work just fine - pages get allocated, references
to them put into pipe cyclic buffer *and* into a number of bio, bio
would get submitted and once the IO is completed we unlock the pipe,
making those pages available for readers.
With minimal care it works just fine - all you really need is
* cope with failing copy_to_... / iov_iter_get_pages().
Short read if we'd already gotten something, -EFAULT otherwise.
That goes for pipe-backed same as for iovec-backed - any ->read_iter()
that fails to handle that is already in trouble.
* make sure that iov_iter_get_pages()/iov_iter_get_pages_alloc()
is followed by iov_iter_advance() for the amount you've actually filled,
before any subsequent copy_to_iter()/copy_page_to_iter() or return
from ->read_iter(), whichever comes first. That includes the situation
when you actually hadn't filled anything at all - just remember to
do iov_iter_advance(to, 0) in that case. That's about the only
extra requirement imposed by pipes and it's not hard to satisfy.
Combination of iov_iter_advance() with iov_iter_revert() works as
usual.
Normally a filesystem doesn't need to care about splice at all -
just use generic_file_splice_read() and be done with that.
It will use the normal ->read_iter(), with whatever locking, etc.,
your filesystem would do on a normal read.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-11 3:32 ` Al Viro
@ 2017-09-11 6:44 ` Dave Chinner
2017-09-11 20:07 ` Al Viro
0 siblings, 1 reply; 30+ messages in thread
From: Dave Chinner @ 2017-09-11 6:44 UTC (permalink / raw)
To: Al Viro; +Cc: Dave Jones, Darrick J. Wong, Linux Kernel, linux-xfs
On Mon, Sep 11, 2017 at 04:32:22AM +0100, Al Viro wrote:
> On Mon, Sep 11, 2017 at 10:31:13AM +1000, Dave Chinner wrote:
>
> > splice does not go down the direct IO path, so iomap_dio_actor()
> > should never be handled a pipe as the destination for the IO data.
> > Indeed, splice read has to supply the pages to be put into the pipe,
> > which the DIO path does not do - it requires pages be supplied to
> > it. So I'm not sure why we'd care about pipe destination limitations
> > in the DIO path?
>
> splice doesn't give a rat's arse for direct IO; it's up to filesystem.
[....]
It's news to me that splice works on direct IO - I thought it was
still required page cache based IO for file data for this stuff to
work. I must have missed the memo saying that splice interfaces now
work on O_DIRECT fds, there's certainly no documentation or comments
in the code I could have read to find this out myself...
As it is, we have very little test coverage for splice interfaces,
and all that I am aware of assumes that sendfile/splice only works
for buffered IO. So I'm not surprised there are bugs in this code,
it's likely to be completely untested.
I'm guessing the warnings are being thrown because sendfile's
source and/or destination is opened O_DIRECT and something else has
also mmap()d the same files and is doing concurrent sendfile/splice
and page faults. Hell, it could even be sendfile to/from the same
file mixing buffered and direct IO, or perhaps vmsplice of a mapped
range of the same file it's using as the O_DIRECT destination fd.
None of which are sane things to do and fall under the "not
supported" category....
> iov_iter_get_pages() for pipe-backed destination does page allocation
> and inserts freshly allocated pages into pipe.
Oh, it's hidden more layers down than the code implied I needed to
look.
i.e. there's no obvious clue in the function names that there is
allocation happening in these paths (get_pipe_pages ->
__get_pipe_pages -> push_pipe -> page allocation). The function
names imply it's getting a reference to pages (like
(get_user_pages()) and the fact it does allocation is inconsistent
with it's naming. Worse, when push_pipe() fails to allocate pages,
the error __get_pipe_pages() returns is -EFAULT, which further hides
the fact push_pipe() does memory allocation that can fail....
And then there's the companion interface that implies page
allocation: pipe_get_pages_alloc(). Which brings me back to there
being no obvious clue while reading the code from the top down that
pages are being allocated in push_pipe()....
Comments and documentation for this code would help, but I can't
find any of that, either. Hence I assumed naming followed familiar
patterns and so mistook these interfaces being one that does page
allocation and the other for getting references to pre-existing
pages.....
[snip]
> Normally a filesystem doesn't need to care about splice at all -
> just use generic_file_splice_read() and be done with that.
> It will use the normal ->read_iter(), with whatever locking, etc.,
> your filesystem would do on a normal read.
Yup, that's my point - this is exactly what XFS does, and so I had
no clue that the generic splice code had been changed to accept and
use O_DIRECT semantics because no filesystem code was changed to
enable it.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-10 23:07 ` Al Viro
2017-09-10 23:15 ` Al Viro
2017-09-11 0:31 ` Dave Chinner
@ 2017-09-11 12:07 ` Christoph Hellwig
2017-09-11 12:51 ` Al Viro
2 siblings, 1 reply; 30+ messages in thread
From: Christoph Hellwig @ 2017-09-11 12:07 UTC (permalink / raw)
To: Al Viro; +Cc: Dave Chinner, Dave Jones, Darrick J. Wong, Linux Kernel,
linux-xfs
On Mon, Sep 11, 2017 at 12:07:23AM +0100, Al Viro wrote:
> BTW, another problem I see there is that iomap_dio_actor() should *NOT*
> assume that do-while loop in there will always manage to shove 'length'
> bytes out in case of success. That is simply not true for pipe-backed
> destination. And I'm not sure if outright failures halfway through
> are handled correctly. What does it need a copy of dio->submit.iter for,
> anyway? Why not work with dio->submit.iter directly?
> --
So that we only walk the pagetables and pin down the pages that
we can actually use in this iteration.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-11 12:07 ` Christoph Hellwig
@ 2017-09-11 12:51 ` Al Viro
0 siblings, 0 replies; 30+ messages in thread
From: Al Viro @ 2017-09-11 12:51 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Dave Chinner, Dave Jones, Darrick J. Wong, Linux Kernel,
linux-xfs
On Mon, Sep 11, 2017 at 05:07:57AM -0700, Christoph Hellwig wrote:
> On Mon, Sep 11, 2017 at 12:07:23AM +0100, Al Viro wrote:
> > BTW, another problem I see there is that iomap_dio_actor() should *NOT*
> > assume that do-while loop in there will always manage to shove 'length'
> > bytes out in case of success. That is simply not true for pipe-backed
> > destination. And I'm not sure if outright failures halfway through
> > are handled correctly. What does it need a copy of dio->submit.iter for,
> > anyway? Why not work with dio->submit.iter directly?
> > --
>
> So that we only walk the pagetables and pin down the pages that
> we can actually use in this iteration.
Er... So why not simply do iov_iter_reexpand() in the end of segment with the
right argument? IDGI...
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-11 6:44 ` Dave Chinner
@ 2017-09-11 20:07 ` Al Viro
2017-09-11 20:17 ` Al Viro
2017-09-12 6:02 ` Dave Chinner
0 siblings, 2 replies; 30+ messages in thread
From: Al Viro @ 2017-09-11 20:07 UTC (permalink / raw)
To: Dave Chinner; +Cc: Dave Jones, Darrick J. Wong, Linux Kernel, linux-xfs
On Mon, Sep 11, 2017 at 04:44:40PM +1000, Dave Chinner wrote:
> > iov_iter_get_pages() for pipe-backed destination does page allocation
> > and inserts freshly allocated pages into pipe.
>
> Oh, it's hidden more layers down than the code implied I needed to
> look.
>
> i.e. there's no obvious clue in the function names that there is
> allocation happening in these paths (get_pipe_pages ->
> __get_pipe_pages -> push_pipe -> page allocation). The function
> names imply it's getting a reference to pages (like
> (get_user_pages()) and the fact it does allocation is inconsistent
> with it's naming. Worse, when push_pipe() fails to allocate pages,
> the error __get_pipe_pages() returns is -EFAULT, which further hides
> the fact push_pipe() does memory allocation that can fail....
>
> And then there's the companion interface that implies page
> allocation: pipe_get_pages_alloc(). Which brings me back to there
> being no obvious clue while reading the code from the top down that
> pages are being allocated in push_pipe()....
>
> Comments and documentation for this code would help, but I can't
> find any of that, either. Hence I assumed naming followed familiar
> patterns and so mistook these interfaces being one that does page
> allocation and the other for getting references to pre-existing
> pages.....
_NONE_ of those is a public interface - they are all static, to start
with.
The whole damn point is to have normal ->read_iter() work for read-to-pipe
without changes. That's why -EFAULT as error (rather than some other
mechanism for saying that pipe is full), etc.
Filesystem should *not* be changed to use that. At all. As far as it is
concerned,
copy_to_iter()
copy_page_to_iter()
iov_iter_get_pages()
iov_iter_get_pages_alloc()
iov_iter_advance()
are black boxes.
Note that one of the bugs there applies to normal read() as well - if you
are reading from a hole in file into an array with a read-only page in
the middle, you want a short read. Ignoring return value from iov_iter_zero()
is wrong for iovec-backed case as well as for pipes.
Another one manages to work for iovec-backed case, albeit with rather odd
resulting semantics. readv(2) is underspecified (to put it politely) enough
for compliance, but it's still bloody strange. Namely, if you have a contiguous
50Mb chunk of file on disk and run into e.g. a failure to fault the destination
pages in halfway through that extent, you act as if *nothing* in the damn thing
had been read, nevermind that 25Mb had been actually already read and that had
there been a discontinuity 5Mb prior, the first 20Mb would've been reported
read just fine.
Strictly speaking that behaviour doesn't violate POSIX. It is, however,
atrocious from the QoI standpoint, and for no good reason whatsoever.
It's quite easy to do better, and doing so would've eliminated the problems
in pipe-backed case as well (see below). In addition to that, I would
consider teaching bio_iov_iter_get_pages() to take the maximal bio size
as an explict argument. That would've killed the need of copying the
iterator and calling iov_iter_advance() in iomap_dio_actor() at all.
Anyway, the minimal candidate fix follows; it won't do anything about
the WARN_ON() in there, seeing that those are deliberate "program is
doing something bogus" things, but it should eliminate all crap with
->splice_read() misreporting the amount of data it has copied.
diff --git a/fs/iomap.c b/fs/iomap.c
index 269b24a01f32..836fe27b00e2 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -832,6 +832,7 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
struct bio *bio;
bool need_zeroout = false;
int nr_pages, ret;
+ size_t copied = 0;
if ((pos | length | align) & ((1 << blkbits) - 1))
return -EINVAL;
@@ -843,7 +844,7 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
/*FALLTHRU*/
case IOMAP_UNWRITTEN:
if (!(dio->flags & IOMAP_DIO_WRITE)) {
- iov_iter_zero(length, dio->submit.iter);
+ length = iov_iter_zero(length, dio->submit.iter);
dio->size += length;
return length;
}
@@ -880,6 +881,7 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
}
do {
+ size_t n;
if (dio->error)
return 0;
@@ -897,17 +899,21 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
return ret;
}
+ n = bio->bi_iter.bi_size;
if (dio->flags & IOMAP_DIO_WRITE) {
bio_set_op_attrs(bio, REQ_OP_WRITE, REQ_SYNC | REQ_IDLE);
- task_io_account_write(bio->bi_iter.bi_size);
+ task_io_account_write(n);
} else {
bio_set_op_attrs(bio, REQ_OP_READ, 0);
if (dio->flags & IOMAP_DIO_DIRTY)
bio_set_pages_dirty(bio);
}
- dio->size += bio->bi_iter.bi_size;
- pos += bio->bi_iter.bi_size;
+ iov_iter_advance(dio->submit.iter, n);
+
+ dio->size += n;
+ pos += n;
+ copied += n;
nr_pages = iov_iter_npages(&iter, BIO_MAX_PAGES);
@@ -923,9 +929,7 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
if (pad)
iomap_dio_zero(dio, iomap, pos, fs_block_size - pad);
}
-
- iov_iter_advance(dio->submit.iter, length);
- return length;
+ return copied;
}
ssize_t
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-11 20:07 ` Al Viro
@ 2017-09-11 20:17 ` Al Viro
2017-09-12 6:02 ` Dave Chinner
1 sibling, 0 replies; 30+ messages in thread
From: Al Viro @ 2017-09-11 20:17 UTC (permalink / raw)
To: Dave Chinner; +Cc: Dave Jones, Darrick J. Wong, Linux Kernel, linux-xfs
On Mon, Sep 11, 2017 at 09:07:13PM +0100, Al Viro wrote:
> Strictly speaking that behaviour doesn't violate POSIX. It is, however,
> atrocious from the QoI standpoint, and for no good reason whatsoever.
> It's quite easy to do better, and doing so would've eliminated the problems
> in pipe-backed case as well (see below). In addition to that, I would
> consider teaching bio_iov_iter_get_pages() to take the maximal bio size
> as an explict argument. That would've killed the need of copying the
> iterator and calling iov_iter_advance() in iomap_dio_actor() at all.
> Anyway, the minimal candidate fix follows; it won't do anything about
> the WARN_ON() in there, seeing that those are deliberate "program is
> doing something bogus" things, but it should eliminate all crap with
> ->splice_read() misreporting the amount of data it has copied.
... and after minimal testing and fixing a braino in "found an IO error"
case, that's
diff --git a/fs/iomap.c b/fs/iomap.c
index 269b24a01f32..012e1f247e13 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -832,6 +832,7 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
struct bio *bio;
bool need_zeroout = false;
int nr_pages, ret;
+ size_t copied = 0;
if ((pos | length | align) & ((1 << blkbits) - 1))
return -EINVAL;
@@ -843,7 +844,7 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
/*FALLTHRU*/
case IOMAP_UNWRITTEN:
if (!(dio->flags & IOMAP_DIO_WRITE)) {
- iov_iter_zero(length, dio->submit.iter);
+ length = iov_iter_zero(length, dio->submit.iter);
dio->size += length;
return length;
}
@@ -880,8 +881,11 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
}
do {
- if (dio->error)
+ size_t n;
+ if (dio->error) {
+ iov_iter_revert(dio->submit.iter, copied);
return 0;
+ }
bio = bio_alloc(GFP_KERNEL, nr_pages);
bio_set_dev(bio, iomap->bdev);
@@ -894,20 +898,24 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
ret = bio_iov_iter_get_pages(bio, &iter);
if (unlikely(ret)) {
bio_put(bio);
- return ret;
+ return copied ? copied : ret;
}
+ n = bio->bi_iter.bi_size;
if (dio->flags & IOMAP_DIO_WRITE) {
bio_set_op_attrs(bio, REQ_OP_WRITE, REQ_SYNC | REQ_IDLE);
- task_io_account_write(bio->bi_iter.bi_size);
+ task_io_account_write(n);
} else {
bio_set_op_attrs(bio, REQ_OP_READ, 0);
if (dio->flags & IOMAP_DIO_DIRTY)
bio_set_pages_dirty(bio);
}
- dio->size += bio->bi_iter.bi_size;
- pos += bio->bi_iter.bi_size;
+ iov_iter_advance(dio->submit.iter, n);
+
+ dio->size += n;
+ pos += n;
+ copied += n;
nr_pages = iov_iter_npages(&iter, BIO_MAX_PAGES);
@@ -923,9 +931,7 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
if (pad)
iomap_dio_zero(dio, iomap, pos, fs_block_size - pad);
}
-
- iov_iter_advance(dio->submit.iter, length);
- return length;
+ return copied;
}
ssize_t
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-11 20:07 ` Al Viro
2017-09-11 20:17 ` Al Viro
@ 2017-09-12 6:02 ` Dave Chinner
2017-09-12 11:13 ` Al Viro
1 sibling, 1 reply; 30+ messages in thread
From: Dave Chinner @ 2017-09-12 6:02 UTC (permalink / raw)
To: Al Viro; +Cc: Dave Jones, Darrick J. Wong, Linux Kernel, linux-xfs
On Mon, Sep 11, 2017 at 09:07:13PM +0100, Al Viro wrote:
> On Mon, Sep 11, 2017 at 04:44:40PM +1000, Dave Chinner wrote:
>
> > > iov_iter_get_pages() for pipe-backed destination does page allocation
> > > and inserts freshly allocated pages into pipe.
> >
> > Oh, it's hidden more layers down than the code implied I needed to
> > look.
> >
> > i.e. there's no obvious clue in the function names that there is
> > allocation happening in these paths (get_pipe_pages ->
> > __get_pipe_pages -> push_pipe -> page allocation). The function
> > names imply it's getting a reference to pages (like
> > (get_user_pages()) and the fact it does allocation is inconsistent
> > with it's naming. Worse, when push_pipe() fails to allocate pages,
> > the error __get_pipe_pages() returns is -EFAULT, which further hides
> > the fact push_pipe() does memory allocation that can fail....
> >
> > And then there's the companion interface that implies page
> > allocation: pipe_get_pages_alloc(). Which brings me back to there
> > being no obvious clue while reading the code from the top down that
> > pages are being allocated in push_pipe()....
> >
> > Comments and documentation for this code would help, but I can't
> > find any of that, either. Hence I assumed naming followed familiar
> > patterns and so mistook these interfaces being one that does page
> > allocation and the other for getting references to pre-existing
> > pages.....
>
> _NONE_ of those is a public interface - they are all static, to start
> with.
It still requires comments to explain *why* the code is doing what
it's doing. You wrote the code, the whole explaination of it is in
your head. I can't see any of that, so when I read the code I sit
there thinking "why the fuck is it doing this?" because there's no
explanations of the WTF? moments in the code...
> The whole damn point is to have normal ->read_iter() work for read-to-pipe
> without changes. That's why -EFAULT as error (rather than some other
> mechanism for saying that pipe is full), etc.
... like this one.
That needs a *fucking big comment* because it's not at all obvious
why ENOMEM conditions are being hidden with EFAULT.
Comments and documentation are not for the person who writes the
code - they are for the stupid morons like me that need all the
help they can get to understand complex code that does tricksy,
subtle, non-obvious shit to work correctly.
> Filesystem should *not* be changed to use that. At all. As far as it is
> concerned,
> copy_to_iter()
> copy_page_to_iter()
> iov_iter_get_pages()
> iov_iter_get_pages_alloc()
> iov_iter_advance()
> are black boxes.
The implementation may be a black box, but the operations the black
box is performing for the callers still needs to be explained.
> Note that one of the bugs there applies to normal read() as well - if you
> are reading from a hole in file into an array with a read-only page in
> the middle, you want a short read.
And there's another WTF? moment.....
How do we get a read only page in the middle of an array of pages
we've been told to write data into? And why isn't that a bug in the
code that supplied us with those pages?
> Ignoring return value from iov_iter_zero()
> is wrong for iovec-backed case as well as for pipes.
>
> Another one manages to work for iovec-backed case, albeit with rather odd
> resulting semantics. readv(2) is underspecified (to put it politely) enough
> for compliance, but it's still bloody strange. Namely, if you have a contiguous
> 50Mb chunk of file on disk and run into e.g. a failure to fault the destination
> pages in halfway through that extent, you act as if *nothing* in the damn thing
> had been read, nevermind that 25Mb had been actually already read and that had
> there been a discontinuity 5Mb prior, the first 20Mb would've been reported
> read just fine.
>
> Strictly speaking that behaviour doesn't violate POSIX.
This is direct IO. POSIX compliant behaviour went out the window
long ago..... :/
> It is, however,
> atrocious from the QoI standpoint, and for no good reason whatsoever.
> It's quite easy to do better, and doing so would've eliminated the problems
> in pipe-backed case as well (see below). In addition to that, I would
> consider teaching bio_iov_iter_get_pages() to take the maximal bio size
> as an explict argument. That would've killed the need of copying the
> iterator and calling iov_iter_advance() in iomap_dio_actor() at all.
> Anyway, the minimal candidate fix follows; it won't do anything about
> the WARN_ON() in there, seeing that those are deliberate "program is
> doing something bogus" things, but it should eliminate all crap with
> ->splice_read() misreporting the amount of data it has copied.
I'll run your updated patch through my testing, but seeing as I have
nothing that tests splice+direct IO I'm not going to be able to test
that right now. I have slightly more important things to that need
urgent attention than writing splice+DIO test cases....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: iov_iter_pipe warning.
2017-09-12 6:02 ` Dave Chinner
@ 2017-09-12 11:13 ` Al Viro
0 siblings, 0 replies; 30+ messages in thread
From: Al Viro @ 2017-09-12 11:13 UTC (permalink / raw)
To: Dave Chinner; +Cc: Dave Jones, Darrick J. Wong, Linux Kernel, linux-xfs
On Tue, Sep 12, 2017 at 04:02:14PM +1000, Dave Chinner wrote:
> > Note that one of the bugs there applies to normal read() as well - if you
> > are reading from a hole in file into an array with a read-only page in
> > the middle, you want a short read.
>
> And there's another WTF? moment.....
>
> How do we get a read only page in the middle of an array of pages
> we've been told to write data into? And why isn't that a bug in the
> code that supplied us with those pages?
Sorry, I'd been unclear - I'm talking about read(2) or readv(2) called by
userland with a read-only piece in the middle of a (user-supplied) buffer.
Either due to mprotect() or simply with one of the iovecs passed to readv(2)
having ->iov_base set to some read-only area.
It may be a bug in userland code, but when handling that error is as trivial
as "don't assume iov_iter_zero(to, n) will return n, use the actual return
value", resorting to "the userland code was probably buggy and it's O_DIRECT,
so we can do whatever we want" looks wrong.
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2017-09-12 11:13 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20170412152600.GP29622@ZenIV.linux.org.uk>
[not found] ` <20170412162709.bn5qfk4seues3yos@codemonkey.org.uk>
[not found] ` <20170412170723.GQ29622@ZenIV.linux.org.uk>
[not found] ` <20170412190318.srkkdytf2ebrjzrg@codemonkey.org.uk>
[not found] ` <20170421175430.GT29622@ZenIV.linux.org.uk>
[not found] ` <20170428152955.mafs3f22srmm34aw@codemonkey.org.uk>
[not found] ` <20170428164313.GK29622@ZenIV.linux.org.uk>
[not found] ` <20170428165024.ofyl2atpjwohekqa@codemonkey.org.uk>
[not found] ` <20170428172024.GL29622@ZenIV.linux.org.uk>
[not found] ` <20170807201818.kykqzexce6ap6aik@codemonkey.org.uk>
2017-08-28 20:31 ` iov_iter_pipe warning Dave Jones
2017-08-29 4:25 ` Darrick J. Wong
2017-08-30 17:05 ` Dave Jones
2017-08-30 17:13 ` Darrick J. Wong
2017-08-30 17:17 ` Dave Jones
2017-09-06 20:03 ` Dave Jones
2017-09-06 23:46 ` Dave Chinner
2017-09-07 3:48 ` Dave Jones
2017-09-07 4:33 ` Al Viro
2017-09-08 1:04 ` Al Viro
2017-09-10 1:07 ` Dave Jones
2017-09-10 2:57 ` Al Viro
2017-09-10 16:07 ` Dave Jones
2017-09-10 20:05 ` Al Viro
2017-09-10 20:07 ` Dave Jones
2017-09-10 20:33 ` Al Viro
2017-09-10 21:11 ` Dave Chinner
2017-09-10 21:19 ` Al Viro
2017-09-10 22:08 ` Dave Chinner
2017-09-10 23:07 ` Al Viro
2017-09-10 23:15 ` Al Viro
2017-09-11 0:31 ` Dave Chinner
2017-09-11 3:32 ` Al Viro
2017-09-11 6:44 ` Dave Chinner
2017-09-11 20:07 ` Al Viro
2017-09-11 20:17 ` Al Viro
2017-09-12 6:02 ` Dave Chinner
2017-09-12 11:13 ` Al Viro
2017-09-11 12:07 ` Christoph Hellwig
2017-09-11 12:51 ` Al Viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).