aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/addr.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ceph/addr.c')
-rw-r--r--fs/ceph/addr.c50
1 files changed, 15 insertions, 35 deletions
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 064d1a68d2c1..a60ea977af6f 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -195,7 +195,7 @@ static int ceph_releasepage(struct page *page, gfp_t g)
195 */ 195 */
196static int readpage_nounlock(struct file *filp, struct page *page) 196static int readpage_nounlock(struct file *filp, struct page *page)
197{ 197{
198 struct inode *inode = filp->f_dentry->d_inode; 198 struct inode *inode = file_inode(filp);
199 struct ceph_inode_info *ci = ceph_inode(inode); 199 struct ceph_inode_info *ci = ceph_inode(inode);
200 struct ceph_osd_client *osdc = 200 struct ceph_osd_client *osdc =
201 &ceph_inode_to_client(inode)->client->osdc; 201 &ceph_inode_to_client(inode)->client->osdc;
@@ -236,16 +236,10 @@ static int ceph_readpage(struct file *filp, struct page *page)
236static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg) 236static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg)
237{ 237{
238 struct inode *inode = req->r_inode; 238 struct inode *inode = req->r_inode;
239 struct ceph_osd_reply_head *replyhead; 239 int rc = req->r_result;
240 int rc, bytes; 240 int bytes = le32_to_cpu(msg->hdr.data_len);
241 int i; 241 int i;
242 242
243 /* parse reply */
244 replyhead = msg->front.iov_base;
245 WARN_ON(le32_to_cpu(replyhead->num_ops) == 0);
246 rc = le32_to_cpu(replyhead->result);
247 bytes = le32_to_cpu(msg->hdr.data_len);
248
249 dout("finish_read %p req %p rc %d bytes %d\n", inode, req, rc, bytes); 243 dout("finish_read %p req %p rc %d bytes %d\n", inode, req, rc, bytes);
250 244
251 /* unlock all pages, zeroing any data we didn't read */ 245 /* unlock all pages, zeroing any data we didn't read */
@@ -315,7 +309,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
315 CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, 309 CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ,
316 NULL, 0, 310 NULL, 0,
317 ci->i_truncate_seq, ci->i_truncate_size, 311 ci->i_truncate_seq, ci->i_truncate_size,
318 NULL, false, 1, 0); 312 NULL, false, 0);
319 if (IS_ERR(req)) 313 if (IS_ERR(req))
320 return PTR_ERR(req); 314 return PTR_ERR(req);
321 315
@@ -370,7 +364,7 @@ out:
370static int ceph_readpages(struct file *file, struct address_space *mapping, 364static int ceph_readpages(struct file *file, struct address_space *mapping,
371 struct list_head *page_list, unsigned nr_pages) 365 struct list_head *page_list, unsigned nr_pages)
372{ 366{
373 struct inode *inode = file->f_dentry->d_inode; 367 struct inode *inode = file_inode(file);
374 struct ceph_fs_client *fsc = ceph_inode_to_client(inode); 368 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
375 int rc = 0; 369 int rc = 0;
376 int max = 0; 370 int max = 0;
@@ -492,8 +486,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
492 &ci->i_layout, snapc, 486 &ci->i_layout, snapc,
493 page_off, len, 487 page_off, len,
494 ci->i_truncate_seq, ci->i_truncate_size, 488 ci->i_truncate_seq, ci->i_truncate_size,
495 &inode->i_mtime, 489 &inode->i_mtime, &page, 1);
496 &page, 1, 0, 0, true);
497 if (err < 0) { 490 if (err < 0) {
498 dout("writepage setting page/mapping error %d %p\n", err, page); 491 dout("writepage setting page/mapping error %d %p\n", err, page);
499 SetPageError(page); 492 SetPageError(page);
@@ -554,27 +547,18 @@ static void writepages_finish(struct ceph_osd_request *req,
554 struct ceph_msg *msg) 547 struct ceph_msg *msg)
555{ 548{
556 struct inode *inode = req->r_inode; 549 struct inode *inode = req->r_inode;
557 struct ceph_osd_reply_head *replyhead;
558 struct ceph_osd_op *op;
559 struct ceph_inode_info *ci = ceph_inode(inode); 550 struct ceph_inode_info *ci = ceph_inode(inode);
560 unsigned wrote; 551 unsigned wrote;
561 struct page *page; 552 struct page *page;
562 int i; 553 int i;
563 struct ceph_snap_context *snapc = req->r_snapc; 554 struct ceph_snap_context *snapc = req->r_snapc;
564 struct address_space *mapping = inode->i_mapping; 555 struct address_space *mapping = inode->i_mapping;
565 __s32 rc = -EIO; 556 int rc = req->r_result;
566 u64 bytes = 0; 557 u64 bytes = le64_to_cpu(req->r_request_ops[0].extent.length);
567 struct ceph_fs_client *fsc = ceph_inode_to_client(inode); 558 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
568 long writeback_stat; 559 long writeback_stat;
569 unsigned issued = ceph_caps_issued(ci); 560 unsigned issued = ceph_caps_issued(ci);
570 561
571 /* parse reply */
572 replyhead = msg->front.iov_base;
573 WARN_ON(le32_to_cpu(replyhead->num_ops) == 0);
574 op = (void *)(replyhead + 1);
575 rc = le32_to_cpu(replyhead->result);
576 bytes = le64_to_cpu(op->extent.length);
577
578 if (rc >= 0) { 562 if (rc >= 0) {
579 /* 563 /*
580 * Assume we wrote the pages we originally sent. The 564 * Assume we wrote the pages we originally sent. The
@@ -741,8 +725,6 @@ retry:
741 struct page *page; 725 struct page *page;
742 int want; 726 int want;
743 u64 offset, len; 727 u64 offset, len;
744 struct ceph_osd_request_head *reqhead;
745 struct ceph_osd_op *op;
746 long writeback_stat; 728 long writeback_stat;
747 729
748 next = 0; 730 next = 0;
@@ -838,7 +820,7 @@ get_more_pages:
838 snapc, do_sync, 820 snapc, do_sync,
839 ci->i_truncate_seq, 821 ci->i_truncate_seq,
840 ci->i_truncate_size, 822 ci->i_truncate_size,
841 &inode->i_mtime, true, 1, 0); 823 &inode->i_mtime, true, 0);
842 824
843 if (IS_ERR(req)) { 825 if (IS_ERR(req)) {
844 rc = PTR_ERR(req); 826 rc = PTR_ERR(req);
@@ -906,10 +888,8 @@ get_more_pages:
906 888
907 /* revise final length, page count */ 889 /* revise final length, page count */
908 req->r_num_pages = locked_pages; 890 req->r_num_pages = locked_pages;
909 reqhead = req->r_request->front.iov_base; 891 req->r_request_ops[0].extent.length = cpu_to_le64(len);
910 op = (void *)(reqhead + 1); 892 req->r_request_ops[0].payload_len = cpu_to_le32(len);
911 op->extent.length = cpu_to_le64(len);
912 op->payload_len = cpu_to_le32(len);
913 req->r_request->hdr.data_len = cpu_to_le32(len); 893 req->r_request->hdr.data_len = cpu_to_le32(len);
914 894
915 rc = ceph_osdc_start_request(&fsc->client->osdc, req, true); 895 rc = ceph_osdc_start_request(&fsc->client->osdc, req, true);
@@ -977,7 +957,7 @@ static int ceph_update_writeable_page(struct file *file,
977 loff_t pos, unsigned len, 957 loff_t pos, unsigned len,
978 struct page *page) 958 struct page *page)
979{ 959{
980 struct inode *inode = file->f_dentry->d_inode; 960 struct inode *inode = file_inode(file);
981 struct ceph_inode_info *ci = ceph_inode(inode); 961 struct ceph_inode_info *ci = ceph_inode(inode);
982 struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc; 962 struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
983 loff_t page_off = pos & PAGE_CACHE_MASK; 963 loff_t page_off = pos & PAGE_CACHE_MASK;
@@ -1086,7 +1066,7 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping,
1086 loff_t pos, unsigned len, unsigned flags, 1066 loff_t pos, unsigned len, unsigned flags,
1087 struct page **pagep, void **fsdata) 1067 struct page **pagep, void **fsdata)
1088{ 1068{
1089 struct inode *inode = file->f_dentry->d_inode; 1069 struct inode *inode = file_inode(file);
1090 struct ceph_inode_info *ci = ceph_inode(inode); 1070 struct ceph_inode_info *ci = ceph_inode(inode);
1091 struct ceph_file_info *fi = file->private_data; 1071 struct ceph_file_info *fi = file->private_data;
1092 struct page *page; 1072 struct page *page;
@@ -1144,7 +1124,7 @@ static int ceph_write_end(struct file *file, struct address_space *mapping,
1144 loff_t pos, unsigned len, unsigned copied, 1124 loff_t pos, unsigned len, unsigned copied,
1145 struct page *page, void *fsdata) 1125 struct page *page, void *fsdata)
1146{ 1126{
1147 struct inode *inode = file->f_dentry->d_inode; 1127 struct inode *inode = file_inode(file);
1148 struct ceph_inode_info *ci = ceph_inode(inode); 1128 struct ceph_inode_info *ci = ceph_inode(inode);
1149 struct ceph_fs_client *fsc = ceph_inode_to_client(inode); 1129 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
1150 struct ceph_mds_client *mdsc = fsc->mdsc; 1130 struct ceph_mds_client *mdsc = fsc->mdsc;
@@ -1228,7 +1208,7 @@ const struct address_space_operations ceph_aops = {
1228 */ 1208 */
1229static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) 1209static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
1230{ 1210{
1231 struct inode *inode = vma->vm_file->f_dentry->d_inode; 1211 struct inode *inode = file_inode(vma->vm_file);
1232 struct page *page = vmf->page; 1212 struct page *page = vmf->page;
1233 struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc; 1213 struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
1234 loff_t off = page_offset(page); 1214 loff_t off = page_offset(page);