diff options
author | Alex Elder <elder@inktank.com> | 2013-04-05 02:27:12 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-05-02 00:18:21 -0400 |
commit | e65550fd94c5c01b438e24fbf4a29ba65709ec97 (patch) | |
tree | 589ea50de6231f616fa3948e7f7e943938ed182f /net/ceph | |
parent | 5f562df5f59340eae4272501b974903f48d2ad92 (diff) |
libceph: move ceph_osdc_build_request()
This simply moves ceph_osdc_build_request() later in its source
file without any change. Done as a separate patch to facilitate
review of the change in the next patch.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'net/ceph')
-rw-r--r-- | net/ceph/osd_client.c | 196 |
1 files changed, 98 insertions, 98 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index db2624860384..3fe8a7909ed9 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -526,104 +526,6 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req, | |||
526 | } | 526 | } |
527 | 527 | ||
528 | /* | 528 | /* |
529 | * build new request AND message | ||
530 | * | ||
531 | */ | ||
532 | void ceph_osdc_build_request(struct ceph_osd_request *req, u64 off, | ||
533 | struct ceph_snap_context *snapc, u64 snap_id, | ||
534 | struct timespec *mtime) | ||
535 | { | ||
536 | struct ceph_msg *msg = req->r_request; | ||
537 | void *p; | ||
538 | size_t msg_size; | ||
539 | int flags = req->r_flags; | ||
540 | u64 data_len; | ||
541 | unsigned int i; | ||
542 | |||
543 | req->r_snapid = snap_id; | ||
544 | req->r_snapc = ceph_get_snap_context(snapc); | ||
545 | |||
546 | /* encode request */ | ||
547 | msg->hdr.version = cpu_to_le16(4); | ||
548 | |||
549 | p = msg->front.iov_base; | ||
550 | ceph_encode_32(&p, 1); /* client_inc is always 1 */ | ||
551 | req->r_request_osdmap_epoch = p; | ||
552 | p += 4; | ||
553 | req->r_request_flags = p; | ||
554 | p += 4; | ||
555 | if (req->r_flags & CEPH_OSD_FLAG_WRITE) | ||
556 | ceph_encode_timespec(p, mtime); | ||
557 | p += sizeof(struct ceph_timespec); | ||
558 | req->r_request_reassert_version = p; | ||
559 | p += sizeof(struct ceph_eversion); /* will get filled in */ | ||
560 | |||
561 | /* oloc */ | ||
562 | ceph_encode_8(&p, 4); | ||
563 | ceph_encode_8(&p, 4); | ||
564 | ceph_encode_32(&p, 8 + 4 + 4); | ||
565 | req->r_request_pool = p; | ||
566 | p += 8; | ||
567 | ceph_encode_32(&p, -1); /* preferred */ | ||
568 | ceph_encode_32(&p, 0); /* key len */ | ||
569 | |||
570 | ceph_encode_8(&p, 1); | ||
571 | req->r_request_pgid = p; | ||
572 | p += 8 + 4; | ||
573 | ceph_encode_32(&p, -1); /* preferred */ | ||
574 | |||
575 | /* oid */ | ||
576 | ceph_encode_32(&p, req->r_oid_len); | ||
577 | memcpy(p, req->r_oid, req->r_oid_len); | ||
578 | dout("oid '%.*s' len %d\n", req->r_oid_len, req->r_oid, req->r_oid_len); | ||
579 | p += req->r_oid_len; | ||
580 | |||
581 | /* ops--can imply data */ | ||
582 | ceph_encode_16(&p, (u16)req->r_num_ops); | ||
583 | data_len = 0; | ||
584 | for (i = 0; i < req->r_num_ops; i++) { | ||
585 | data_len += osd_req_encode_op(req, p, i); | ||
586 | p += sizeof(struct ceph_osd_op); | ||
587 | } | ||
588 | |||
589 | /* snaps */ | ||
590 | ceph_encode_64(&p, req->r_snapid); | ||
591 | ceph_encode_64(&p, req->r_snapc ? req->r_snapc->seq : 0); | ||
592 | ceph_encode_32(&p, req->r_snapc ? req->r_snapc->num_snaps : 0); | ||
593 | if (req->r_snapc) { | ||
594 | for (i = 0; i < snapc->num_snaps; i++) { | ||
595 | ceph_encode_64(&p, req->r_snapc->snaps[i]); | ||
596 | } | ||
597 | } | ||
598 | |||
599 | req->r_request_attempts = p; | ||
600 | p += 4; | ||
601 | |||
602 | /* data */ | ||
603 | if (flags & CEPH_OSD_FLAG_WRITE) { | ||
604 | u16 data_off; | ||
605 | |||
606 | /* | ||
607 | * The header "data_off" is a hint to the receiver | ||
608 | * allowing it to align received data into its | ||
609 | * buffers such that there's no need to re-copy | ||
610 | * it before writing it to disk (direct I/O). | ||
611 | */ | ||
612 | data_off = (u16) (off & 0xffff); | ||
613 | req->r_request->hdr.data_off = cpu_to_le16(data_off); | ||
614 | } | ||
615 | req->r_request->hdr.data_len = cpu_to_le32(data_len); | ||
616 | |||
617 | BUG_ON(p > msg->front.iov_base + msg->front.iov_len); | ||
618 | msg_size = p - msg->front.iov_base; | ||
619 | msg->front.iov_len = msg_size; | ||
620 | msg->hdr.front_len = cpu_to_le32(msg_size); | ||
621 | |||
622 | dout("build_request msg_size was %d\n", (int)msg_size); | ||
623 | } | ||
624 | EXPORT_SYMBOL(ceph_osdc_build_request); | ||
625 | |||
626 | /* | ||
627 | * build new request AND message, calculate layout, and adjust file | 529 | * build new request AND message, calculate layout, and adjust file |
628 | * extent as needed. | 530 | * extent as needed. |
629 | * | 531 | * |
@@ -1968,6 +1870,104 @@ static void ceph_osdc_msg_data_set(struct ceph_msg *msg, | |||
1968 | } | 1870 | } |
1969 | 1871 | ||
1970 | /* | 1872 | /* |
1873 | * build new request AND message | ||
1874 | * | ||
1875 | */ | ||
1876 | void ceph_osdc_build_request(struct ceph_osd_request *req, u64 off, | ||
1877 | struct ceph_snap_context *snapc, u64 snap_id, | ||
1878 | struct timespec *mtime) | ||
1879 | { | ||
1880 | struct ceph_msg *msg = req->r_request; | ||
1881 | void *p; | ||
1882 | size_t msg_size; | ||
1883 | int flags = req->r_flags; | ||
1884 | u64 data_len; | ||
1885 | unsigned int i; | ||
1886 | |||
1887 | req->r_snapid = snap_id; | ||
1888 | req->r_snapc = ceph_get_snap_context(snapc); | ||
1889 | |||
1890 | /* encode request */ | ||
1891 | msg->hdr.version = cpu_to_le16(4); | ||
1892 | |||
1893 | p = msg->front.iov_base; | ||
1894 | ceph_encode_32(&p, 1); /* client_inc is always 1 */ | ||
1895 | req->r_request_osdmap_epoch = p; | ||
1896 | p += 4; | ||
1897 | req->r_request_flags = p; | ||
1898 | p += 4; | ||
1899 | if (req->r_flags & CEPH_OSD_FLAG_WRITE) | ||
1900 | ceph_encode_timespec(p, mtime); | ||
1901 | p += sizeof(struct ceph_timespec); | ||
1902 | req->r_request_reassert_version = p; | ||
1903 | p += sizeof(struct ceph_eversion); /* will get filled in */ | ||
1904 | |||
1905 | /* oloc */ | ||
1906 | ceph_encode_8(&p, 4); | ||
1907 | ceph_encode_8(&p, 4); | ||
1908 | ceph_encode_32(&p, 8 + 4 + 4); | ||
1909 | req->r_request_pool = p; | ||
1910 | p += 8; | ||
1911 | ceph_encode_32(&p, -1); /* preferred */ | ||
1912 | ceph_encode_32(&p, 0); /* key len */ | ||
1913 | |||
1914 | ceph_encode_8(&p, 1); | ||
1915 | req->r_request_pgid = p; | ||
1916 | p += 8 + 4; | ||
1917 | ceph_encode_32(&p, -1); /* preferred */ | ||
1918 | |||
1919 | /* oid */ | ||
1920 | ceph_encode_32(&p, req->r_oid_len); | ||
1921 | memcpy(p, req->r_oid, req->r_oid_len); | ||
1922 | dout("oid '%.*s' len %d\n", req->r_oid_len, req->r_oid, req->r_oid_len); | ||
1923 | p += req->r_oid_len; | ||
1924 | |||
1925 | /* ops--can imply data */ | ||
1926 | ceph_encode_16(&p, (u16)req->r_num_ops); | ||
1927 | data_len = 0; | ||
1928 | for (i = 0; i < req->r_num_ops; i++) { | ||
1929 | data_len += osd_req_encode_op(req, p, i); | ||
1930 | p += sizeof(struct ceph_osd_op); | ||
1931 | } | ||
1932 | |||
1933 | /* snaps */ | ||
1934 | ceph_encode_64(&p, req->r_snapid); | ||
1935 | ceph_encode_64(&p, req->r_snapc ? req->r_snapc->seq : 0); | ||
1936 | ceph_encode_32(&p, req->r_snapc ? req->r_snapc->num_snaps : 0); | ||
1937 | if (req->r_snapc) { | ||
1938 | for (i = 0; i < snapc->num_snaps; i++) { | ||
1939 | ceph_encode_64(&p, req->r_snapc->snaps[i]); | ||
1940 | } | ||
1941 | } | ||
1942 | |||
1943 | req->r_request_attempts = p; | ||
1944 | p += 4; | ||
1945 | |||
1946 | /* data */ | ||
1947 | if (flags & CEPH_OSD_FLAG_WRITE) { | ||
1948 | u16 data_off; | ||
1949 | |||
1950 | /* | ||
1951 | * The header "data_off" is a hint to the receiver | ||
1952 | * allowing it to align received data into its | ||
1953 | * buffers such that there's no need to re-copy | ||
1954 | * it before writing it to disk (direct I/O). | ||
1955 | */ | ||
1956 | data_off = (u16) (off & 0xffff); | ||
1957 | req->r_request->hdr.data_off = cpu_to_le16(data_off); | ||
1958 | } | ||
1959 | req->r_request->hdr.data_len = cpu_to_le32(data_len); | ||
1960 | |||
1961 | BUG_ON(p > msg->front.iov_base + msg->front.iov_len); | ||
1962 | msg_size = p - msg->front.iov_base; | ||
1963 | msg->front.iov_len = msg_size; | ||
1964 | msg->hdr.front_len = cpu_to_le32(msg_size); | ||
1965 | |||
1966 | dout("build_request msg_size was %d\n", (int)msg_size); | ||
1967 | } | ||
1968 | EXPORT_SYMBOL(ceph_osdc_build_request); | ||
1969 | |||
1970 | /* | ||
1971 | * Register request, send initial attempt. | 1971 | * Register request, send initial attempt. |
1972 | */ | 1972 | */ |
1973 | int ceph_osdc_start_request(struct ceph_osd_client *osdc, | 1973 | int ceph_osdc_start_request(struct ceph_osd_client *osdc, |