• Jeff Layton's avatar
    ceph: add read/modify/write to ceph_sync_write · 33a5f170
    Jeff Layton authored
    When doing a synchronous write on an encrypted inode, we have no
    guarantee that the caller is writing crypto block-aligned data. When
    that happens, we must do a read/modify/write cycle.
    
    First, expand the range to cover complete blocks. If we had to change
    the original pos or length, issue a read to fill the first and/or last
    pages, and fetch the version of the object from the result.
    
    We then copy data into the pages as usual, encrypt the result and issue
    a write prefixed by an assertion that the version hasn't changed. If it has
    changed then we restart the whole thing again.
    
    If there is no object at that position in the file (-ENOENT), we prefix
    the write on an exclusive create of the object instead.
    Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
    Reviewed-by: default avatarXiubo Li <xiubli@redhat.com>
    Reviewed-and-tested-by: default avatarLuís Henriques <lhenriques@suse.de>
    Reviewed-by: default avatarMilind Changire <mchangir@redhat.com>
    Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
    33a5f170
file.c 79.3 KB