]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kernel: some encoding/decoding cleanup
authorSage Weil <sage@newdream.net>
Thu, 31 Jan 2008 23:29:57 +0000 (15:29 -0800)
committerSage Weil <sage@newdream.net>
Thu, 31 Jan 2008 23:32:03 +0000 (15:32 -0800)
src/TODO
src/kernel/mds_client.c
src/kernel/mdsmap.c
src/kernel/messenger.c
src/kernel/messenger.h
src/kernel/mon_client.c
src/kernel/osd_client.c
src/kernel/osdmap.c

index 9620349f0edbd083ab5bd2c2d9251daa5c63718c..b764c9418b9731b4131b224282d6a5babd4c6910 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -18,7 +18,6 @@ code cleanup
 kernel client
 - some bugs
  - open path needs to call fill_trace/fill_inode such that ci->i_max_size gets filled in
- - echo blah >> mnt/blah "appends" from offset zero, regardless of file size
  - cap handler probably needs i_mutex or something when updating file sizes
    - which means it probably needs to be done in a different worker thread (NOT the messenger's)
  - prevent client_reply from racing against a subsequent file_caps.
@@ -29,10 +28,7 @@ kernel client
 - audit use of kmalloc vs spinlocks
 - convert most everything in ceph_fs.h to le32/le64 notation, cleaning up userspace appropriately
 - vfs
- - generate paths relative to the appropriate vfsmount root?
- - getattr should do an lstat?
- - d_revalidate?
- - test truncate
+ - can we use dentry_path(), if it gets merged into mainline?
 - fix file open vs file_cap race
   - preemptively release caps as part of request if doing utimes/etc. on an open file?
 - mds client
index 8652a13bc3e93039be7ec35c9d6dd60c47485544..d8e9383b5b014b9e5f8cd447157d52d58d4841b1 100644 (file)
@@ -451,7 +451,7 @@ ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op,
        end = req->front.iov_base + req->front.iov_len;
 
        /* encode head */
-       ceph_encode_inst(&head->client_inst, &mdsc->client->msgr->inst);
+       head->client_inst = mdsc->client->msgr->inst;
        /* tid, oldest_client_tid set by do_request */
        head->mdsmap_epoch = cpu_to_le64(mdsc->mdsmap->m_epoch);
        head->num_fwd = 0;
index eb5dd8e3dadeeaeef01ff6dab359a13889854c5c..b734f33b3974f3bf54c546dedbc65ed083d2177e 100644 (file)
@@ -109,7 +109,8 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end)
                if (mds >= m->m_max_mds)
                        goto bad;
                *p += sizeof(struct ceph_entity_name);
-               if ((err = ceph_decode_addr(p, end, &m->m_addr[mds])) != 0)
+               if ((err = ceph_decode_copy(p, end, &m->m_addr[mds],
+                                           sizeof(*m->m_addr))) != 0)
                        goto bad;
        }
 
index a1ab58f59678aad5f72eb9d1e6e6348a82060a5e..8f85c88495aba01604bf3be2af880b1393b323ce 100644 (file)
@@ -419,25 +419,23 @@ static void prepare_write_ack(struct ceph_connection *con)
 
 static void prepare_write_connect(struct ceph_messenger *msgr, struct ceph_connection *con)
 {
-       ceph_encode_addr(&con->out_addr, &msgr->inst.addr);
-       con->out_kvec[0].iov_base = &con->out_addr;
-       con->out_kvec[0].iov_len = sizeof(con->out_addr);
+       con->out_kvec[0].iov_base = &msgr->inst.addr;
+       con->out_kvec[0].iov_len = sizeof(msgr->inst.addr);
        con->out32 = cpu_to_le32(con->connect_seq);
        con->out_kvec[1].iov_base = &con->out32;
        con->out_kvec[1].iov_len = 4;
        con->out_kvec_left = 2;
-       con->out_kvec_bytes = sizeof(con->out_addr) + 4;
+       con->out_kvec_bytes = sizeof(msgr->inst.addr) + 4;
        con->out_kvec_cur = con->out_kvec;
        set_bit(WRITE_PENDING, &con->state);
 }
 
 static void prepare_write_accept_announce(struct ceph_messenger *msgr, struct ceph_connection *con)
 {
-       ceph_encode_addr(&con->out_addr, &msgr->inst.addr);
-       con->out_kvec[0].iov_base = &con->out_addr;
-       con->out_kvec[0].iov_len = sizeof(con->out_addr);
+       con->out_kvec[0].iov_base = &msgr->inst.addr;
+       con->out_kvec[0].iov_len = sizeof(msgr->inst.addr);
        con->out_kvec_left = 1;
-       con->out_kvec_bytes = sizeof(con->out_addr);
+       con->out_kvec_bytes = sizeof(msgr->inst.addr);
        con->out_kvec_cur = con->out_kvec;
        set_bit(WRITE_PENDING, &con->state);
 }
index 859058af78508f3eed579187556690d729ded47c..20b6a82911cfc845dc697018aa10bade720d32fa 100644 (file)
@@ -93,7 +93,6 @@ struct ceph_connection {
        struct list_head out_queue;
        struct list_head out_sent;   /* sending/sent but unacked; resend if connection drops */
 
-       struct ceph_entity_addr out_addr;
        __le32 out32;
        struct kvec out_kvec[4],
                *out_kvec_cur;
@@ -162,49 +161,6 @@ static __inline__ int ceph_decode_copy(void **p, void *end, void *v, int len) {
        return 0;
 }
 
-static __inline__ int ceph_decode_addr(void **p, void *end, struct ceph_entity_addr *v) {
-       int err;
-       if (*p + sizeof(*v) > end) 
-               return -EINVAL;
-       if ((err = ceph_decode_32(p, end, &v->erank)) != 0)
-               return -EINVAL;
-       if ((err = ceph_decode_32(p, end, &v->nonce)) != 0)
-               return -EINVAL;
-       ceph_decode_copy(p, end, &v->ipaddr, sizeof(v->ipaddr));
-       return 0;
-}
-static __inline__ void ceph_encode_addr(struct ceph_entity_addr *to, struct ceph_entity_addr *from)
-{
-       to->erank = cpu_to_le32(from->erank);
-       to->nonce = cpu_to_le32(from->nonce);
-       to->ipaddr = from->ipaddr;
-}
-
-static __inline__ int ceph_decode_name(void **p, void *end, struct ceph_entity_name *v) {
-       if (unlikely(*p + sizeof(*v) > end))
-               return -EINVAL;
-       v->type = le32_to_cpu(*(__u32*)*p);
-       *p += sizeof(__u32);
-       v->num = le32_to_cpu(*(__u32*)*p);
-       *p += sizeof(__u32);
-       return 0;
-}
-
-/* hmm, these are actually identical, yeah? */
-static __inline__ void ceph_decode_inst(struct ceph_entity_inst *to)
-{
-       le32_to_cpus(&to->name.type);
-       le32_to_cpus(&to->name.num);
-       le32_to_cpus(&to->addr.erank);
-       le32_to_cpus(&to->addr.nonce);
-}
-static __inline__ void ceph_encode_inst(struct ceph_entity_inst *to, struct ceph_entity_inst *from)
-{
-       to->name.type = cpu_to_le32(from->name.type);
-       to->name.num = cpu_to_le32(from->name.num);
-       ceph_encode_addr(&to->addr, &from->addr);
-}
-
 static __inline__ int ceph_encode_64(void **p, void *end, __u64 v) {
        BUG_ON(*p + sizeof(v) > end);
        *(__u64*)*p = cpu_to_le64(v);
index dbc7c83242a89ad6f8fb43bfe217a50409f7df6d..404c37de5f10cbb4340651cad4f29aa8b143edde 100644 (file)
@@ -34,7 +34,6 @@ struct ceph_monmap *ceph_monmap_decode(void *p, void *end)
        }
        memcpy(m->mon_inst, p, end-p);
        for (i=0; i<m->num_mon; i++) {
-               ceph_decode_inst(&m->mon_inst[i]);
                dout(30, "monmap_decode mon%d is %x:%d\n", i,
                     ntohl(m->mon_inst[i].addr.ipaddr.sin_addr.s_addr), 
                     ntohs(m->mon_inst[i].addr.ipaddr.sin_port));
index 09e147db347ff078d834b0809f9ad48f0791194a..4a17cdd2d49e0d850447746c32862519e8f31ce1 100644 (file)
@@ -144,9 +144,9 @@ struct ceph_msg *new_request_msg(struct ceph_osd_client *osdc, int op)
 
        /* encode head */
        head->op = cpu_to_le32(op);
-       ceph_encode_inst(&head->client_inst, &osdc->client->msgr->inst);
+       head->client_inst = osdc->client->msgr->inst;
        head->client_inc = 1; /* always, for now. */
-       
+
        return req;
 }
 
index 8ef2b548707baff4a7af9c710f3e7b7243d4aa4f..6ef8df8f9abab1fbceaa719beeb12ff00dddc038 100644 (file)
@@ -447,7 +447,8 @@ struct ceph_osdmap *apply_incremental(void **p, void *end, struct ceph_osdmap *m
                struct ceph_entity_addr addr;
                if ((err = ceph_decode_32(p, end, &osd)) < 0)
                        goto bad;
-               if ((err = ceph_decode_addr(p, end, &addr)) < 0)
+               if ((err = ceph_decode_copy(p, end, &addr, 
+                                           sizeof(addr))) < 0)
                        goto bad;
                dout(1, "osd%d up\n", osd);
                BUG_ON(osd >= map->max_osd);