]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: update for ceph_fsid_t
authorYehuda Sadeh <yehuda@hq.newdream.net>
Wed, 31 Dec 2008 00:18:01 +0000 (16:18 -0800)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Wed, 31 Dec 2008 00:18:01 +0000 (16:18 -0800)
src/include/ceph_fs.h
src/kernel/mds_client.c
src/kernel/mon_client.c
src/kernel/mon_client.h
src/kernel/osd_client.c
src/kernel/osdmap.c
src/kernel/osdmap.h
src/kernel/super.c
src/kernel/super.h

index fc7c8dc755c835fd4d847c7d42023c6acd2f0004..7d19ffbac4d6e24a97081f54be4e114caa083b7b 100644 (file)
@@ -61,7 +61,6 @@ typedef __le64 ceph_version_t;
 typedef __le64 ceph_tid_t;      /* transaction id */
 typedef __le32 ceph_epoch_t;
 
-
 /*
  * fs id
  */
index 18de0462fe08116a65d80953096b86fa4c37268c..3c4863e61732bd3cab27a29bb5fca2214d0b13e2 100644 (file)
@@ -2193,9 +2193,10 @@ void ceph_mdsc_handle_map(struct ceph_mds_client *mdsc, struct ceph_msg *msg)
        void *p = msg->front.iov_base;
        void *end = p + msg->front.iov_len;
        struct ceph_mdsmap *newmap, *oldmap;
-       struct ceph_fsid fsid;
+       ceph_fsid_t fsid;
        int err = -EINVAL;
        int from;
+       __le64 major, minor;
 
        if (le32_to_cpu(msg->hdr.src.name.type) == CEPH_ENTITY_TYPE_MDS)
                from = le32_to_cpu(msg->hdr.src.name.num);
@@ -2203,9 +2204,11 @@ void ceph_mdsc_handle_map(struct ceph_mds_client *mdsc, struct ceph_msg *msg)
                from = -1;
 
        ceph_decode_need(&p, end, sizeof(fsid)+2*sizeof(u32), bad);
-       ceph_decode_64_le(&p, fsid.major);
-       ceph_decode_64_le(&p, fsid.minor);
-       if (!ceph_fsid_equal(&fsid, &mdsc->client->monc.monmap->fsid)) {
+       ceph_decode_64_le(&p, major);
+       __ceph_fsid_set_major(&fsid, major);
+       ceph_decode_64_le(&p, minor);
+       __ceph_fsid_set_minor(&fsid, minor);
+       if (ceph_fsid_compare(&fsid, &mdsc->client->monc.monmap->fsid)) {
                derr(0, "got mdsmap with wrong fsid\n");
                return;
        }
index de255f0c944a6db84dc63b8e4c8998153ba79bba..01502ff73490180cb8573f4878e83ec2f558680c 100644 (file)
@@ -19,6 +19,7 @@ struct ceph_monmap *ceph_monmap_decode(void *p, void *end)
 {
        struct ceph_monmap *m;
        int i, err = -EINVAL;
+       __le64 major, minor;
 
        dout(30, "monmap_decode %p %p len %d\n", p, end, (int)(end-p));
 
@@ -28,8 +29,10 @@ struct ceph_monmap *ceph_monmap_decode(void *p, void *end)
                return ERR_PTR(-ENOMEM);
 
        ceph_decode_need(&p, end, 2*sizeof(u32) + 2*sizeof(u64), bad);
-       ceph_decode_64_le(&p, m->fsid.major);
-       ceph_decode_64_le(&p, m->fsid.minor);
+       ceph_decode_64_le(&p, major);
+       __ceph_fsid_set_major(&m->fsid, major);
+       ceph_decode_64_le(&p, minor);
+       __ceph_fsid_set_minor(&m->fsid, minor);
        ceph_decode_32(&p, m->epoch);
        ceph_decode_32(&p, m->num_mon);
        ceph_decode_need(&p, end, m->num_mon*sizeof(m->mon_inst[0]), bad);
index 9ca6880384915b981fbc31f2f3f5f20c1db17bef..5b05b243523526213bb3c52b17265885e0722912 100644 (file)
@@ -29,7 +29,7 @@ struct ceph_mount_args;
  * ceph_monmap_decode().
  */
 struct ceph_monmap {
-       struct ceph_fsid fsid;
+       ceph_fsid_t fsid;
        u32 epoch;
        u32 num_mon;
        struct ceph_entity_inst mon_inst[0];
index 6beb88855eb573f640dd3a85cae0de23915b1e89..1df4d18896e5565a16cfda949c53add3dd6ffb2c 100644 (file)
@@ -442,7 +442,8 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg)
        u32 epoch;
        struct ceph_osdmap *newmap = NULL, *oldmap;
        int err;
-       struct ceph_fsid fsid;
+       ceph_fsid_t fsid;
+       __le64 major, minor;
 
        dout(2, "handle_map have %u\n", osdc->osdmap ? osdc->osdmap->epoch : 0);
        p = msg->front.iov_base;
@@ -450,9 +451,11 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg)
 
        /* verify fsid */
        ceph_decode_need(&p, end, sizeof(fsid), bad);
-       ceph_decode_64_le(&p, fsid.major);
-       ceph_decode_64_le(&p, fsid.minor);
-       if (!ceph_fsid_equal(&fsid, &osdc->client->monc.monmap->fsid)) {
+       ceph_decode_64_le(&p, major);
+       __ceph_fsid_set_major(&fsid, major);
+       ceph_decode_64_le(&p, minor);
+       __ceph_fsid_set_minor(&fsid, minor);
+       if (ceph_fsid_compare(&fsid, &osdc->client->monc.monmap->fsid)) {
                derr(0, "got map with wrong fsid, ignoring\n");
                return;
        }
index e41b9222d487462965759908484ab0d3295385dd..659e4d54430c9aa51d88c9710b9a74ce0b0717e0 100644 (file)
@@ -341,6 +341,7 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end)
        u32 len, max, i;
        int err = -EINVAL;
        void *start = *p;
+       __le64 major, minor;
 
        dout(30, "osdmap_decode %p to %p len %d\n", *p, end, (int)(end - *p));
 
@@ -349,8 +350,10 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end)
                return ERR_PTR(-ENOMEM);
 
        ceph_decode_need(p, end, 2*sizeof(u64)+11*sizeof(u32), bad);
-       ceph_decode_64_le(p, map->fsid.major);
-       ceph_decode_64_le(p, map->fsid.minor);
+       ceph_decode_64_le(p, major);
+       __ceph_fsid_set_major(&map->fsid, major);
+       ceph_decode_64_le(p, minor);
+       __ceph_fsid_set_minor(&map->fsid, minor);
        ceph_decode_32(p, map->epoch);
        ceph_decode_32_le(p, map->ctime.tv_sec);
        ceph_decode_32_le(p, map->ctime.tv_nsec);
@@ -422,18 +425,21 @@ struct ceph_osdmap *apply_incremental(void **p, void *end,
 {
        struct ceph_osdmap *newmap = map;
        struct crush_map *newcrush = NULL;
-       struct ceph_fsid fsid;
+       ceph_fsid_t fsid;
        u32 epoch = 0;
        struct ceph_timespec ctime;
        u32 len, x;
        __s32 new_flags, max;
        void *start = *p;
        int err = -EINVAL;
+       __le64 major, minor;
 
        ceph_decode_need(p, end, sizeof(fsid)+sizeof(ctime)+2*sizeof(u32),
                         bad);
-       ceph_decode_64_le(p, fsid.major);
-       ceph_decode_64_le(p, fsid.minor);
+       ceph_decode_64_le(p, major);
+       __ceph_fsid_set_major(&fsid, major);
+       ceph_decode_64_le(p, minor);
+       __ceph_fsid_set_minor(&fsid, minor);
        ceph_decode_32(p, epoch);
        BUG_ON(epoch != map->epoch+1);
        ceph_decode_32_le(p, ctime.tv_sec);
index 000550b624ee9d8f34c9b81c115345599c9f55b9..db97ca7d91da68762c67fd3f032d4fdc8de040d4 100644 (file)
@@ -2,6 +2,7 @@
 #define _FS_CEPH_OSDMAP_H
 
 #include "types.h"
+#include "ceph_fs.h"
 #include "crush/crush.h"
 
 /*
@@ -17,7 +18,7 @@
  * the change between two successive epochs, or as a fully encoded map.
  */
 struct ceph_osdmap {
-       struct ceph_fsid fsid;
+       ceph_fsid_t fsid;
        u32 epoch;
        u32 mkfs_epoch;
        struct ceph_timespec ctime, mtime;
index 3b77aba69e9b870a17497a44a4a3c6a384e035a3..e7c20db2dd05aa6ec5b0b8122d9d1b652ae61189 100644 (file)
@@ -105,7 +105,7 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
        buf->f_frsize = PAGE_CACHE_SIZE;
 
        /* leave in little-endian, regardless of host endianness */
-       fsid = monmap->fsid.major ^ monmap->fsid.minor;
+       fsid = __ceph_fsid_major(&monmap->fsid) ^ __ceph_fsid_minor(&monmap->fsid);
        buf->f_fsid.val[0] = le64_to_cpu(fsid) & 0xffffffff;
        buf->f_fsid.val[1] = le64_to_cpu(fsid) >> 32;
 
@@ -134,7 +134,7 @@ static int ceph_show_options(struct seq_file *m, struct vfsmount *mnt)
                seq_printf(m, ",debug=%d", ceph_debug);
        if (args->flags & CEPH_MOUNT_FSID)
                seq_printf(m, ",fsidmajor=%llu,fsidminor%llu",
-                          args->fsid.major, args->fsid.minor);
+                          __ceph_fsid_major(&args->fsid), __ceph_fsid_minor(&args->fsid));
        if (args->flags & CEPH_MOUNT_NOSHARE)
                seq_puts(m, ",noshare");
        if (args->flags & CEPH_MOUNT_UNSAFE_WRITEBACK)
@@ -252,8 +252,8 @@ static void handle_monmap(struct ceph_client *client, struct ceph_msg *msg)
                client->msgr->inst.name = msg->hdr.dst.name;
                sprintf(name, "client%d", client->whoami);
                dout(1, "i am %s, fsid is %llx.%llx\n", name,
-                    le64_to_cpu(client->monc.monmap->fsid.major),
-                    le64_to_cpu(client->monc.monmap->fsid.minor));
+                    le64_to_cpu(__ceph_fsid_major(&client->monc.monmap->fsid)),
+                    le64_to_cpu(__ceph_fsid_minor(&client->monc.monmap->fsid)));
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
                client->client_kobj = kobject_create_and_add(name, ceph_kobj);
@@ -523,10 +523,10 @@ static int parse_mount_args(int flags, char *options, const char *dev_name,
                }
                switch (token) {
                case Opt_fsidmajor:
-                       args->fsid.major = cpu_to_le64(intval);
+                       __ceph_fsid_set_major(&args->fsid, cpu_to_le64(intval));
                        break;
                case Opt_fsidminor:
-                       args->fsid.minor = cpu_to_le64(intval);
+                       __ceph_fsid_set_minor(&args->fsid, cpu_to_le64(intval));
                        break;
                case Opt_port:
                        args->my_addr.ipaddr.sin_port = htons(intval);
@@ -953,7 +953,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
 
        /* either compare fsid, or specified mon_hostname */
        if (args->flags & CEPH_MOUNT_FSID) {
-               if (!ceph_fsid_equal(&args->fsid, &other->fsid)) {
+               if (ceph_fsid_compare(&args->fsid, &other->fsid)) {
                        dout(30, "fsid doesn't match\n");
                        return 0;
                }
index 3bc96959d6248ef848beb6675f82cd379bc71cf4..78b7ce00ebc13d435076e446d7e76ee68c2d4d58 100644 (file)
@@ -16,6 +16,7 @@
 #include "mon_client.h"
 #include "mds_client.h"
 #include "osd_client.h"
+#include "ceph_fs.h"
 
 /* f_type in struct statfs */
 #define CEPH_SUPER_MAGIC 0x00c36400
@@ -57,7 +58,7 @@ struct ceph_mount_args {
        int sb_flags;
        int flags;
        int mount_timeout;
-       struct ceph_fsid fsid;
+       ceph_fsid_t fsid;
        struct ceph_entity_addr my_addr;
        int num_mon;
        struct ceph_entity_addr mon_addr[MAX_MON_MOUNT_ADDR];
@@ -89,7 +90,7 @@ struct ceph_client {
 
        struct mutex mount_mutex;       /* serialize mount attempts */
        struct ceph_mount_args mount_args;
-       struct ceph_fsid fsid;
+       ceph_fsid_t fsid;
 
        struct super_block *sb;
 
@@ -573,6 +574,26 @@ static inline bool __ceph_have_pending_cap_snap(struct ceph_inode_info *ci)
 /* super.c */
 extern const char *ceph_msg_type_name(int type);
 
+static inline __le64 __ceph_fsid_minor(ceph_fsid_t *fsid)
+{
+       return *(__le64 *)&fsid->fsid[8];
+}
+
+static inline __le64 __ceph_fsid_major(ceph_fsid_t *fsid)
+{
+       return *(__le64 *)&fsid->fsid[0];
+}
+
+static inline void __ceph_fsid_set_minor(ceph_fsid_t *fsid, __le64 val)
+{
+       *(__le64 *)&fsid->fsid[8] = val;
+}
+
+static inline void __ceph_fsid_set_major(ceph_fsid_t *fsid, __le64 val)
+{
+       *(__le64 *)&fsid->fsid[0] = val;
+}
+
 /* inode.c */
 extern const struct inode_operations ceph_file_iops;
 extern struct kmem_cache *ceph_inode_cachep;