]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commit
ceph: add read/modify/write to ceph_sync_write
authorJeff Layton <jlayton@kernel.org>
Wed, 27 Jan 2021 18:13:45 +0000 (13:13 -0500)
committerJeff Layton <jlayton@kernel.org>
Tue, 31 May 2022 15:50:01 +0000 (11:50 -0400)
commit9b295bb188e96e005be87126a06177264040c6b1
tree9e2257e554967f92ea9744c0164f105a7e669f41
parent8d7976e2c5d4426474ea29009233b8fc4275102e
ceph: add read/modify/write to ceph_sync_write

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.

Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
fs/ceph/file.c