]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: endianity handling fixes
authorYehuda Sadeh <yehuda@hq.newdream.net>
Thu, 16 Oct 2008 16:29:59 +0000 (09:29 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Thu, 16 Oct 2008 18:28:35 +0000 (11:28 -0700)
src/kernel/addr.c
src/kernel/caps.c
src/kernel/decode.h
src/kernel/dir.c
src/kernel/inode.c
src/kernel/mds_client.c
src/kernel/mds_client.h
src/kernel/messenger.c
src/kernel/messenger.h
src/kernel/snap.c
src/kernel/super.h

index 938ed290104d7f44674bb04a80febd21b1642fd9..019ebdfdfd9eded91ab2a471dec07f78d8a8fc52 100644 (file)
@@ -461,7 +461,7 @@ static void writepages_finish(struct ceph_osd_request *req)
        if (req->r_reply) {
                replyhead = req->r_reply->front.iov_base;
                rc = le32_to_cpu(replyhead->result);
-               bytes = le32_to_cpu(replyhead->length);
+               bytes = le64_to_cpu(replyhead->length);
        }
 
        if (rc >= 0) {
@@ -522,7 +522,6 @@ static int ceph_writepages_start(struct address_space *mapping,
 
        client = ceph_inode_to_client(inode);
 
-       dout(1, "writepage client=%p\n", client);
        if (client->mount_state == CEPH_MOUNT_SHUTDOWN) {
                dout(1, "writepage on forced umount\n");
                return -EIO; /* we're in a forced umount, don't write anything! */
index 9c1243964380223639cdb4127e449816a301716d..22330c9370b6002b7ca9914c0029dde9d99be5d8 100644 (file)
@@ -329,8 +329,8 @@ static void send_cap_msg(struct ceph_mds_client *mdsc, __u64 ino, int op,
        memset(fc, 0, sizeof(*fc));
 
        fc->op = cpu_to_le32(op);
-       fc->seq = cpu_to_le64(seq);
-       fc->migrate_seq = cpu_to_le64(mseq);
+       fc->seq = cpu_to_le32(seq);
+       fc->migrate_seq = cpu_to_le32(mseq);
        fc->caps = cpu_to_le32(caps);
        fc->wanted = cpu_to_le32(wanted);
        fc->ino = cpu_to_le64(ino);
@@ -939,7 +939,7 @@ static int handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
                         */
                        cap->implemented = newcaps;
 
-                       grant->size = le64_to_cpu(inode->i_size);
+                       grant->size = cpu_to_le64(inode->i_size);
                        grant->max_size = 0;  /* don't re-request */
                        ceph_encode_timespec(&grant->mtime, &inode->i_mtime);
                        ceph_encode_timespec(&grant->atime, &inode->i_atime);
@@ -1023,7 +1023,7 @@ static void handle_cap_flushedsnap(struct inode *inode,
                                   struct ceph_mds_session *session)
 {
        struct ceph_inode_info *ci = ceph_inode(inode);
-       u64 follows = le32_to_cpu(m->snap_follows);
+       u64 follows = le64_to_cpu(m->snap_follows);
        struct list_head *p;
        struct ceph_cap_snap *capsnap;
 
index 126ea857daf81a9e0141fcac781a10e07d60aa6b..afec24b082745162d87315b7ea8a2fe070414bbd 100644 (file)
 
 #define ceph_decode_64(p, v)                           \
        do {                                            \
-               v = le64_to_cpu(*(__u64*)*(p));         \
+               v = le64_to_cpu(*(__le64*)*(p));        \
                *(p) += sizeof(__u64);                  \
        } while (0)
 #define ceph_decode_32(p, v)                           \
        do {                                            \
-               v = le32_to_cpu(*(__u32*)*(p));         \
+               v = le32_to_cpu(*(__le32*)*(p));        \
                *(p) += sizeof(__u32);                  \
        } while (0)
 #define ceph_decode_16(p, v)                           \
        do {                                            \
-               v = le16_to_cpu(*(__u16*)*(p));         \
+               v = le16_to_cpu(*(__le16*)*(p));        \
                *(p) += sizeof(__u16);                  \
        } while (0)
 #define ceph_decode_8(p, v)                            \
index 2610ecf7963a9d58adf2b0a76e9df52f169f9cea..cf4e7c0aa0f0ba3d572f596912db4181eee823a0 100644 (file)
@@ -146,7 +146,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
        unsigned skew;
        int err;
        __u32 ftype;
-       struct ceph_mds_reply_info *rinfo;
+       struct ceph_mds_reply_info_parsed *rinfo;
 
 nextfrag:
        dout(5, "readdir filp %p at frag %u off %u\n", filp, frag, off);
@@ -224,7 +224,7 @@ nextfrag:
                     off, off+skew,
                     rinfo->dir_nr, rinfo->dir_dname_len[off+skew],
                     rinfo->dir_dname[off+skew]);
-               ftype = le32_to_cpu(rinfo->dir_in[off+skew].in->mode >> 12);
+               ftype = le32_to_cpu(rinfo->dir_in[off+skew].in->mode) >> 12;
                if (filldir(dirent,
                            rinfo->dir_dname[off+skew],
                            rinfo->dir_dname_len[off+skew],
index 2d5abecdb66a661ce90c68fdd91ea62ee1309f7a..14cc4da572b51c6f2a049c3d7b8a35c4590e9fbc 100644 (file)
@@ -780,7 +780,7 @@ out:
 int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
                    struct ceph_mds_session *session)
 {
-       struct ceph_mds_reply_info *rinfo = &req->r_reply_info;
+       struct ceph_mds_reply_info_parsed *rinfo = &req->r_reply_info;
        int err = 0, mask;
        struct qstr dname;
        struct dentry *dn = sb->s_root;
@@ -876,7 +876,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
 
                /* do we have a dn lease? */
                have_lease = have_icontent ||
-                       (rinfo->trace_dlease[d]->mask & CEPH_LOCK_DN);
+                       (le16_to_cpu(rinfo->trace_dlease[d]->mask) & CEPH_LOCK_DN);
                if (!have_lease)
                        dout(10, "fill_trace  no icontent|dentry lease\n");
 
@@ -1132,7 +1132,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
 int ceph_readdir_prepopulate(struct ceph_mds_request *req)
 {
        struct dentry *parent = req->r_last_dentry;
-       struct ceph_mds_reply_info *rinfo = &req->r_reply_info;
+       struct ceph_mds_reply_info_parsed *rinfo = &req->r_reply_info;
        struct qstr dname;
        struct dentry *dn;
        struct inode *in;
@@ -1155,7 +1155,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req)
                struct ceph_vino vino;
 
                dname.name = rinfo->dir_dname[i];
-               dname.len = le32_to_cpu(rinfo->dir_dname_len[i]);
+               dname.len = rinfo->dir_dname_len[i];
                dname.hash = full_name_hash(dname.name, dname.len);
 
                vino.ino = le64_to_cpu(rinfo->dir_in[i].in->ino);
@@ -1479,9 +1479,9 @@ static int ceph_setattr_time(struct dentry *dentry, struct iattr *attr)
 
        reqh->args.utime.mask = 0;
        if (ia_valid & ATTR_ATIME)
-               reqh->args.utime.mask |= CEPH_UTIME_ATIME;
+               reqh->args.utime.mask |= cpu_to_le32(CEPH_UTIME_ATIME);
        if (ia_valid & ATTR_MTIME)
-               reqh->args.utime.mask |= CEPH_UTIME_MTIME;
+               reqh->args.utime.mask |= cpu_to_le32(CEPH_UTIME_MTIME);
 
        ceph_mdsc_lease_release(mdsc, inode, NULL, CEPH_LOCK_ICONTENT);
        err = ceph_mdsc_do_request(mdsc, req);
index 4812923e38cb570a9eaf10d2ab3cb7cc051fed1a..333577486b49088b1fa1dd07a221c5350ab4e6be 100644 (file)
@@ -65,7 +65,7 @@ bad:
  * sequence.
  */
 static int parse_reply_info_trace(void **p, void *end,
-                                 struct ceph_mds_reply_info *info)
+                                 struct ceph_mds_reply_info_parsed *info)
 {
        __u16 numi, numd, snapdirpos;
        int err;
@@ -152,7 +152,7 @@ out_bad:
  * parse readdir results
  */
 static int parse_reply_info_dir(void **p, void *end,
-                               struct ceph_mds_reply_info *info)
+                               struct ceph_mds_reply_info_parsed *info)
 {
        __u32 num, i = 0;
        int err;
@@ -220,7 +220,7 @@ out_bad:
  * parse entire mds reply
  */
 static int parse_reply_info(struct ceph_msg *msg,
-                           struct ceph_mds_reply_info *info)
+                           struct ceph_mds_reply_info_parsed *info)
 {
        void *p, *end;
        __u32 len;
@@ -260,7 +260,7 @@ out_bad:
        return err;
 }
 
-static void destroy_reply_info(struct ceph_mds_reply_info *info)
+static void destroy_reply_info(struct ceph_mds_reply_info_parsed *info)
 {
        kfree(info->trace_in);
        kfree(info->dir_in);
@@ -1191,7 +1191,7 @@ void ceph_mdsc_handle_reply(struct ceph_mds_client *mdsc, struct ceph_msg *msg)
 {
        struct ceph_mds_request *req;
        struct ceph_mds_reply_head *head = msg->front.iov_base;
-       struct ceph_mds_reply_info *rinfo;
+       struct ceph_mds_reply_info_parsed *rinfo;
        u64 tid;
        int err, result;
        int mds;
index 1b61d90b474f44d192e46abc70aee8a49a603561..29b5311130be38080715265d226a88c0050b0a4a 100644 (file)
@@ -31,7 +31,7 @@ struct ceph_mds_reply_info_in {
  * the referenced inode, through its parents up to the root
  * directory, and directory contents (for readdir results).
  */
-struct ceph_mds_reply_info {
+struct ceph_mds_reply_info_parsed {
        struct ceph_mds_reply_head    *head;
 
        int trace_numi, trace_numd, trace_snapdirpos;
@@ -99,7 +99,11 @@ struct ceph_mds_request {
        __u64             r_tid;      /* transaction id */
        struct ceph_msg  *r_request;  /* original request */
        struct ceph_msg  *r_reply;
+<<<<<<< HEAD:src/kernel/mds_client.h
        struct ceph_mds_reply_info r_reply_info;  /* parsed reply */
+=======
+       struct ceph_mds_reply_info_parsed r_reply_info;
+>>>>>>> kclient: endianity handling fixes:src/kernel/mds_client.h
        int r_err;
        unsigned long r_timeout;  /* optional.  jiffies */
 
index c78eb88d8c33490eb25354fcd9f9161961d373bb..1b0ad6e5dadf50283521cf8d090768498d48271d 100644 (file)
@@ -376,7 +376,7 @@ static unsigned long hash_addr(struct ceph_entity_addr *addr)
 {
        unsigned long key;
        key = *(__u32 *)&addr->ipaddr.sin_addr.s_addr;
-       key ^= addr->ipaddr.sin_port;
+       key ^= *(__u16 *)&addr->ipaddr.sin_port;
        return key;
 }
 
@@ -713,8 +713,8 @@ static int write_partial_msg_pages(struct ceph_connection *con,
                        void *base = kaddr + con->out_msg_pos.page_pos;
 
                        con->out_msg->footer.data_crc =
-                               crc32c_le(con->out_msg->footer.data_crc,
-                                         base, len);
+                               cpu_to_le32(crc32c_le(le32_to_cpu(con->out_msg->footer.data_crc),
+                                         base, len));
                        con->out_msg_pos.did_page_crc = 1;
                }
 
@@ -750,7 +750,7 @@ static int write_partial_msg_pages(struct ceph_connection *con,
 
        /* queue up footer, too */
        if (!crc)
-               con->out_msg->footer.flags |= CEPH_MSG_FOOTER_NOCRC;
+               con->out_msg->footer.flags |= cpu_to_le32(CEPH_MSG_FOOTER_NOCRC);
        con->out_kvec[0].iov_base = &con->out_msg->footer;
        con->out_kvec_bytes = con->out_kvec[0].iov_len =
                sizeof(con->out_msg->footer);
@@ -794,7 +794,7 @@ static void prepare_write_message(struct ceph_connection *con)
 
        /* encode header */
        dout(20, "prepare_write_message %p seq %lld type %d len %d+%d %d pgs\n",
-            m, le64_to_cpu(m->hdr.seq), le32_to_cpu(m->hdr.type),
+            m, le64_to_cpu(m->hdr.seq), le16_to_cpu(m->hdr.type),
             le32_to_cpu(m->hdr.front_len), le32_to_cpu(m->hdr.data_len),
             m->nr_pages);
        BUG_ON(le32_to_cpu(m->hdr.front_len) != m->front.iov_len);
@@ -817,11 +817,11 @@ static void prepare_write_message(struct ceph_connection *con)
        con->out_msg_pos.did_page_crc = 0;
 
        /* fill in crc (except data pages), footer */
-       con->out_msg->hdr.crc = crc32c_le(0, (void *)&m->hdr,
-                                         sizeof(m->hdr) - sizeof(m->hdr.crc));
+       con->out_msg->hdr.crc = cpu_to_le32(crc32c_le(0, (void *)&m->hdr,
+                                         sizeof(m->hdr) - sizeof(m->hdr.crc)));
        con->out_msg->footer.flags = 0;
-       con->out_msg->footer.front_crc = crc32c_le(0, m->front.iov_base,
-                                                  m->front.iov_len);
+       con->out_msg->footer.front_crc = cpu_to_le32(crc32c_le(0, m->front.iov_base,
+                                                  m->front.iov_len));
        con->out_msg->footer.data_crc = 0;
 
        set_bit(WRITE_PENDING, &con->state);
@@ -948,7 +948,7 @@ static void prepare_write_accept_ready(struct ceph_connection *con)
 }
 
 static void prepare_write_accept_retry(struct ceph_connection *con, char *ptag,
-                                      u32 *pseq)
+                                      __le32 *pseq)
 {
        con->out_kvec[0].iov_base = ptag;
        con->out_kvec[0].iov_len = 1;
@@ -1095,7 +1095,7 @@ static int read_message_partial(struct ceph_connection *con)
                if (con->in_base_pos == sizeof(m->hdr)) {
                        u32 crc = crc32c_le(0, (void *)&m->hdr,
                                    sizeof(m->hdr) - sizeof(m->hdr.crc));
-                       if (crc != m->hdr.crc) {
+                       if (crc != le32_to_cpu(m->hdr.crc)) {
                                derr(0, "read_message_partial %p bad hdr crc"
                                     " %u != expected %u\n",
                                     m, crc, m->hdr.crc);
@@ -1196,13 +1196,13 @@ no_data:
        dout(20, "read_message_partial got msg %p\n", m);
 
        /* crc ok? */
-       if (con->in_front_crc != m->footer.front_crc) {
+       if (con->in_front_crc != le32_to_cpu(m->footer.front_crc)) {
                derr(0, "read_message_partial %p front crc %u != expected %u\n",
                     con->in_msg,
                     con->in_front_crc, m->footer.front_crc);
                return -EIO;
        }
-       if (con->in_data_crc != m->footer.data_crc) {
+       if (con->in_data_crc != le32_to_cpu(m->footer.data_crc)) {
                derr(0, "read_message_partial %p data crc %u != expected %u\n",
                     con->in_msg,
                     con->in_data_crc, m->footer.data_crc);
@@ -1236,10 +1236,10 @@ static void process_message(struct ceph_connection *con)
        spin_unlock(&con->out_queue_lock);
 
        dout(1, "===== %p %u from %s%d %d=%s len %d+%d (%u %u) =====\n",
-            con->in_msg, le32_to_cpu(con->in_msg->hdr.seq),
+            con->in_msg, le64_to_cpu(con->in_msg->hdr.seq),
             ENTITY_NAME(con->in_msg->hdr.src.name),
-            le32_to_cpu(con->in_msg->hdr.type),
-            ceph_msg_type_name(le32_to_cpu(con->in_msg->hdr.type)),
+            le16_to_cpu(con->in_msg->hdr.type),
+            ceph_msg_type_name(le16_to_cpu(con->in_msg->hdr.type)),
             le32_to_cpu(con->in_msg->hdr.front_len),
             le32_to_cpu(con->in_msg->hdr.data_len),
             con->in_front_crc, con->in_data_crc);
@@ -1286,7 +1286,7 @@ static void process_ack(struct ceph_connection *con)
                if (seq > ack)
                        break;
                dout(5, "got ack for seq %llu type %d at %p\n", seq,
-                    le32_to_cpu(m->hdr.type), m);
+                    le16_to_cpu(m->hdr.type), m);
                list_del_init(&m->list_head);
                ceph_msg_put(m);
        }
@@ -1993,7 +1993,7 @@ struct ceph_msg *ceph_msg_maybe_dup(struct ceph_msg *old)
        if (atomic_read(&old->nref) == 1)
                return old;  /* we have only ref, all is well */
 
-       dup = ceph_msg_new(le32_to_cpu(old->hdr.type),
+       dup = ceph_msg_new(le16_to_cpu(old->hdr.type),
                           le32_to_cpu(old->hdr.front_len),
                           le32_to_cpu(old->hdr.data_len),
                           le32_to_cpu(old->hdr.data_off),
@@ -2005,7 +2005,7 @@ struct ceph_msg *ceph_msg_maybe_dup(struct ceph_msg *old)
        /* revoke old message's pages */
        mutex_lock(&old->page_mutex);
        old->pages = NULL;
-       old->footer.flags |= CEPH_MSG_FOOTER_ABORTED;
+       old->footer.flags |= cpu_to_le32(CEPH_MSG_FOOTER_ABORTED);
        mutex_unlock(&old->page_mutex);
 
        ceph_msg_put(old);
@@ -2081,10 +2081,10 @@ int ceph_msg_send(struct ceph_messenger *msgr, struct ceph_msg *msg,
 
        /* queue */
        spin_lock(&con->out_queue_lock);
-       if (unlikely(msg->hdr.type == CEPH_MSG_PING &&
+       if (unlikely(le16_to_cpu(msg->hdr.type) == CEPH_MSG_PING &&
                     !list_empty(&con->out_queue) &&
-                    list_entry(con->out_queue.prev, struct ceph_msg,
-                               list_head)->hdr.type == CEPH_MSG_PING)) {
+                    le16_to_cpu(list_entry(con->out_queue.prev, struct ceph_msg,
+                               list_head)->hdr.type) == CEPH_MSG_PING)) {
                /* don't queue multiple pings in a row */
                dout(2, "ceph_msg_send dropping dup ping\n");
                ceph_msg_put(msg);
@@ -2092,8 +2092,8 @@ int ceph_msg_send(struct ceph_messenger *msgr, struct ceph_msg *msg,
                msg->hdr.seq = cpu_to_le64(++con->out_seq);
                dout(1, "----- %p %u to %s%d %d=%s len %d+%d -----\n", msg,
                     (unsigned)con->out_seq,
-                    ENTITY_NAME(msg->hdr.dst.name), le32_to_cpu(msg->hdr.type),
-                    ceph_msg_type_name(le32_to_cpu(msg->hdr.type)),
+                    ENTITY_NAME(msg->hdr.dst.name), le16_to_cpu(msg->hdr.type),
+                    ceph_msg_type_name(le16_to_cpu(msg->hdr.type)),
                     le32_to_cpu(msg->hdr.front_len),
                     le32_to_cpu(msg->hdr.data_len));
                dout(2, "ceph_msg_send %p seq %llu for %s%d on %p pgs %d\n",
@@ -2128,7 +2128,7 @@ struct ceph_msg *ceph_msg_new(int type, int front_len,
        mutex_init(&m->page_mutex);
        INIT_LIST_HEAD(&m->list_head);
 
-       m->hdr.type = cpu_to_le32(type);
+       m->hdr.type = cpu_to_le16(type);
        m->hdr.front_len = cpu_to_le32(front_len);
        m->hdr.data_len = cpu_to_le32(page_len);
        m->hdr.data_off = cpu_to_le32(page_off);
@@ -2168,10 +2168,10 @@ void ceph_msg_put(struct ceph_msg *m)
             atomic_read(&m->nref)-1);
        if (atomic_read(&m->nref) <= 0) {
                derr(0, "bad ceph_msg_put on %p %u from %s%d %d=%s len %d+%d\n",
-                    m, le32_to_cpu(m->hdr.seq),
+                    m, le64_to_cpu(m->hdr.seq),
                     ENTITY_NAME(m->hdr.src.name),
-                    le32_to_cpu(m->hdr.type),
-                    ceph_msg_type_name(le32_to_cpu(m->hdr.type)),
+                    le16_to_cpu(m->hdr.type),
+                    ceph_msg_type_name(le16_to_cpu(m->hdr.type)),
                     le32_to_cpu(m->hdr.front_len),
                     le32_to_cpu(m->hdr.data_len));
                WARN_ON(1);
index c5fdb739184aaca3b0a9a698e3e782088d97c32b..0d77ad6cda611f02770e66f0efef268b3db3c55b 100644 (file)
@@ -136,7 +136,7 @@ struct ceph_connection {
        char in_tag;
        u8 in_flags;
        int in_base_pos;   /* for ack seq, or msg headers, or handshake */
-       __u32 in_partial_ack;
+       __le32 in_partial_ack;
        struct ceph_msg *in_msg;
        struct ceph_msg_pos in_msg_pos;
        u32 in_front_crc, in_data_crc;
index a6776f89175ed0059d66e49910d45ec8aacae883..2aab2414b9bab3feb5775fdf9424422cd7dc6d08 100644 (file)
@@ -172,7 +172,7 @@ static void rebuild_snap_realms(struct ceph_snap_realm *realm)
 }
 
 
-static int dup_array(u64 **dst, u64 *src, int num)
+static int dup_array(u64 **dst, __le64 *src, int num)
 {
        int i;
 
@@ -258,8 +258,8 @@ struct ceph_snap_realm *ceph_update_snap_trace(struct ceph_mds_client *mdsc,
 {
        struct ceph_mds_snap_realm *ri;
        int err = -ENOMEM;
-       u64 *snaps;
-       u64 *prior_parent_snaps;
+       __le64 *snaps;
+       __le64 *prior_parent_snaps;
        struct ceph_snap_realm *realm, *first = NULL;
        int invalidate = 0;
 
index 53603819ecbd11bb54d3bc1c1cb98f484c07d1fe..53d36bfa173f489b3ca71b817a0d9af282a203eb 100644 (file)
@@ -55,10 +55,10 @@ extern int ceph_debug_mask;
 #define CEPH_BLOCK  (1 << CEPH_BLOCK_SHIFT)
 
 #define IPQUADPORT(n)                                                  \
-       (unsigned int)(((n).sin_addr.s_addr)) & 0xFF,                   \
-               (unsigned int)(((n).sin_addr.s_addr)>>8) & 0xFF,        \
-               (unsigned int)(((n).sin_addr.s_addr)>>16) & 0xFF,       \
-               (unsigned int)(((n).sin_addr.s_addr)>>24) & 0xFF,       \
+       (unsigned int)((be32_to_cpu((n).sin_addr.s_addr) >> 24)) & 0xFF,                        \
+               (unsigned int)((be32_to_cpu((n).sin_addr.s_addr)) >> 16) & 0xFF,        \
+               (unsigned int)((be32_to_cpu((n).sin_addr.s_addr))>>8) & 0xFF,   \
+               (unsigned int)((be32_to_cpu((n).sin_addr.s_addr))) & 0xFF,      \
                (unsigned int)(ntohs((n).sin_port))