diff options
| author | Yan, Zheng <zyan@redhat.com> | 2014-11-13 01:40:37 -0500 |
|---|---|---|
| committer | Ilya Dryomov <idryomov@redhat.com> | 2014-12-17 12:09:52 -0500 |
| commit | 715e4cd405cfd67bd058e410b3e599bab2072645 (patch) | |
| tree | 20b4b1bf1fe86e7719f82c4804228e887592d832 | |
| parent | 864e9197f10c77053bbaf12932f5b200bb4ed3c5 (diff) | |
libceph: specify position of extent operation
allow specifying position of extent operation in multi-operations
osd request. This is required for cephfs to convert inline data to
normal data (compare xattr, then write object).
Signed-off-by: Yan, Zheng <zyan@redhat.com>
Reviewed-by: Ilya Dryomov <idryomov@redhat.com>
| -rw-r--r-- | fs/ceph/addr.c | 9 | ||||
| -rw-r--r-- | fs/ceph/file.c | 8 | ||||
| -rw-r--r-- | include/linux/ceph/osd_client.h | 3 | ||||
| -rw-r--r-- | net/ceph/osd_client.c | 19 |
4 files changed, 19 insertions, 20 deletions
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 18c06bbaf136..f2c7aa878aa4 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c | |||
| @@ -319,7 +319,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max) | |||
| 319 | off, len); | 319 | off, len); |
| 320 | vino = ceph_vino(inode); | 320 | vino = ceph_vino(inode); |
| 321 | req = ceph_osdc_new_request(osdc, &ci->i_layout, vino, off, &len, | 321 | req = ceph_osdc_new_request(osdc, &ci->i_layout, vino, off, &len, |
| 322 | 1, CEPH_OSD_OP_READ, | 322 | 0, 1, CEPH_OSD_OP_READ, |
| 323 | CEPH_OSD_FLAG_READ, NULL, | 323 | CEPH_OSD_FLAG_READ, NULL, |
| 324 | ci->i_truncate_seq, ci->i_truncate_size, | 324 | ci->i_truncate_seq, ci->i_truncate_size, |
| 325 | false); | 325 | false); |
| @@ -750,7 +750,6 @@ retry: | |||
| 750 | last_snapc = snapc; | 750 | last_snapc = snapc; |
| 751 | 751 | ||
| 752 | while (!done && index <= end) { | 752 | while (!done && index <= end) { |
| 753 | int num_ops = do_sync ? 2 : 1; | ||
| 754 | unsigned i; | 753 | unsigned i; |
| 755 | int first; | 754 | int first; |
| 756 | pgoff_t next; | 755 | pgoff_t next; |
| @@ -850,7 +849,8 @@ get_more_pages: | |||
| 850 | len = wsize; | 849 | len = wsize; |
| 851 | req = ceph_osdc_new_request(&fsc->client->osdc, | 850 | req = ceph_osdc_new_request(&fsc->client->osdc, |
| 852 | &ci->i_layout, vino, | 851 | &ci->i_layout, vino, |
| 853 | offset, &len, num_ops, | 852 | offset, &len, 0, |
| 853 | do_sync ? 2 : 1, | ||
| 854 | CEPH_OSD_OP_WRITE, | 854 | CEPH_OSD_OP_WRITE, |
| 855 | CEPH_OSD_FLAG_WRITE | | 855 | CEPH_OSD_FLAG_WRITE | |
| 856 | CEPH_OSD_FLAG_ONDISK, | 856 | CEPH_OSD_FLAG_ONDISK, |
| @@ -862,6 +862,9 @@ get_more_pages: | |||
| 862 | break; | 862 | break; |
| 863 | } | 863 | } |
| 864 | 864 | ||
| 865 | if (do_sync) | ||
| 866 | osd_req_op_init(req, 1, CEPH_OSD_OP_STARTSYNC); | ||
| 867 | |||
| 865 | req->r_callback = writepages_finish; | 868 | req->r_callback = writepages_finish; |
| 866 | req->r_inode = inode; | 869 | req->r_inode = inode; |
| 867 | 870 | ||
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index d7e0da8366e6..c03ac4c4bcd1 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c | |||
| @@ -598,7 +598,7 @@ ceph_sync_direct_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos) | |||
| 598 | snapc = ci->i_snap_realm->cached_context; | 598 | snapc = ci->i_snap_realm->cached_context; |
| 599 | vino = ceph_vino(inode); | 599 | vino = ceph_vino(inode); |
| 600 | req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, | 600 | req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, |
| 601 | vino, pos, &len, | 601 | vino, pos, &len, 0, |
| 602 | 2,/*include a 'startsync' command*/ | 602 | 2,/*include a 'startsync' command*/ |
| 603 | CEPH_OSD_OP_WRITE, flags, snapc, | 603 | CEPH_OSD_OP_WRITE, flags, snapc, |
| 604 | ci->i_truncate_seq, | 604 | ci->i_truncate_seq, |
| @@ -609,6 +609,8 @@ ceph_sync_direct_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos) | |||
| 609 | break; | 609 | break; |
| 610 | } | 610 | } |
| 611 | 611 | ||
| 612 | osd_req_op_init(req, 1, CEPH_OSD_OP_STARTSYNC); | ||
| 613 | |||
| 612 | n = iov_iter_get_pages_alloc(from, &pages, len, &start); | 614 | n = iov_iter_get_pages_alloc(from, &pages, len, &start); |
| 613 | if (unlikely(n < 0)) { | 615 | if (unlikely(n < 0)) { |
| 614 | ret = n; | 616 | ret = n; |
| @@ -713,7 +715,7 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos) | |||
| 713 | snapc = ci->i_snap_realm->cached_context; | 715 | snapc = ci->i_snap_realm->cached_context; |
| 714 | vino = ceph_vino(inode); | 716 | vino = ceph_vino(inode); |
| 715 | req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, | 717 | req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, |
| 716 | vino, pos, &len, 1, | 718 | vino, pos, &len, 0, 1, |
| 717 | CEPH_OSD_OP_WRITE, flags, snapc, | 719 | CEPH_OSD_OP_WRITE, flags, snapc, |
| 718 | ci->i_truncate_seq, | 720 | ci->i_truncate_seq, |
| 719 | ci->i_truncate_size, | 721 | ci->i_truncate_size, |
| @@ -1111,7 +1113,7 @@ static int ceph_zero_partial_object(struct inode *inode, | |||
| 1111 | req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, | 1113 | req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, |
| 1112 | ceph_vino(inode), | 1114 | ceph_vino(inode), |
| 1113 | offset, length, | 1115 | offset, length, |
| 1114 | 1, op, | 1116 | 0, 1, op, |
| 1115 | CEPH_OSD_FLAG_WRITE | | 1117 | CEPH_OSD_FLAG_WRITE | |
| 1116 | CEPH_OSD_FLAG_ONDISK, | 1118 | CEPH_OSD_FLAG_ONDISK, |
| 1117 | NULL, 0, 0, false); | 1119 | NULL, 0, 0, false); |
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h index bcf9c2180ea5..5d86416d35f2 100644 --- a/include/linux/ceph/osd_client.h +++ b/include/linux/ceph/osd_client.h | |||
| @@ -328,7 +328,8 @@ extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *, | |||
| 328 | struct ceph_file_layout *layout, | 328 | struct ceph_file_layout *layout, |
| 329 | struct ceph_vino vino, | 329 | struct ceph_vino vino, |
| 330 | u64 offset, u64 *len, | 330 | u64 offset, u64 *len, |
| 331 | int num_ops, int opcode, int flags, | 331 | unsigned int which, int num_ops, |
| 332 | int opcode, int flags, | ||
| 332 | struct ceph_snap_context *snapc, | 333 | struct ceph_snap_context *snapc, |
| 333 | u32 truncate_seq, u64 truncate_size, | 334 | u32 truncate_seq, u64 truncate_size, |
| 334 | bool use_mempool); | 335 | bool use_mempool); |
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index af1b3ee195e9..53299c7b0ca4 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
| @@ -753,7 +753,8 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req, | |||
| 753 | struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | 753 | struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, |
| 754 | struct ceph_file_layout *layout, | 754 | struct ceph_file_layout *layout, |
| 755 | struct ceph_vino vino, | 755 | struct ceph_vino vino, |
| 756 | u64 off, u64 *plen, int num_ops, | 756 | u64 off, u64 *plen, |
| 757 | unsigned int which, int num_ops, | ||
| 757 | int opcode, int flags, | 758 | int opcode, int flags, |
| 758 | struct ceph_snap_context *snapc, | 759 | struct ceph_snap_context *snapc, |
| 759 | u32 truncate_seq, | 760 | u32 truncate_seq, |
| @@ -785,7 +786,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
| 785 | } | 786 | } |
| 786 | 787 | ||
| 787 | if (opcode == CEPH_OSD_OP_CREATE || opcode == CEPH_OSD_OP_DELETE) { | 788 | if (opcode == CEPH_OSD_OP_CREATE || opcode == CEPH_OSD_OP_DELETE) { |
| 788 | osd_req_op_init(req, 0, opcode); | 789 | osd_req_op_init(req, which, opcode); |
| 789 | } else { | 790 | } else { |
| 790 | u32 object_size = le32_to_cpu(layout->fl_object_size); | 791 | u32 object_size = le32_to_cpu(layout->fl_object_size); |
| 791 | u32 object_base = off - objoff; | 792 | u32 object_base = off - objoff; |
| @@ -798,17 +799,9 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
| 798 | truncate_size = object_size; | 799 | truncate_size = object_size; |
| 799 | } | 800 | } |
| 800 | } | 801 | } |
| 801 | 802 | osd_req_op_extent_init(req, which, opcode, objoff, objlen, | |
| 802 | osd_req_op_extent_init(req, 0, opcode, objoff, objlen, | ||
| 803 | truncate_size, truncate_seq); | 803 | truncate_size, truncate_seq); |
| 804 | } | 804 | } |
| 805 | /* | ||
| 806 | * A second op in the ops array means the caller wants to | ||
| 807 | * also issue a include a 'startsync' command so that the | ||
| 808 | * osd will flush data quickly. | ||
| 809 | */ | ||
| 810 | if (num_ops > 1) | ||
| 811 | osd_req_op_init(req, 1, CEPH_OSD_OP_STARTSYNC); | ||
| 812 | 805 | ||
| 813 | req->r_base_oloc.pool = ceph_file_layout_pg_pool(*layout); | 806 | req->r_base_oloc.pool = ceph_file_layout_pg_pool(*layout); |
| 814 | 807 | ||
| @@ -2675,7 +2668,7 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc, | |||
| 2675 | 2668 | ||
| 2676 | dout("readpages on ino %llx.%llx on %llu~%llu\n", vino.ino, | 2669 | dout("readpages on ino %llx.%llx on %llu~%llu\n", vino.ino, |
| 2677 | vino.snap, off, *plen); | 2670 | vino.snap, off, *plen); |
| 2678 | req = ceph_osdc_new_request(osdc, layout, vino, off, plen, 1, | 2671 | req = ceph_osdc_new_request(osdc, layout, vino, off, plen, 0, 1, |
| 2679 | CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, | 2672 | CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, |
| 2680 | NULL, truncate_seq, truncate_size, | 2673 | NULL, truncate_seq, truncate_size, |
| 2681 | false); | 2674 | false); |
| @@ -2718,7 +2711,7 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino, | |||
| 2718 | int page_align = off & ~PAGE_MASK; | 2711 | int page_align = off & ~PAGE_MASK; |
| 2719 | 2712 | ||
| 2720 | BUG_ON(vino.snap != CEPH_NOSNAP); /* snapshots aren't writeable */ | 2713 | BUG_ON(vino.snap != CEPH_NOSNAP); /* snapshots aren't writeable */ |
| 2721 | req = ceph_osdc_new_request(osdc, layout, vino, off, &len, 1, | 2714 | req = ceph_osdc_new_request(osdc, layout, vino, off, &len, 0, 1, |
| 2722 | CEPH_OSD_OP_WRITE, | 2715 | CEPH_OSD_OP_WRITE, |
| 2723 | CEPH_OSD_FLAG_ONDISK | CEPH_OSD_FLAG_WRITE, | 2716 | CEPH_OSD_FLAG_ONDISK | CEPH_OSD_FLAG_WRITE, |
| 2724 | snapc, truncate_seq, truncate_size, | 2717 | snapc, truncate_seq, truncate_size, |
