aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ceph')
-rw-r--r--fs/ceph/addr.c36
-rw-r--r--fs/ceph/file.c20
2 files changed, 36 insertions, 20 deletions
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index ae438d02a422..681463d5459b 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -284,7 +284,9 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
284 &ceph_inode_to_client(inode)->client->osdc; 284 &ceph_inode_to_client(inode)->client->osdc;
285 struct ceph_inode_info *ci = ceph_inode(inode); 285 struct ceph_inode_info *ci = ceph_inode(inode);
286 struct page *page = list_entry(page_list->prev, struct page, lru); 286 struct page *page = list_entry(page_list->prev, struct page, lru);
287 struct ceph_vino vino;
287 struct ceph_osd_request *req; 288 struct ceph_osd_request *req;
289 struct ceph_osd_req_op op;
288 u64 off; 290 u64 off;
289 u64 len; 291 u64 len;
290 int i; 292 int i;
@@ -308,16 +310,17 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
308 len = nr_pages << PAGE_CACHE_SHIFT; 310 len = nr_pages << PAGE_CACHE_SHIFT;
309 dout("start_read %p nr_pages %d is %lld~%lld\n", inode, nr_pages, 311 dout("start_read %p nr_pages %d is %lld~%lld\n", inode, nr_pages,
310 off, len); 312 off, len);
311 313 vino = ceph_vino(inode);
312 req = ceph_osdc_new_request(osdc, &ci->i_layout, ceph_vino(inode), 314 req = ceph_osdc_new_request(osdc, &ci->i_layout, vino, off, &len,
313 off, &len, 315 1, &op, CEPH_OSD_OP_READ,
314 CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, 316 CEPH_OSD_FLAG_READ, NULL,
315 NULL, 0,
316 ci->i_truncate_seq, ci->i_truncate_size, 317 ci->i_truncate_seq, ci->i_truncate_size,
317 NULL, false); 318 false);
318 if (IS_ERR(req)) 319 if (IS_ERR(req))
319 return PTR_ERR(req); 320 return PTR_ERR(req);
320 321
322 ceph_osdc_build_request(req, off, 1, &op, NULL, vino.snap, NULL);
323
321 /* build page vector */ 324 /* build page vector */
322 nr_pages = calc_pages_for(0, len); 325 nr_pages = calc_pages_for(0, len);
323 pages = kmalloc(sizeof(*pages) * nr_pages, GFP_NOFS); 326 pages = kmalloc(sizeof(*pages) * nr_pages, GFP_NOFS);
@@ -736,6 +739,7 @@ retry:
736 last_snapc = snapc; 739 last_snapc = snapc;
737 740
738 while (!done && index <= end) { 741 while (!done && index <= end) {
742 struct ceph_osd_req_op ops[2];
739 unsigned i; 743 unsigned i;
740 int first; 744 int first;
741 pgoff_t next; 745 pgoff_t next;
@@ -825,20 +829,22 @@ get_more_pages:
825 829
826 /* ok */ 830 /* ok */
827 if (locked_pages == 0) { 831 if (locked_pages == 0) {
832 struct ceph_vino vino;
833 int num_ops = do_sync ? 2 : 1;
834
828 /* prepare async write request */ 835 /* prepare async write request */
829 offset = (u64) page_offset(page); 836 offset = (u64) page_offset(page);
830 len = wsize; 837 len = wsize;
838 vino = ceph_vino(inode);
839 /* BUG_ON(vino.snap != CEPH_NOSNAP); */
831 req = ceph_osdc_new_request(&fsc->client->osdc, 840 req = ceph_osdc_new_request(&fsc->client->osdc,
832 &ci->i_layout, 841 &ci->i_layout, vino, offset, &len,
833 ceph_vino(inode), 842 num_ops, ops,
834 offset, &len,
835 CEPH_OSD_OP_WRITE, 843 CEPH_OSD_OP_WRITE,
836 CEPH_OSD_FLAG_WRITE | 844 CEPH_OSD_FLAG_WRITE |
837 CEPH_OSD_FLAG_ONDISK, 845 CEPH_OSD_FLAG_ONDISK,
838 snapc, do_sync, 846 snapc, ci->i_truncate_seq,
839 ci->i_truncate_seq, 847 ci->i_truncate_size, true);
840 ci->i_truncate_size,
841 &inode->i_mtime, true);
842 848
843 if (IS_ERR(req)) { 849 if (IS_ERR(req)) {
844 rc = PTR_ERR(req); 850 rc = PTR_ERR(req);
@@ -846,6 +852,10 @@ get_more_pages:
846 break; 852 break;
847 } 853 }
848 854
855 ceph_osdc_build_request(req, offset,
856 num_ops, ops, snapc, vino.snap,
857 &inode->i_mtime);
858
849 req->r_data_out.type = CEPH_OSD_DATA_TYPE_PAGES; 859 req->r_data_out.type = CEPH_OSD_DATA_TYPE_PAGES;
850 req->r_data_out.length = len; 860 req->r_data_out.length = len;
851 req->r_data_out.alignment = 0; 861 req->r_data_out.alignment = 0;
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index aeafa67bfe99..3d6dcf23b4ad 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -475,14 +475,17 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
475 struct inode *inode = file_inode(file); 475 struct inode *inode = file_inode(file);
476 struct ceph_inode_info *ci = ceph_inode(inode); 476 struct ceph_inode_info *ci = ceph_inode(inode);
477 struct ceph_fs_client *fsc = ceph_inode_to_client(inode); 477 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
478 struct ceph_snap_context *snapc;
479 struct ceph_vino vino;
478 struct ceph_osd_request *req; 480 struct ceph_osd_request *req;
481 struct ceph_osd_req_op ops[2];
482 int num_ops = 1;
479 struct page **pages; 483 struct page **pages;
480 int num_pages; 484 int num_pages;
481 long long unsigned pos; 485 long long unsigned pos;
482 u64 len; 486 u64 len;
483 int written = 0; 487 int written = 0;
484 int flags; 488 int flags;
485 int do_sync = 0;
486 int check_caps = 0; 489 int check_caps = 0;
487 int page_align, io_align; 490 int page_align, io_align;
488 unsigned long buf_align; 491 unsigned long buf_align;
@@ -516,7 +519,7 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
516 if ((file->f_flags & (O_SYNC|O_DIRECT)) == 0) 519 if ((file->f_flags & (O_SYNC|O_DIRECT)) == 0)
517 flags |= CEPH_OSD_FLAG_ACK; 520 flags |= CEPH_OSD_FLAG_ACK;
518 else 521 else
519 do_sync = 1; 522 num_ops++; /* Also include a 'startsync' command. */
520 523
521 /* 524 /*
522 * we may need to do multiple writes here if we span an object 525 * we may need to do multiple writes here if we span an object
@@ -527,16 +530,19 @@ more:
527 buf_align = (unsigned long)data & ~PAGE_MASK; 530 buf_align = (unsigned long)data & ~PAGE_MASK;
528 len = left; 531 len = left;
529 532
533 snapc = ci->i_snap_realm->cached_context;
534 vino = ceph_vino(inode);
530 req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, 535 req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout,
531 ceph_vino(inode), pos, &len, 536 vino, pos, &len, num_ops, ops,
532 CEPH_OSD_OP_WRITE, flags, 537 CEPH_OSD_OP_WRITE, flags, snapc,
533 ci->i_snap_realm->cached_context,
534 do_sync,
535 ci->i_truncate_seq, ci->i_truncate_size, 538 ci->i_truncate_seq, ci->i_truncate_size,
536 &mtime, false); 539 false);
537 if (IS_ERR(req)) 540 if (IS_ERR(req))
538 return PTR_ERR(req); 541 return PTR_ERR(req);
539 542
543 ceph_osdc_build_request(req, pos, num_ops, ops,
544 snapc, vino.snap, &mtime);
545
540 /* write from beginning of first page, regardless of io alignment */ 546 /* write from beginning of first page, regardless of io alignment */
541 page_align = file->f_flags & O_DIRECT ? buf_align : io_align; 547 page_align = file->f_flags & O_DIRECT ? buf_align : io_align;
542 num_pages = calc_pages_for(page_align, len); 548 num_pages = calc_pages_for(page_align, len);