lkml.org 
[lkml]   [2019]   [Sep]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Date
    Subject[PATCH 3.16 093/132] ext4: fix data corruption caused by overlapping unaligned and aligned IO
    3.16.74-rc1 review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Lukas Czerner <lczerner@redhat.com>

    commit 57a0da28ced8707cb9f79f071a016b9d005caf5a upstream.

    Unaligned AIO must be serialized because the zeroing of partial blocks
    of unaligned AIO can result in data corruption in case it's overlapping
    another in flight IO.

    Currently we wait for all unwritten extents before we submit unaligned
    AIO which protects data in case of unaligned AIO is following overlapping
    IO. However if a unaligned AIO is followed by overlapping aligned AIO we
    can still end up corrupting data.

    To fix this, we must make sure that the unaligned AIO is the only IO in
    flight by waiting for unwritten extents conversion not just before the
    IO submission, but right after it as well.

    This problem can be reproduced by xfstest generic/538

    Signed-off-by: Lukas Czerner <lczerner@redhat.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    [bwh: Backported to 3.16:
    - Test aio_mutex instead of unaligned_aio
    - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    ---
    fs/ext4/file.c | 7 +++++++
    1 file changed, 7 insertions(+)

    --- a/fs/ext4/file.c
    +++ b/fs/ext4/file.c
    @@ -173,6 +173,13 @@ ext4_file_write_iter(struct kiocb *iocb,
    }

    ret = __generic_file_write_iter(iocb, from);
    + /*
    + * Unaligned direct AIO must be the only IO in flight. Otherwise
    + * overlapping aligned IO after unaligned might result in data
    + * corruption.
    + */
    + if (ret == -EIOCBQUEUED && aio_mutex)
    + ext4_unwritten_wait(inode);
    mutex_unlock(&inode->i_mutex);

    if (ret > 0) {
    \
     
     \ /
      Last update: 2019-09-20 16:34    [W:4.143 / U:0.148 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site