Skip to content

Commit b294fa2

Browse files
jtlaytonidryomov
authored andcommitted
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 <[email protected]> Reviewed-by: Xiubo Li <[email protected]> Reviewed-and-tested-by: Luís Henriques <[email protected]> Reviewed-by: Milind Changire <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 8cff8f5 commit b294fa2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

fs/ceph/file.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,7 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
15821582
bool check_caps = false;
15831583
struct timespec64 mtime = current_time(inode);
15841584
size_t count = iov_iter_count(from);
1585+
size_t off;
15851586

15861587
if (ceph_snap(file_inode(file)) != CEPH_NOSNAP)
15871588
return -EROFS;
@@ -1619,22 +1620,20 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
16191620
break;
16201621
}
16211622

1622-
/*
1623-
* write from beginning of first page,
1624-
* regardless of io alignment
1625-
*/
1626-
num_pages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
1627-
1623+
num_pages = calc_pages_for(pos, len);
16281624
pages = ceph_alloc_page_vector(num_pages, GFP_KERNEL);
16291625
if (IS_ERR(pages)) {
16301626
ret = PTR_ERR(pages);
16311627
goto out;
16321628
}
16331629

16341630
left = len;
1631+
off = offset_in_page(pos);
16351632
for (n = 0; n < num_pages; n++) {
1636-
size_t plen = min_t(size_t, left, PAGE_SIZE);
1637-
ret = copy_page_from_iter(pages[n], 0, plen, from);
1633+
size_t plen = min_t(size_t, left, PAGE_SIZE - off);
1634+
1635+
ret = copy_page_from_iter(pages[n], off, plen, from);
1636+
off = 0;
16381637
if (ret != plen) {
16391638
ret = -EFAULT;
16401639
break;
@@ -1649,8 +1648,9 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
16491648

16501649
req->r_inode = inode;
16511650

1652-
osd_req_op_extent_osd_data_pages(req, 0, pages, len, 0,
1653-
false, true);
1651+
osd_req_op_extent_osd_data_pages(req, 0, pages, len,
1652+
offset_in_page(pos),
1653+
false, true);
16541654

16551655
req->r_mtime = mtime;
16561656
ceph_osdc_start_request(&fsc->client->osdc, req);

0 commit comments

Comments
 (0)