]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: more fixes from akpm's review
authorSage Weil <sage@newdream.net>
Wed, 30 Sep 2009 18:01:37 +0000 (11:01 -0700)
committerSage Weil <sage@newdream.net>
Wed, 30 Sep 2009 18:01:37 +0000 (11:01 -0700)
src/TODO
src/include/ceph_fs.cc
src/include/msgr.h
src/include/rados.h
src/kernel/Makefile
src/kernel/buffer.c [new file with mode: 0644]
src/kernel/buffer.h
src/kernel/osdmap.h

index eb7a86f6c8dd0128a6634a600a4dc6b5bde76954..d7f1e8c1284bea7cdefdaf444a090b609cbdcc8f 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -23,7 +23,10 @@ v0.16
 
 /- uninline frags
 /- uninline string hash
-
+- document data structures
+- audit all inline in kclient
+- document on-wire protocol
+- ceph_buffer fixes
 
 bugs
 - mislinked directory?
index fc615ba076dfe863eea1af13d72d8b4bf171cba6..e228496bfea94c0b76b48f2f39980a2d39c6e232 100644 (file)
@@ -65,7 +65,7 @@ static unsigned long ceph_partial_name_hash(unsigned long c, unsigned long prevh
  */
 static unsigned long ceph_end_name_hash(unsigned long hash)
 {
-       return (unsigned int) hash;
+       return hash & 0xffffffff;
 }
 
 /* Compute the hash for a name string. */
index 968b4ba0849f87b4f6fd0fc880a44e5c43cba483..541e5bc0dc29113844b61bbbc50e9dbfaae9b992 100644 (file)
@@ -21,7 +21,7 @@
  * whenever the wire protocol changes.  try to keep this string length
  * constant.
  */
-#define CEPH_BANNER "ceph v019"
+#define CEPH_BANNER "ceph v020"
 #define CEPH_BANNER_MAX_LEN 30
 
 
@@ -90,10 +90,10 @@ struct ceph_entity_inst {
 #define CEPH_MSGR_TAG_RETRY_GLOBAL  5  /* server->client + gseq: try again
                                          with higher gseq */
 #define CEPH_MSGR_TAG_CLOSE         6  /* closing pipe */
-#define CEPH_MSGR_TAG_MSG          10  /* message */
-#define CEPH_MSGR_TAG_ACK          11  /* message ack */
-#define CEPH_MSGR_TAG_KEEPALIVE    12  /* just a keepalive byte! */
-#define CEPH_MSGR_TAG_BADPROTOVER  13  /* bad protocol version */
+#define CEPH_MSGR_TAG_MSG           7  /* message */
+#define CEPH_MSGR_TAG_ACK           8  /* message ack */
+#define CEPH_MSGR_TAG_KEEPALIVE     9  /* just a keepalive byte! */
+#define CEPH_MSGR_TAG_BADPROTOVER  10  /* bad protocol version */
 
 
 /*
index ab3e698472f18bb2fa0a141b53f4ee42aa53cdf3..d7ab9dd863dd6212dfdb2f85d50fe341180dc223 100644 (file)
@@ -2,8 +2,8 @@
 #define __RADOS_H
 
 /*
- * Data types for RADOS, the distributed object storage layer used by
- * the Ceph file system.
+ * Data types for the Ceph distributed object storage layer RADOS
+ * (Reliable Autonomic Distributed Object Store).
  */
 
 #include "msgr.h"
@@ -55,20 +55,15 @@ struct ceph_timespec {
  * placement group.
  * we encode this into one __le64.
  */
-#define CEPH_PG_TYPE_REP     1
-#define CEPH_PG_TYPE_RAID4   2
 union ceph_pg {
        __u64 pg64;
        struct {
                __s16 preferred; /* preferred primary osd */
                __u16 ps;        /* placement seed */
                __u32 pool;      /* implies crush ruleset */
-       } pg;
+       } __attribute__ ((packed)) pg;
 } __attribute__ ((packed));
 
-#define ceph_pg_is_rep(pg)   ((pg).pg.type == CEPH_PG_TYPE_REP)
-#define ceph_pg_is_raid4(pg) ((pg).pg.type == CEPH_PG_TYPE_RAID4)
-
 /*
  * pg_pool is a set of pgs storing a pool of objects
  *
@@ -86,6 +81,8 @@ union ceph_pg {
  *
  *  lpgp_num -- as above.
  */
+#define CEPH_PG_TYPE_REP     1
+#define CEPH_PG_TYPE_RAID4   2
 struct ceph_pg_pool {
        __u8 type;
        __u8 size;
index d7493d61614dd449f43758b74e9e8d2c6bba1440..7da6d69dba29c2e163f2c92c985b83d78c1b7a8d 100644 (file)
@@ -8,7 +8,7 @@ obj-$(CONFIG_CEPH_FS) += ceph.o
 
 ceph-objs := super.o inode.o dir.o file.o addr.o ioctl.o \
        export.o caps.o snap.o xattr.o \
-       messenger.o msgpool.o \
+       messenger.o msgpool.o buffer.o \
        mds_client.o mdsmap.o \
        mon_client.o \
        osd_client.o osdmap.o crush/crush.o crush/mapper.o \
diff --git a/src/kernel/buffer.c b/src/kernel/buffer.c
new file mode 100644 (file)
index 0000000..635e7df
--- /dev/null
@@ -0,0 +1,34 @@
+
+#include "ceph_debug.h"
+#include "buffer.h"
+
+struct ceph_buffer *ceph_buffer_new(gfp_t gfp)
+{
+       struct ceph_buffer *b;
+
+       b = kmalloc(sizeof(*b), gfp);
+       if (!b)
+               return NULL;
+       atomic_set(&b->nref, 1);
+       b->vec.iov_base = NULL;
+       b->vec.iov_len = 0;
+       b->alloc_len = 0;
+       return b;
+}
+
+int ceph_buffer_alloc(struct ceph_buffer *b, int len, gfp_t gfp)
+{
+       if (len <= PAGE_SIZE) {
+               b->vec.iov_base = kmalloc(len, gfp);
+               b->is_vmalloc = false;
+       } else {
+               b->vec.iov_base = __vmalloc(len, gfp, PAGE_KERNEL);
+               b->is_vmalloc = true;
+       }
+       if (!b->vec.iov_base)
+               return -ENOMEM;
+       b->alloc_len = len;
+       b->vec.iov_len = len;
+       return 0;
+}
+
index 128593d3bc9aeb4dc0563a5afc73379e682617f3..bbedaf47ab9e537238fb89a0de5e25161428699e 100644 (file)
@@ -2,10 +2,9 @@
 #define __FS_CEPH_BUFFER_H
 
 #include <linux/mm.h>
-#include <linux/types.h>
 #include <linux/vmalloc.h>
-
-#include "ceph_debug.h"
+#include <linux/types.h>
+#include <linux/uio.h>
 
 /*
  * a simple reference counted buffer.
@@ -20,35 +19,8 @@ struct ceph_buffer {
        bool is_vmalloc;
 };
 
-static inline struct ceph_buffer *ceph_buffer_new(gfp_t gfp)
-{
-       struct ceph_buffer *b;
-
-       b = kmalloc(sizeof(*b), gfp);
-       if (!b)
-               return NULL;
-       atomic_set(&b->nref, 1);
-       b->vec.iov_base = NULL;
-       b->vec.iov_len = 0;
-       b->alloc_len = 0;
-       return b;
-}
-
-static inline int ceph_buffer_alloc(struct ceph_buffer *b, int len, gfp_t gfp)
-{
-       if (len <= PAGE_SIZE) {
-               b->vec.iov_base = kmalloc(len, gfp);
-               b->is_vmalloc = false;
-       } else {
-               b->vec.iov_base = __vmalloc(len, gfp, PAGE_KERNEL);
-               b->is_vmalloc = true;
-       }
-       if (!b->vec.iov_base)
-               return -ENOMEM;
-       b->alloc_len = len;
-       b->vec.iov_len = len;
-       return 0;
-}
+struct ceph_buffer *ceph_buffer_new(gfp_t gfp);
+int ceph_buffer_alloc(struct ceph_buffer *b, int len, gfp_t gfp);
 
 static inline struct ceph_buffer *ceph_buffer_get(struct ceph_buffer *b)
 {
@@ -71,13 +43,13 @@ static inline void ceph_buffer_put(struct ceph_buffer *b)
 
 static inline struct ceph_buffer *ceph_buffer_new_alloc(int len, gfp_t gfp)
 {
-       struct ceph_buffer *b = ceph_buffer_new(gfp);
+       struct ceph_buffer *b = ceph_buffer_new(gfp);
 
-       if (b && ceph_buffer_alloc(b, len, gfp) < 0) {
-               ceph_buffer_put(b);
-               b = NULL;
-       }
-       return b;
+       if (b && ceph_buffer_alloc(b, len, gfp) < 0) {
+               ceph_buffer_put(b);
+               b = NULL;
+       }
+       return b;
 }
 
 #endif
index cdf6f1aecf0a98c11478ffa2b90eb9513198ca20..07127c6fb134c3980b5f32f7f242fe73b0240c16 100644 (file)
@@ -53,7 +53,9 @@ struct ceph_osdmap {
        struct crush_map *crush;
 };
 
-/* file layout helpers */
+/*
+ * file layout helpers
+ */
 #define ceph_file_layout_su(l) ((__s32)le32_to_cpu((l).fl_stripe_unit))
 #define ceph_file_layout_stripe_count(l) \
        ((__s32)le32_to_cpu((l).fl_stripe_count))
@@ -66,12 +68,19 @@ struct ceph_osdmap {
 #define ceph_file_layout_pg_pool(l) \
        ((__s32)le32_to_cpu((l).fl_pg_pool))
 
-#define ceph_file_layout_stripe_width(l) (le32_to_cpu((l).fl_stripe_unit) * \
-                                         le32_to_cpu((l).fl_stripe_count))
+static inline unsigned ceph_file_layout_stripe_width(struct ceph_file_layout *l)
+{
+       return le32_to_cpu(l->fl_stripe_unit) *
+               le32_to_cpu(l->fl_stripe_count);
+}
 
 /* "period" == bytes before i start on a new set of objects */
-#define ceph_file_layout_period(l) (le32_to_cpu((l).fl_object_size) *  \
-                                   le32_to_cpu((l).fl_stripe_count))
+static inline unsigned ceph_file_layout_period(struct ceph_file_layout *l)
+{
+       return le32_to_cpu(l->fl_object_size) *
+               le32_to_cpu(l->fl_stripe_count);
+}
+
 
 static inline int ceph_osd_is_up(struct ceph_osdmap *map, int osd)
 {