]> Pileus Git - ~andy/linux/commitdiff
libceph: move ceph_osdc_build_request()
authorAlex Elder <elder@inktank.com>
Fri, 5 Apr 2013 06:27:12 +0000 (01:27 -0500)
committerSage Weil <sage@inktank.com>
Thu, 2 May 2013 04:18:21 +0000 (21:18 -0700)
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>
net/ceph/osd_client.c

index db2624860384ac3851e041b77c4062c20268e4a6..3fe8a7909ed9720e34fcc0128950ecba9fbebb79 100644 (file)
@@ -525,104 +525,6 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req,
        return request_data_len;
 }
 
-/*
- * build new request AND message
- *
- */
-void ceph_osdc_build_request(struct ceph_osd_request *req, u64 off,
-                               struct ceph_snap_context *snapc, u64 snap_id,
-                               struct timespec *mtime)
-{
-       struct ceph_msg *msg = req->r_request;
-       void *p;
-       size_t msg_size;
-       int flags = req->r_flags;
-       u64 data_len;
-       unsigned int i;
-
-       req->r_snapid = snap_id;
-       req->r_snapc = ceph_get_snap_context(snapc);
-
-       /* encode request */
-       msg->hdr.version = cpu_to_le16(4);
-
-       p = msg->front.iov_base;
-       ceph_encode_32(&p, 1);   /* client_inc  is always 1 */
-       req->r_request_osdmap_epoch = p;
-       p += 4;
-       req->r_request_flags = p;
-       p += 4;
-       if (req->r_flags & CEPH_OSD_FLAG_WRITE)
-               ceph_encode_timespec(p, mtime);
-       p += sizeof(struct ceph_timespec);
-       req->r_request_reassert_version = p;
-       p += sizeof(struct ceph_eversion); /* will get filled in */
-
-       /* oloc */
-       ceph_encode_8(&p, 4);
-       ceph_encode_8(&p, 4);
-       ceph_encode_32(&p, 8 + 4 + 4);
-       req->r_request_pool = p;
-       p += 8;
-       ceph_encode_32(&p, -1);  /* preferred */
-       ceph_encode_32(&p, 0);   /* key len */
-
-       ceph_encode_8(&p, 1);
-       req->r_request_pgid = p;
-       p += 8 + 4;
-       ceph_encode_32(&p, -1);  /* preferred */
-
-       /* oid */
-       ceph_encode_32(&p, req->r_oid_len);
-       memcpy(p, req->r_oid, req->r_oid_len);
-       dout("oid '%.*s' len %d\n", req->r_oid_len, req->r_oid, req->r_oid_len);
-       p += req->r_oid_len;
-
-       /* ops--can imply data */
-       ceph_encode_16(&p, (u16)req->r_num_ops);
-       data_len = 0;
-       for (i = 0; i < req->r_num_ops; i++) {
-               data_len += osd_req_encode_op(req, p, i);
-               p += sizeof(struct ceph_osd_op);
-       }
-
-       /* snaps */
-       ceph_encode_64(&p, req->r_snapid);
-       ceph_encode_64(&p, req->r_snapc ? req->r_snapc->seq : 0);
-       ceph_encode_32(&p, req->r_snapc ? req->r_snapc->num_snaps : 0);
-       if (req->r_snapc) {
-               for (i = 0; i < snapc->num_snaps; i++) {
-                       ceph_encode_64(&p, req->r_snapc->snaps[i]);
-               }
-       }
-
-       req->r_request_attempts = p;
-       p += 4;
-
-       /* data */
-       if (flags & CEPH_OSD_FLAG_WRITE) {
-               u16 data_off;
-
-               /*
-                * The header "data_off" is a hint to the receiver
-                * allowing it to align received data into its
-                * buffers such that there's no need to re-copy
-                * it before writing it to disk (direct I/O).
-                */
-               data_off = (u16) (off & 0xffff);
-               req->r_request->hdr.data_off = cpu_to_le16(data_off);
-       }
-       req->r_request->hdr.data_len = cpu_to_le32(data_len);
-
-       BUG_ON(p > msg->front.iov_base + msg->front.iov_len);
-       msg_size = p - msg->front.iov_base;
-       msg->front.iov_len = msg_size;
-       msg->hdr.front_len = cpu_to_le32(msg_size);
-
-       dout("build_request msg_size was %d\n", (int)msg_size);
-}
-EXPORT_SYMBOL(ceph_osdc_build_request);
-
 /*
  * build new request AND message, calculate layout, and adjust file
  * extent as needed.
@@ -1967,6 +1869,104 @@ static void ceph_osdc_msg_data_set(struct ceph_msg *msg,
        }
 }
 
+/*
+ * build new request AND message
+ *
+ */
+void ceph_osdc_build_request(struct ceph_osd_request *req, u64 off,
+                               struct ceph_snap_context *snapc, u64 snap_id,
+                               struct timespec *mtime)
+{
+       struct ceph_msg *msg = req->r_request;
+       void *p;
+       size_t msg_size;
+       int flags = req->r_flags;
+       u64 data_len;
+       unsigned int i;
+
+       req->r_snapid = snap_id;
+       req->r_snapc = ceph_get_snap_context(snapc);
+
+       /* encode request */
+       msg->hdr.version = cpu_to_le16(4);
+
+       p = msg->front.iov_base;
+       ceph_encode_32(&p, 1);   /* client_inc  is always 1 */
+       req->r_request_osdmap_epoch = p;
+       p += 4;
+       req->r_request_flags = p;
+       p += 4;
+       if (req->r_flags & CEPH_OSD_FLAG_WRITE)
+               ceph_encode_timespec(p, mtime);
+       p += sizeof(struct ceph_timespec);
+       req->r_request_reassert_version = p;
+       p += sizeof(struct ceph_eversion); /* will get filled in */
+
+       /* oloc */
+       ceph_encode_8(&p, 4);
+       ceph_encode_8(&p, 4);
+       ceph_encode_32(&p, 8 + 4 + 4);
+       req->r_request_pool = p;
+       p += 8;
+       ceph_encode_32(&p, -1);  /* preferred */
+       ceph_encode_32(&p, 0);   /* key len */
+
+       ceph_encode_8(&p, 1);
+       req->r_request_pgid = p;
+       p += 8 + 4;
+       ceph_encode_32(&p, -1);  /* preferred */
+
+       /* oid */
+       ceph_encode_32(&p, req->r_oid_len);
+       memcpy(p, req->r_oid, req->r_oid_len);
+       dout("oid '%.*s' len %d\n", req->r_oid_len, req->r_oid, req->r_oid_len);
+       p += req->r_oid_len;
+
+       /* ops--can imply data */
+       ceph_encode_16(&p, (u16)req->r_num_ops);
+       data_len = 0;
+       for (i = 0; i < req->r_num_ops; i++) {
+               data_len += osd_req_encode_op(req, p, i);
+               p += sizeof(struct ceph_osd_op);
+       }
+
+       /* snaps */
+       ceph_encode_64(&p, req->r_snapid);
+       ceph_encode_64(&p, req->r_snapc ? req->r_snapc->seq : 0);
+       ceph_encode_32(&p, req->r_snapc ? req->r_snapc->num_snaps : 0);
+       if (req->r_snapc) {
+               for (i = 0; i < snapc->num_snaps; i++) {
+                       ceph_encode_64(&p, req->r_snapc->snaps[i]);
+               }
+       }
+
+       req->r_request_attempts = p;
+       p += 4;
+
+       /* data */
+       if (flags & CEPH_OSD_FLAG_WRITE) {
+               u16 data_off;
+
+               /*
+                * The header "data_off" is a hint to the receiver
+                * allowing it to align received data into its
+                * buffers such that there's no need to re-copy
+                * it before writing it to disk (direct I/O).
+                */
+               data_off = (u16) (off & 0xffff);
+               req->r_request->hdr.data_off = cpu_to_le16(data_off);
+       }
+       req->r_request->hdr.data_len = cpu_to_le32(data_len);
+
+       BUG_ON(p > msg->front.iov_base + msg->front.iov_len);
+       msg_size = p - msg->front.iov_base;
+       msg->front.iov_len = msg_size;
+       msg->hdr.front_len = cpu_to_le32(msg_size);
+
+       dout("build_request msg_size was %d\n", (int)msg_size);
+}
+EXPORT_SYMBOL(ceph_osdc_build_request);
+
 /*
  * Register request, send initial attempt.
  */