• Ross Zwisler's avatar
    loop: Fix lost writes caused by missing flag · 1d037577
    Ross Zwisler authored
    The following commit:
    
    commit aa4d8616 ("block: loop: switch to VFS ITER_BVEC")
    
    replaced __do_lo_send_write(), which used ITER_KVEC iterators, with
    lo_write_bvec() which uses ITER_BVEC iterators.  In this change, though,
    the WRITE flag was lost:
    
    -       iov_iter_kvec(&from, ITER_KVEC | WRITE, &kvec, 1, len);
    +       iov_iter_bvec(&i, ITER_BVEC, bvec, 1, bvec->bv_len);
    
    This flag is necessary for the DAX case because we make decisions based on
    whether or not the iterator is a READ or a WRITE in dax_iomap_actor() and
    in dax_iomap_rw().
    
    We end up going through this path in configurations where we combine a PMEM
    device with 4k sectors, a loopback device and DAX.  The consequence of this
    missed flag is that what we intend as a write actually turns into a read in
    the DAX code, so no data is ever written.
    
    The very simplest test case is to create a loopback device and try and
    write a small string to it, then hexdump a few bytes of the device to see
    if the write took.  Without this patch you read back all zeros, with this
    you read back the string you wrote.
    
    For XFS this causes us to fail or panic during the following xfstests:
    
    	xfs/074 xfs/078 xfs/216 xfs/217 xfs/250
    
    For ext4 we have a similar issue where writes never happen, but we don't
    currently have any xfstests that use loopback and show this issue.
    
    Fix this by restoring the WRITE flag argument to iov_iter_bvec().  This
    causes the xfstests to all pass.
    
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: stable@vger.kernel.org
    Fixes: commit aa4d8616 ("block: loop: switch to VFS ITER_BVEC")
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
    Signed-off-by: default avatarRoss Zwisler <ross.zwisler@linux.intel.com>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    1d037577
Name
Last commit
Last update
..
aoe Loading commit data...
drbd Loading commit data...
mtip32xx Loading commit data...
paride Loading commit data...
rsxx Loading commit data...
xen-blkback Loading commit data...
zram Loading commit data...
DAC960.c Loading commit data...
DAC960.h Loading commit data...
Kconfig Loading commit data...
Makefile Loading commit data...
amiflop.c Loading commit data...
ataflop.c Loading commit data...
brd.c Loading commit data...
cryptoloop.c Loading commit data...
floppy.c Loading commit data...
loop.c Loading commit data...
loop.h Loading commit data...
nbd.c Loading commit data...
null_blk.c Loading commit data...
pktcdvd.c Loading commit data...
ps3disk.c Loading commit data...
ps3vram.c Loading commit data...
rbd.c Loading commit data...
rbd_types.h Loading commit data...
skd_main.c Loading commit data...
skd_s1120.h Loading commit data...
sunvdc.c Loading commit data...
swim.c Loading commit data...
swim3.c Loading commit data...
swim_asm.S Loading commit data...
sx8.c Loading commit data...
umem.c Loading commit data...
umem.h Loading commit data...
virtio_blk.c Loading commit data...
xen-blkfront.c Loading commit data...
xsysace.c Loading commit data...
z2ram.c Loading commit data...