xfs: pass the correct cursor to xfs_iomap_prealloc_size
In xfs_buffered_write_iomap_begin, @icur is the iext cursor for the data
fork and @ccur is the cursor for the cow fork. Pass in whichever cursor
corresponds to allocfork, because otherwise the xfs_iext_prev_extent
call can use the data fork cursor to walk off the end of the cow fork
structure. Best case it returns the wrong results, worst case it does
this:
stack segment: 0000 [#1] PREEMPT SMP
CPU: 2 PID:
3141909 Comm: fsstress Tainted: G W 6.3.0-rc2-xfsx #6.3.0-rc2
7bf5cc2e98997627cae5c930d890aba3aeec65dd
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20171121_152543-x86-ol7-builder-01.us.oracle.com-4.el7.1 04/01/2014
RIP: 0010:xfs_iext_prev+0x71/0x150 [xfs]
RSP: 0018:
ffffc90002233aa8 EFLAGS:
00010297
RAX:
000000000000000f RBX:
000000000000000e RCX:
000000000000000c
RDX:
0000000000000002 RSI:
000000000000000e RDI:
ffff8883d0019ba0
RBP:
989642409af8a7a7 R08:
ffffea0000000001 R09:
0000000000000002
R10:
0000000000000000 R11:
000000000000000c R12:
ffffc90002233b00
R13:
ffff8883d0019ba0 R14:
989642409af8a6bf R15:
000ffffffffe0000
FS:
00007fdf8115f740(0000) GS:
ffff88843fd00000(0000) knlGS:
0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0:
0000000080050033
CR2:
00007fdf8115e000 CR3:
0000000357256000 CR4:
00000000003506e0
Call Trace:
<TASK>
xfs_iomap_prealloc_size.constprop.0.isra.0+0x1a6/0x410 [xfs
619a268fb2406d68bd34e007a816b27e70abc22c]
xfs_buffered_write_iomap_begin+0xa87/0xc60 [xfs
619a268fb2406d68bd34e007a816b27e70abc22c]
iomap_iter+0x132/0x2f0
iomap_file_buffered_write+0x92/0x330
xfs_file_buffered_write+0xb1/0x330 [xfs
619a268fb2406d68bd34e007a816b27e70abc22c]
vfs_write+0x2eb/0x410
ksys_write+0x65/0xe0
do_syscall_64+0x2b/0x80
entry_SYSCALL_64_after_hwframe+0x46/0xb0
Found by xfs/538 in alwayscow mode, but this doesn't seem particular to
that test.
Fixes:
590b16516ef3 ("xfs: refactor xfs_iomap_prealloc_size")
Actually-Fixes:
66ae56a53f0e ("xfs: introduce an always_cow mode")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>