aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ceph/addr.c7
-rw-r--r--fs/ceph/file.c9
-rw-r--r--include/linux/ceph/osd_client.h2
-rw-r--r--net/ceph/osd_client.c19
4 files changed, 19 insertions, 18 deletions
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index e53f24b15b12..e324222acc82 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -309,7 +309,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
309 CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, 309 CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ,
310 NULL, 0, 310 NULL, 0,
311 ci->i_truncate_seq, ci->i_truncate_size, 311 ci->i_truncate_seq, ci->i_truncate_size,
312 NULL, false, 0); 312 NULL, false);
313 if (IS_ERR(req)) 313 if (IS_ERR(req))
314 return PTR_ERR(req); 314 return PTR_ERR(req);
315 315
@@ -338,6 +338,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
338 } 338 }
339 req->r_pages = pages; 339 req->r_pages = pages;
340 req->r_num_pages = nr_pages; 340 req->r_num_pages = nr_pages;
341 req->r_page_alignment = 0;
341 req->r_callback = finish_read; 342 req->r_callback = finish_read;
342 req->r_inode = inode; 343 req->r_inode = inode;
343 344
@@ -820,7 +821,7 @@ get_more_pages:
820 snapc, do_sync, 821 snapc, do_sync,
821 ci->i_truncate_seq, 822 ci->i_truncate_seq,
822 ci->i_truncate_size, 823 ci->i_truncate_size,
823 &inode->i_mtime, true, 0); 824 &inode->i_mtime, true);
824 825
825 if (IS_ERR(req)) { 826 if (IS_ERR(req)) {
826 rc = PTR_ERR(req); 827 rc = PTR_ERR(req);
@@ -828,6 +829,8 @@ get_more_pages:
828 break; 829 break;
829 } 830 }
830 831
832 req->r_num_pages = calc_pages_for(0, len);
833 req->r_page_alignment = 0;
831 max_pages = req->r_num_pages; 834 max_pages = req->r_num_pages;
832 835
833 alloc_page_vec(fsc, req); 836 alloc_page_vec(fsc, req);
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 146ac9040141..f2754cdb5a03 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -527,19 +527,19 @@ more:
527 buf_align = (unsigned long)data & ~PAGE_MASK; 527 buf_align = (unsigned long)data & ~PAGE_MASK;
528 len = left; 528 len = left;
529 529
530 /* write from beginning of first page, regardless of io alignment */
531 page_align = file->f_flags & O_DIRECT ? buf_align : io_align;
532 num_pages = calc_pages_for(page_align, len);
533 req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, 530 req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout,
534 ceph_vino(inode), pos, &len, 531 ceph_vino(inode), pos, &len,
535 CEPH_OSD_OP_WRITE, flags, 532 CEPH_OSD_OP_WRITE, flags,
536 ci->i_snap_realm->cached_context, 533 ci->i_snap_realm->cached_context,
537 do_sync, 534 do_sync,
538 ci->i_truncate_seq, ci->i_truncate_size, 535 ci->i_truncate_seq, ci->i_truncate_size,
539 &mtime, false, page_align); 536 &mtime, false);
540 if (IS_ERR(req)) 537 if (IS_ERR(req))
541 return PTR_ERR(req); 538 return PTR_ERR(req);
542 539
540 /* write from beginning of first page, regardless of io alignment */
541 page_align = file->f_flags & O_DIRECT ? buf_align : io_align;
542 num_pages = calc_pages_for(page_align, len);
543 if (file->f_flags & O_DIRECT) { 543 if (file->f_flags & O_DIRECT) {
544 pages = ceph_get_direct_page_vector(data, num_pages, false); 544 pages = ceph_get_direct_page_vector(data, num_pages, false);
545 if (IS_ERR(pages)) { 545 if (IS_ERR(pages)) {
@@ -573,6 +573,7 @@ more:
573 } 573 }
574 req->r_pages = pages; 574 req->r_pages = pages;
575 req->r_num_pages = num_pages; 575 req->r_num_pages = num_pages;
576 req->r_page_alignment = page_align;
576 req->r_inode = inode; 577 req->r_inode = inode;
577 578
578 ret = ceph_osdc_start_request(&fsc->client->osdc, req, false); 579 ret = ceph_osdc_start_request(&fsc->client->osdc, req, false);
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index ec33588194ef..803a9db0b475 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -247,7 +247,7 @@ extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *,
247 int do_sync, u32 truncate_seq, 247 int do_sync, u32 truncate_seq,
248 u64 truncate_size, 248 u64 truncate_size,
249 struct timespec *mtime, 249 struct timespec *mtime,
250 bool use_mempool, int page_align); 250 bool use_mempool);
251 251
252extern void ceph_osdc_set_request_linger(struct ceph_osd_client *osdc, 252extern void ceph_osdc_set_request_linger(struct ceph_osd_client *osdc,
253 struct ceph_osd_request *req); 253 struct ceph_osd_request *req);
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 38d09d13bb15..de427cc7f6d0 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -432,8 +432,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
432 u32 truncate_seq, 432 u32 truncate_seq,
433 u64 truncate_size, 433 u64 truncate_size,
434 struct timespec *mtime, 434 struct timespec *mtime,
435 bool use_mempool, 435 bool use_mempool)
436 int page_align)
437{ 436{
438 struct ceph_osd_req_op ops[2]; 437 struct ceph_osd_req_op ops[2];
439 struct ceph_osd_request *req; 438 struct ceph_osd_request *req;
@@ -470,11 +469,6 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
470 snprintf(req->r_oid, sizeof(req->r_oid), "%llx.%08llx", vino.ino, bno); 469 snprintf(req->r_oid, sizeof(req->r_oid), "%llx.%08llx", vino.ino, bno);
471 req->r_oid_len = strlen(req->r_oid); 470 req->r_oid_len = strlen(req->r_oid);
472 471
473 /* The alignment may differ from the natural (file) alignment */
474
475 req->r_num_pages = calc_pages_for(page_align, *plen);
476 req->r_page_alignment = page_align;
477
478 ceph_osdc_build_request(req, off, *plen, num_op, ops, 472 ceph_osdc_build_request(req, off, *plen, num_op, ops,
479 snapc, vino.snap, mtime); 473 snapc, vino.snap, mtime);
480 474
@@ -1945,12 +1939,14 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc,
1945 req = ceph_osdc_new_request(osdc, layout, vino, off, plen, 1939 req = ceph_osdc_new_request(osdc, layout, vino, off, plen,
1946 CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, 1940 CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ,
1947 NULL, 0, truncate_seq, truncate_size, NULL, 1941 NULL, 0, truncate_seq, truncate_size, NULL,
1948 false, page_align); 1942 false);
1949 if (IS_ERR(req)) 1943 if (IS_ERR(req))
1950 return PTR_ERR(req); 1944 return PTR_ERR(req);
1951 1945
1952 /* it may be a short read due to an object boundary */ 1946 /* it may be a short read due to an object boundary */
1953 req->r_pages = pages; 1947 req->r_pages = pages;
1948 req->r_num_pages = calc_pages_for(page_align, *plen);
1949 req->r_page_alignment = page_align;
1954 1950
1955 dout("readpages final extent is %llu~%llu (%d pages align %d)\n", 1951 dout("readpages final extent is %llu~%llu (%d pages align %d)\n",
1956 off, *plen, req->r_num_pages, page_align); 1952 off, *plen, req->r_num_pages, page_align);
@@ -1986,14 +1982,15 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,
1986 CEPH_OSD_FLAG_ONDISK | CEPH_OSD_FLAG_WRITE, 1982 CEPH_OSD_FLAG_ONDISK | CEPH_OSD_FLAG_WRITE,
1987 snapc, 0, 1983 snapc, 0,
1988 truncate_seq, truncate_size, mtime, 1984 truncate_seq, truncate_size, mtime,
1989 true, page_align); 1985 true);
1990 if (IS_ERR(req)) 1986 if (IS_ERR(req))
1991 return PTR_ERR(req); 1987 return PTR_ERR(req);
1992 1988
1993 /* it may be a short write due to an object boundary */ 1989 /* it may be a short write due to an object boundary */
1994 req->r_pages = pages; 1990 req->r_pages = pages;
1995 dout("writepages %llu~%llu (%d pages)\n", off, len, 1991 req->r_num_pages = calc_pages_for(page_align, len);
1996 req->r_num_pages); 1992 req->r_page_alignment = page_align;
1993 dout("writepages %llu~%llu (%d pages)\n", off, len, req->r_num_pages);
1997 1994
1998 rc = ceph_osdc_start_request(osdc, req, true); 1995 rc = ceph_osdc_start_request(osdc, req, true);
1999 if (!rc) 1996 if (!rc)