summaryrefslogtreecommitdiffstats
path: root/fs/ceph
diff options
context:
space:
mode:
authorJeff Layton <jlayton@kernel.org>2022-08-25 09:31:20 -0400
committerIlya Dryomov <idryomov@gmail.com>2023-08-24 11:24:36 +0200
commitb294fa295ff47a1fdf4db5e8c9275cc7af328c5e (patch)
tree515278e4edc4a8217dd93536fbe1952e4d635c1d /fs/ceph
parent8cff8f5374c7974ab9b9726c5b7c50f10466047e (diff)
downloadlinux-b294fa295ff47a1fdf4db5e8c9275cc7af328c5e.tar.gz
linux-b294fa295ff47a1fdf4db5e8c9275cc7af328c5e.tar.bz2
linux-b294fa295ff47a1fdf4db5e8c9275cc7af328c5e.zip
ceph: align data in pages in ceph_sync_write
Encrypted files will need to be dealt with in block-sized chunks and once we do that, the way that ceph_sync_write aligns the data in the bounce buffer won't be acceptable. Change it to align the data the same way it would be aligned in the pagecache. Signed-off-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: Xiubo Li <xiubli@redhat.com> Reviewed-and-tested-by: Luís Henriques <lhenriques@suse.de> Reviewed-by: Milind Changire <mchangir@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/ceph')
-rw-r--r--fs/ceph/file.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index f4c3da5b38fe..0abe36379fdf 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -1582,6 +1582,7 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
bool check_caps = false;
struct timespec64 mtime = current_time(inode);
size_t count = iov_iter_count(from);
+ size_t off;
if (ceph_snap(file_inode(file)) != CEPH_NOSNAP)
return -EROFS;
@@ -1619,12 +1620,7 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
break;
}
- /*
- * write from beginning of first page,
- * regardless of io alignment
- */
- num_pages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
-
+ num_pages = calc_pages_for(pos, len);
pages = ceph_alloc_page_vector(num_pages, GFP_KERNEL);
if (IS_ERR(pages)) {
ret = PTR_ERR(pages);
@@ -1632,9 +1628,12 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
}
left = len;
+ off = offset_in_page(pos);
for (n = 0; n < num_pages; n++) {
- size_t plen = min_t(size_t, left, PAGE_SIZE);
- ret = copy_page_from_iter(pages[n], 0, plen, from);
+ size_t plen = min_t(size_t, left, PAGE_SIZE - off);
+
+ ret = copy_page_from_iter(pages[n], off, plen, from);
+ off = 0;
if (ret != plen) {
ret = -EFAULT;
break;
@@ -1649,8 +1648,9 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
req->r_inode = inode;
- osd_req_op_extent_osd_data_pages(req, 0, pages, len, 0,
- false, true);
+ osd_req_op_extent_osd_data_pages(req, 0, pages, len,
+ offset_in_page(pos),
+ false, true);
req->r_mtime = mtime;
ceph_osdc_start_request(&fsc->client->osdc, req);