]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
uninline some header types
authorSage Weil <sage@newdream.net>
Wed, 30 Sep 2009 17:24:28 +0000 (10:24 -0700)
committerSage Weil <sage@newdream.net>
Wed, 30 Sep 2009 17:24:28 +0000 (10:24 -0700)
23 files changed:
src/Makefile.am
src/TODO
src/client/Client.cc
src/include/ceph_frag.cc [new file with mode: 0644]
src/include/ceph_frag.h [new file with mode: 0644]
src/include/ceph_fs.cc [new file with mode: 0644]
src/include/ceph_fs.h
src/include/frag.h
src/include/types.h
src/kernel/Makefile
src/kernel/ceph_frag.c [new symlink]
src/kernel/ceph_frag.h [new symlink]
src/kernel/ceph_fs.c [new symlink]
src/kernel/inode.c
src/kernel/osdmap.c
src/kernel/osdmap.h
src/kernel/super.h
src/kernel/types.h
src/mds/mdstypes.h
src/osd/OSDMap.h
src/osdc/Filer.cc
src/osdc/Journaler.cc
src/osdc/Journaler.h

index bdf10bbd96b3570039d6b8c0ada6249d6ae8744b..832b71a3c9153d712b2a06f69b815189cb9ef1f5 100644 (file)
@@ -301,7 +301,9 @@ libcommon_files = \
        common/common_init.cc \
        common/buffer.cc \
        common/debug.cc \
+       include/ceph_fs.cc \
        include/ceph_strings.cc \
+       include/ceph_frag.cc \
        config.cc \
        common/lockdep.cc
 
@@ -433,6 +435,7 @@ noinst_HEADERS = \
         include/blobhash.h\
         include/buffer.h\
         include/byteorder.h\
+       include/ceph_frag.h\
         include/ceph_fs.h\
        include/color.h\
        include/crc32c.h\
@@ -467,7 +470,11 @@ noinst_HEADERS = \
        kernel/buffer.h\
        kernel/caps.c\
        kernel/ceph_debug.h\
+       kernel/ceph_frag.c\
+       kernel/ceph_frag.h\
+       kernel/ceph_fs.c\
        kernel/ceph_fs.h\
+       kernel/ceph_strings.c\
        kernel/ceph_ver.h\
         kernel/crush/crush.c\
         kernel/crush/crush.h\
index b3606a969ec912522a408bf1a0d96b114a41adb0..eb7a86f6c8dd0128a6634a600a4dc6b5bde76954 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -20,6 +20,11 @@ v0.16
 - kclient: retry alloc on ENOMEM when reading from connection?
 - client authentication
 
+
+/- uninline frags
+/- uninline string hash
+
+
 bugs
 - mislinked directory?
 - premature filejournal trimming?
index 2986a037aa8f43af715b8de24bb02db8f1758fc9..07202eb6460320d723bb319ff4dca5303b6382e3 100644 (file)
@@ -3505,7 +3505,7 @@ int Client::fill_stat(Inode *in, struct stat *st, frag_info_t *dirstat, nest_inf
     st->st_size = in->size;
     st->st_blocks = (in->size + 511) >> 9;
   }
-  st->st_blksize = MAX(ceph_file_layout_su(in->layout), 4096);
+  st->st_blksize = MAX(in->layout.fl_object_stripe_unit, 4096);
 
   if (dirstat)
     *dirstat = in->dirstat;
@@ -3566,7 +3566,7 @@ int Client::fill_stat_precise(Inode *in, struct stat_precise *st, frag_info_t *d
     st->st_size = in->size;
     st->st_blocks = (in->size + 511) >> 9;
   }
-  st->st_blksize = MAX(ceph_file_layout_su(in->layout), 4096);
+  st->st_blksize = MAX(in->layout.fl_object_stripe_unit, 4096);
 
   if (dirstat)
     *dirstat = in->dirstat;
@@ -4339,7 +4339,7 @@ int Client::_read_async(Fh *f, __u64 off, __u64 len, bufferlist *bl)
       l = MAX(l, g_conf.client_readahead_min);
     if (g_conf.client_readahead_max_bytes)
       l = MIN(l, g_conf.client_readahead_max_bytes);
-    loff_t p = ceph_file_layout_period(in->layout);
+    loff_t p = in->layout.fl_stripe_count * in->layout.fl_object_size;
     if (g_conf.client_readahead_max_periods)
       l = MIN(l, g_conf.client_readahead_max_periods * p);
 
@@ -4348,7 +4348,7 @@ int Client::_read_async(Fh *f, __u64 off, __u64 len, bufferlist *bl)
       l -= (off+l) % p;
     else {
       // align readahead with stripe unit if we cross su boundary
-      int su = ceph_file_layout_su(in->layout);
+      int su = in->layout.fl_object_stripe_unit;
       if ((off+l)/su != off/su) l -= (off+l) % su;
     }
     
@@ -5815,21 +5815,21 @@ int Client::get_file_stripe_unit(int fd)
 {
   ceph_file_layout layout;
   describe_layout(fd, &layout);
-  return ceph_file_layout_su(layout);
+  return layout.fl_object_stripe_unit;
 }
 
 int Client::get_file_stripe_width(int fd)
 {
   ceph_file_layout layout;
   describe_layout(fd, &layout);
-  return ceph_file_layout_stripe_width(layout);
+  return layout.fl_object_stripe_unit * layout.fl_stripe_count;
 }
 
 int Client::get_file_stripe_period(int fd)
 {
   ceph_file_layout layout;
   describe_layout(fd, &layout);
-  return ceph_file_layout_period(layout);
+  return layout.fl_object_size * layout.fl_stripe_count;
 }
 
 int Client::get_file_replication(int fd)
@@ -5841,7 +5841,7 @@ int Client::get_file_replication(int fd)
   Fh *f = fd_map[fd];
   Inode *in = f->inode;
 
-  pool = ceph_file_layout_pg_pool(in->layout);
+  pool = in->layout.fl_pg_pool;
   return osdmap->get_pg_pool(pool).get_size();
 }
 
@@ -5849,7 +5849,7 @@ int Client::get_default_preferred_pg(int fd)
 {
   ceph_file_layout layout;
   describe_layout(fd, &layout);
-  return ceph_file_layout_pg_preferred(layout);
+  return layout.fl_pg_preferred;
 }
 
 int Client::get_file_stripe_address(int fd, loff_t offset, string& address)
diff --git a/src/include/ceph_frag.cc b/src/include/ceph_frag.cc
new file mode 100644 (file)
index 0000000..ab6cf35
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Ceph 'frag' type
+ */
+#include "types.h"
+
+int ceph_frag_compare(__u32 a, __u32 b)
+{
+       unsigned va = ceph_frag_value(a);
+       unsigned vb = ceph_frag_value(b);
+       if (va < vb)
+               return -1;
+       if (va > vb)
+               return 1;
+       va = ceph_frag_bits(a);
+       vb = ceph_frag_bits(b);
+       if (va < vb)
+               return -1;
+       if (va > vb)
+               return 1;
+       return 0;
+}
diff --git a/src/include/ceph_frag.h b/src/include/ceph_frag.h
new file mode 100644 (file)
index 0000000..793f50c
--- /dev/null
@@ -0,0 +1,109 @@
+#ifndef _FS_CEPH_FRAG_H
+#define _FS_CEPH_FRAG_H
+
+/*
+ * "Frags" are a way to describe a subset of a 32-bit number space,
+ * using a mask and a value to match against that mask.  Any given frag
+ * (subset of the number space) can be partitioned into 2^n sub-frags.
+ *
+ * Frags are encoded into a 32-bit word:
+ *   8 upper bits = "bits"
+ *  24 lower bits = "value"
+ * (We could go to 5+27 bits, but who cares.)
+ *
+ * We use the _most_ significant bits of the 24 bit value.  This makes
+ * values logically sort.
+ *
+ * Unfortunately, because the "bits" field is still in the high bits, we
+ * can't sort encoded frags numerically.  However, it does allow you
+ * to feed encoded frags as values into frag_contains_value.
+ */
+static inline __u32 ceph_frag_make(__u32 b, __u32 v)
+{
+       return (b << 24) |
+               (v & (0xffffffu << (24-b)) & 0xffffffu);
+}
+static inline __u32 ceph_frag_bits(__u32 f)
+{
+       return f >> 24;
+}
+static inline __u32 ceph_frag_value(__u32 f)
+{
+       return f & 0xffffffu;
+}
+static inline __u32 ceph_frag_mask(__u32 f)
+{
+       return (0xffffffu << (24-ceph_frag_bits(f))) & 0xffffffu;
+}
+static inline __u32 ceph_frag_mask_shift(__u32 f)
+{
+       return 24 - ceph_frag_bits(f);
+}
+
+static inline int ceph_frag_contains_value(__u32 f, __u32 v)
+{
+       return (v & ceph_frag_mask(f)) == ceph_frag_value(f);
+}
+static inline int ceph_frag_contains_frag(__u32 f, __u32 sub)
+{
+       /* is sub as specific as us, and contained by us? */
+       return ceph_frag_bits(sub) >= ceph_frag_bits(f) &&
+              (ceph_frag_value(sub) & ceph_frag_mask(f)) == ceph_frag_value(f);
+}
+
+static inline __u32 ceph_frag_parent(__u32 f)
+{
+       return ceph_frag_make(ceph_frag_bits(f) - 1,
+                        ceph_frag_value(f) & (ceph_frag_mask(f) << 1));
+}
+static inline int ceph_frag_is_left_child(__u32 f)
+{
+       return ceph_frag_bits(f) > 0 &&
+               (ceph_frag_value(f) & (0x1000000 >> ceph_frag_bits(f))) == 0;
+}
+static inline int ceph_frag_is_right_child(__u32 f)
+{
+       return ceph_frag_bits(f) > 0 &&
+               (ceph_frag_value(f) & (0x1000000 >> ceph_frag_bits(f))) == 1;
+}
+static inline __u32 ceph_frag_sibling(__u32 f)
+{
+       return ceph_frag_make(ceph_frag_bits(f),
+                     ceph_frag_value(f) ^ (0x1000000 >> ceph_frag_bits(f)));
+}
+static inline __u32 ceph_frag_left_child(__u32 f)
+{
+       return ceph_frag_make(ceph_frag_bits(f)+1, ceph_frag_value(f));
+}
+static inline __u32 ceph_frag_right_child(__u32 f)
+{
+       return ceph_frag_make(ceph_frag_bits(f)+1,
+             ceph_frag_value(f) | (0x1000000 >> (1+ceph_frag_bits(f))));
+}
+static inline __u32 ceph_frag_make_child(__u32 f, int by, int i)
+{
+       int newbits = ceph_frag_bits(f) + by;
+       return ceph_frag_make(newbits,
+                        ceph_frag_value(f) | (i << (24 - newbits)));
+}
+static inline int ceph_frag_is_leftmost(__u32 f)
+{
+       return ceph_frag_value(f) == 0;
+}
+static inline int ceph_frag_is_rightmost(__u32 f)
+{
+       return ceph_frag_value(f) == ceph_frag_mask(f);
+}
+static inline __u32 ceph_frag_next(__u32 f)
+{
+       return ceph_frag_make(ceph_frag_bits(f),
+                        ceph_frag_value(f) + (0x1000000 >> ceph_frag_bits(f)));
+}
+
+/*
+ * comparator to sort frags logically, as when traversing the
+ * number space in ascending order...
+ */
+int ceph_frag_compare(__u32 a, __u32 b);
+
+#endif
diff --git a/src/include/ceph_fs.cc b/src/include/ceph_fs.cc
new file mode 100644 (file)
index 0000000..fc615ba
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Some non-inline ceph helpers
+ */
+#include "types.h"
+
+int ceph_flags_to_mode(int flags)
+{
+#ifdef O_DIRECTORY  /* fixme */
+       if ((flags & O_DIRECTORY) == O_DIRECTORY)
+               return CEPH_FILE_MODE_PIN;
+#endif
+#ifdef O_LAZY
+       if (flags & O_LAZY)
+               return CEPH_FILE_MODE_LAZY;
+#endif
+       if ((flags & O_APPEND) == O_APPEND)
+               flags |= O_WRONLY;
+
+       flags &= O_ACCMODE;
+       if ((flags & O_RDWR) == O_RDWR)
+               return CEPH_FILE_MODE_RDWR;
+       if ((flags & O_WRONLY) == O_WRONLY)
+               return CEPH_FILE_MODE_WR;
+       return CEPH_FILE_MODE_RD;
+}
+
+int ceph_caps_for_mode(int mode)
+{
+       switch (mode) {
+       case CEPH_FILE_MODE_PIN:
+               return CEPH_CAP_PIN;
+       case CEPH_FILE_MODE_RD:
+               return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED |
+                       CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE;
+       case CEPH_FILE_MODE_RDWR:
+               return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED |
+                       CEPH_CAP_FILE_EXCL |
+                       CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE |
+                       CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER |
+                       CEPH_CAP_AUTH_SHARED | CEPH_CAP_AUTH_EXCL |
+                       CEPH_CAP_XATTR_SHARED | CEPH_CAP_XATTR_EXCL;
+       case CEPH_FILE_MODE_WR:
+               return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED |
+                       CEPH_CAP_FILE_EXCL |
+                       CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER |
+                       CEPH_CAP_AUTH_SHARED | CEPH_CAP_AUTH_EXCL |
+                       CEPH_CAP_XATTR_SHARED | CEPH_CAP_XATTR_EXCL;
+       }
+       return 0;
+}
+
+/* Name hashing routines. Initial hash value */
+/* Hash courtesy of the R5 hash in reiserfs modulo sign bits */
+#define ceph_init_name_hash()          0
+
+/* partial hash update function. Assume roughly 4 bits per character */
+static unsigned long ceph_partial_name_hash(unsigned long c, unsigned long prevhash)
+{
+       return (prevhash + (c << 4) + (c >> 4)) * 11;
+}
+
+/*
+ * Finally: cut down the number of bits to a int value (and try to avoid
+ * losing bits)
+ */
+static unsigned long ceph_end_name_hash(unsigned long hash)
+{
+       return (unsigned int) hash;
+}
+
+/* Compute the hash for a name string. */
+unsigned int ceph_full_name_hash(const char *name, unsigned int len)
+{
+       unsigned long hash = ceph_init_name_hash();
+       while (len--)
+               hash = ceph_partial_name_hash(*name++, hash);
+       return ceph_end_name_hash(hash);
+}
+
index f5c99de5315216ddbcb3f92c54e83b2add56065b..f7c8384aa21b479a58bb5afb5f1e449bff3b304f 100644 (file)
 #define CEPH_MAX_MON   31
 
 
-/*
- * "Frags" are a way to describe a subset of a 32-bit number space,
- * using a mask and a value to match against that mask.  Any given frag
- * (subset of the number space) can be partitioned into 2^n sub-frags.
- *
- * Frags are encoded into a 32-bit word:
- *   8 upper bits = "bits"
- *  24 lower bits = "value"
- * (We could go to 5+27 bits, but who cares.)
- *
- * We use the _most_ significant bits of the 24 bit value.  This makes
- * values logically sort.
- *
- * Unfortunately, because the "bits" field is still in the high bits, we
- * can't sort encoded frags numerically.  However, it does allow you
- * to feed encoded frags as values into frag_contains_value.
- */
-static inline __u32 ceph_frag_make(__u32 b, __u32 v)
-{
-       return (b << 24) |
-               (v & (0xffffffu << (24-b)) & 0xffffffu);
-}
-static inline __u32 ceph_frag_bits(__u32 f)
-{
-       return f >> 24;
-}
-static inline __u32 ceph_frag_value(__u32 f)
-{
-       return f & 0xffffffu;
-}
-static inline __u32 ceph_frag_mask(__u32 f)
-{
-       return (0xffffffu << (24-ceph_frag_bits(f))) & 0xffffffu;
-}
-static inline __u32 ceph_frag_mask_shift(__u32 f)
-{
-       return 24 - ceph_frag_bits(f);
-}
-
-static inline int ceph_frag_contains_value(__u32 f, __u32 v)
-{
-       return (v & ceph_frag_mask(f)) == ceph_frag_value(f);
-}
-static inline int ceph_frag_contains_frag(__u32 f, __u32 sub)
-{
-       /* is sub as specific as us, and contained by us? */
-       return ceph_frag_bits(sub) >= ceph_frag_bits(f) &&
-              (ceph_frag_value(sub) & ceph_frag_mask(f)) == ceph_frag_value(f);
-}
-
-static inline __u32 ceph_frag_parent(__u32 f)
-{
-       return ceph_frag_make(ceph_frag_bits(f) - 1,
-                        ceph_frag_value(f) & (ceph_frag_mask(f) << 1));
-}
-static inline int ceph_frag_is_left_child(__u32 f)
-{
-       return ceph_frag_bits(f) > 0 &&
-               (ceph_frag_value(f) & (0x1000000 >> ceph_frag_bits(f))) == 0;
-}
-static inline int ceph_frag_is_right_child(__u32 f)
-{
-       return ceph_frag_bits(f) > 0 &&
-               (ceph_frag_value(f) & (0x1000000 >> ceph_frag_bits(f))) == 1;
-}
-static inline __u32 ceph_frag_sibling(__u32 f)
-{
-       return ceph_frag_make(ceph_frag_bits(f),
-                     ceph_frag_value(f) ^ (0x1000000 >> ceph_frag_bits(f)));
-}
-static inline __u32 ceph_frag_left_child(__u32 f)
-{
-       return ceph_frag_make(ceph_frag_bits(f)+1, ceph_frag_value(f));
-}
-static inline __u32 ceph_frag_right_child(__u32 f)
-{
-       return ceph_frag_make(ceph_frag_bits(f)+1,
-             ceph_frag_value(f) | (0x1000000 >> (1+ceph_frag_bits(f))));
-}
-static inline __u32 ceph_frag_make_child(__u32 f, int by, int i)
-{
-       int newbits = ceph_frag_bits(f) + by;
-       return ceph_frag_make(newbits,
-                        ceph_frag_value(f) | (i << (24 - newbits)));
-}
-static inline int ceph_frag_is_leftmost(__u32 f)
-{
-       return ceph_frag_value(f) == 0;
-}
-static inline int ceph_frag_is_rightmost(__u32 f)
-{
-       return ceph_frag_value(f) == ceph_frag_mask(f);
-}
-static inline __u32 ceph_frag_next(__u32 f)
-{
-       return ceph_frag_make(ceph_frag_bits(f),
-                        ceph_frag_value(f) + (0x1000000 >> ceph_frag_bits(f)));
-}
-
-/*
- * comparator to sort frags logically, as when traversing the
- * number space in ascending order...
- */
-static inline int ceph_frag_compare(__u32 a, __u32 b)
-{
-       unsigned va = ceph_frag_value(a);
-       unsigned vb = ceph_frag_value(b);
-       if (va < vb)
-               return -1;
-       if (va > vb)
-               return 1;
-       va = ceph_frag_bits(a);
-       vb = ceph_frag_bits(b);
-       if (va < vb)
-               return -1;
-       if (va > vb)
-               return 1;
-       return 0;
-}
+unsigned int ceph_full_name_hash(const char *name, unsigned int len);
 
 
 /*
@@ -190,63 +72,6 @@ struct ceph_file_layout {
        __le32 fl_pg_pool;      /* namespace, crush ruleset, rep level */
 } __attribute__ ((packed));
 
-#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))
-#define ceph_file_layout_object_size(l) ((__s32)le32_to_cpu((l).fl_object_size))
-#define ceph_file_layout_cas_hash(l) ((__s32)le32_to_cpu((l).fl_cas_hash))
-#define ceph_file_layout_object_su(l) \
-       ((__s32)le32_to_cpu((l).fl_object_stripe_unit))
-#define ceph_file_layout_pg_preferred(l) \
-       ((__s32)le32_to_cpu((l).fl_pg_preferred))
-#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))
-
-/* "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))
-
-
-
-/*
- * string hash.
- *
- * taken from Linux, tho we should probably take care to use this one
- * in case the upstream hash changes.
- */
-
-/* Name hashing routines. Initial hash value */
-/* Hash courtesy of the R5 hash in reiserfs modulo sign bits */
-#define ceph_init_name_hash()          0
-
-/* partial hash update function. Assume roughly 4 bits per character */
-static inline unsigned long
-ceph_partial_name_hash(unsigned long c, unsigned long prevhash)
-{
-       return (prevhash + (c << 4) + (c >> 4)) * 11;
-}
-
-/*
- * Finally: cut down the number of bits to a int value (and try to avoid
- * losing bits)
- */
-static inline unsigned long ceph_end_name_hash(unsigned long hash)
-{
-       return (unsigned int) hash;
-}
-
-/* Compute the hash for a name string. */
-static inline unsigned int
-ceph_full_name_hash(const char *name, unsigned int len)
-{
-       unsigned long hash = ceph_init_name_hash();
-       while (len--)
-               hash = ceph_partial_name_hash(*name++, hash);
-       return ceph_end_name_hash(hash);
-}
 
 
 
@@ -582,26 +407,7 @@ struct ceph_mds_reply_dirfrag {
 #define CEPH_FILE_MODE_LAZY       4  /* lazy io */
 #define CEPH_FILE_MODE_NUM        8  /* bc these are bit fields.. mostly */
 
-static inline int ceph_flags_to_mode(int flags)
-{
-#ifdef O_DIRECTORY  /* fixme */
-       if ((flags & O_DIRECTORY) == O_DIRECTORY)
-               return CEPH_FILE_MODE_PIN;
-#endif
-#ifdef O_LAZY
-       if (flags & O_LAZY)
-               return CEPH_FILE_MODE_LAZY;
-#endif
-       if ((flags & O_APPEND) == O_APPEND)
-               flags |= O_WRONLY;
-
-       flags &= O_ACCMODE;
-       if ((flags & O_RDWR) == O_RDWR)
-               return CEPH_FILE_MODE_RDWR;
-       if ((flags & O_WRONLY) == O_WRONLY)
-               return CEPH_FILE_MODE_WR;
-       return CEPH_FILE_MODE_RD;
-}
+int ceph_flags_to_mode(int flags);
 
 
 /* capability bits */
@@ -681,30 +487,7 @@ static inline int ceph_flags_to_mode(int flags)
 #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \
                        CEPH_LOCK_IXATTR)
 
-static inline int ceph_caps_for_mode(int mode)
-{
-       switch (mode) {
-       case CEPH_FILE_MODE_PIN:
-               return CEPH_CAP_PIN;
-       case CEPH_FILE_MODE_RD:
-               return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED |
-                       CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE;
-       case CEPH_FILE_MODE_RDWR:
-               return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED |
-                       CEPH_CAP_FILE_EXCL |
-                       CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE |
-                       CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER |
-                       CEPH_CAP_AUTH_SHARED | CEPH_CAP_AUTH_EXCL |
-                       CEPH_CAP_XATTR_SHARED | CEPH_CAP_XATTR_EXCL;
-       case CEPH_FILE_MODE_WR:
-               return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED |
-                       CEPH_CAP_FILE_EXCL |
-                       CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER |
-                       CEPH_CAP_AUTH_SHARED | CEPH_CAP_AUTH_EXCL |
-                       CEPH_CAP_XATTR_SHARED | CEPH_CAP_XATTR_EXCL;
-       }
-       return 0;
-}
+int ceph_caps_for_mode(int mode);
 
 enum {
        CEPH_CAP_OP_GRANT,     /* mds->client grant */
index f5d3dc78b32dcb6161d66bb687daeb58e4a1e804..bfae38eda866a5f44ae91497d6163f58bbd6b52e 100644 (file)
@@ -21,6 +21,8 @@
 #include <iostream>
 #include "buffer.h"
 
+#include "ceph_frag.h"
+
 /*
  * 
  * the goal here is to use a binary split strategy to partition a namespace.  
index f166cc5b2000c417853ab1125fec8f8ba9e581d3..9c9604a7ee07a3b87981848cfbccbcac62ff3155 100644 (file)
@@ -24,6 +24,7 @@
 #include <string.h>
 
 #include "ceph_fs.h"
+#include "ceph_frag.h"
 
 #define _BACKWARD_BACKWARD_WARNING_H   /* make gcc 4.3 shut up about hash_*. */
 
index a15e8a95566fd80a8bfdef9df153f2d1a952da63..d7493d61614dd449f43758b74e9e8d2c6bba1440 100644 (file)
@@ -12,7 +12,8 @@ ceph-objs := super.o inode.o dir.o file.o addr.o ioctl.o \
        mds_client.o mdsmap.o \
        mon_client.o \
        osd_client.o osdmap.o crush/crush.o crush/mapper.o \
-       debugfs.o ceph_strings.o
+       debugfs.o \
+       ceph_fs.o ceph_strings.o ceph_frag.o
 
 else
 #Otherwise we were called directly from the command
diff --git a/src/kernel/ceph_frag.c b/src/kernel/ceph_frag.c
new file mode 120000 (symlink)
index 0000000..31c7534
--- /dev/null
@@ -0,0 +1 @@
+../include/ceph_frag.cc
\ No newline at end of file
diff --git a/src/kernel/ceph_frag.h b/src/kernel/ceph_frag.h
new file mode 120000 (symlink)
index 0000000..0b670e2
--- /dev/null
@@ -0,0 +1 @@
+../include/ceph_frag.h
\ No newline at end of file
diff --git a/src/kernel/ceph_fs.c b/src/kernel/ceph_fs.c
new file mode 120000 (symlink)
index 0000000..7a945bb
--- /dev/null
@@ -0,0 +1 @@
+../include/ceph_fs.cc
\ No newline at end of file
index 91c5039a5ff203a6e9f4138232b3359cd8fb068d..c7402f0f9747ca422e2308a7bcdb210d1255b65c 100644 (file)
@@ -138,6 +138,27 @@ static struct ceph_inode_frag *__get_or_create_frag(struct ceph_inode_info *ci,
        return frag;
 }
 
+/*
+ * find a specific frag @f
+ */
+struct ceph_inode_frag *__ceph_find_frag(struct ceph_inode_info *ci, u32 f)
+{
+       struct rb_node *n = ci->i_fragtree.rb_node;
+
+       while (n) {
+               struct ceph_inode_frag *frag =
+                       rb_entry(n, struct ceph_inode_frag, node);
+               int c = ceph_frag_compare(f, frag->frag);
+               if (c < 0)
+                       n = n->rb_left;
+               else if (c > 0)
+                       n = n->rb_right;
+               else
+                       return frag;
+       }
+       return NULL;
+}
+
 /*
  * Choose frag containing the given value @v.  If @pfrag is
  * specified, copy the frag delegation info to the caller if
index a811d479eca9a53c01be46d8300d069db47047cc..ad7f937376db2fee8316997b60917a71f53e2d09 100644 (file)
@@ -8,7 +8,6 @@
 #include "decode.h"
 #include "ceph_debug.h"
 
-
 char *ceph_osdmap_state_str(char *str, int len, int state)
 {
        int flag = 0;
index c76eecbf46dd4afd75de9f4ec26435f01f79170a..cdf6f1aecf0a98c11478ffa2b90eb9513198ca20 100644 (file)
@@ -53,6 +53,26 @@ struct ceph_osdmap {
        struct crush_map *crush;
 };
 
+/* 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))
+#define ceph_file_layout_object_size(l) ((__s32)le32_to_cpu((l).fl_object_size))
+#define ceph_file_layout_cas_hash(l) ((__s32)le32_to_cpu((l).fl_cas_hash))
+#define ceph_file_layout_object_su(l) \
+       ((__s32)le32_to_cpu((l).fl_object_stripe_unit))
+#define ceph_file_layout_pg_preferred(l) \
+       ((__s32)le32_to_cpu((l).fl_pg_preferred))
+#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))
+
+/* "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 int ceph_osd_is_up(struct ceph_osdmap *map, int osd)
 {
        return (osd < map->max_osd) && (map->osd_state[osd] & CEPH_OSD_UP);
index bb5bbed7dbea4eba0b38832e26453a653bfb3e89..669a9a4748fe658683ab8a8fa73bb776b10ac0b5 100644 (file)
@@ -398,24 +398,8 @@ static inline bool ceph_i_test(struct inode *inode, unsigned mask)
 
 
 /* find a specific frag @f */
-static inline struct ceph_inode_frag *
-__ceph_find_frag(struct ceph_inode_info *ci, u32 f)
-{
-       struct rb_node *n = ci->i_fragtree.rb_node;
-
-       while (n) {
-               struct ceph_inode_frag *frag =
-                       rb_entry(n, struct ceph_inode_frag, node);
-               int c = ceph_frag_compare(f, frag->frag);
-               if (c < 0)
-                       n = n->rb_left;
-               else if (c > 0)
-                       n = n->rb_right;
-               else
-                       return frag;
-       }
-       return NULL;
-}
+extern struct ceph_inode_frag *__ceph_find_frag(struct ceph_inode_info *ci,
+                                               u32 f);
 
 /*
  * choose fragment for value @v.  copy frag content to pfrag, if leaf
index c36318348f866190edaaaf156f7d6089e2c92274..8a514568cab2a337bab53b89fe3ac76067f759d7 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/string.h>
 
 #include "ceph_fs.h"
+#include "ceph_frag.h"
 
 /*
  * Identify inodes by both their ino AND snapshot id (a u64).
index 1e2c1a55d57e0f1918adb8c6a85b60f1fe36914b..5598089964ddd913e4c4388cc3319a8fcf4fd219 100644 (file)
@@ -376,7 +376,7 @@ struct inode_t {
   bool is_truncating() const { return truncate_size != -1ull; }
 
   int64_t get_layout_size_increment() {
-    return ceph_file_layout_period(layout);
+    return layout.fl_object_size * layout.fl_stripe_count;
   }
 
   __u64 get_max_size() const {
index 6f7f6cb6153d12d864a8b117d3e773c4ac8955e3..a35d92a29f8235c9bfaba22b2be55948f9f54091 100644 (file)
@@ -631,8 +631,8 @@ private:
   // oid -> pg
   ceph_object_layout file_to_object_layout(object_t oid, ceph_file_layout& layout) {
     return make_object_layout(oid, layout.fl_pg_pool,
-                             ceph_file_layout_pg_preferred(layout),
-                             ceph_file_layout_object_su(layout));
+                             layout.fl_pg_preferred,
+                             layout.fl_object_stripe_unit);
   }
 
   ceph_object_layout make_object_layout(object_t oid, int pg_pool, int preferred=-1, int object_stripe_unit = 0) {
index db60396d867933a1dda6309b2db96d359896198b..50b8b3ab901252d73b99a2b13ada572b3dc46c5e 100644 (file)
@@ -64,7 +64,7 @@ int Filer::probe(inodeno_t ino,
   Probe *probe = new Probe(ino, *layout, snapid, start_from, end, pmtime, flags, fwd, onfinish);
   
   // period (bytes before we jump unto a new set of object(s))
-  __u64 period = ceph_file_layout_period(*layout);
+  __u64 period = layout->fl_stripe_count * layout->fl_object_size;
   
   // start with 1+ periods.
   probe->probing_len = period;
@@ -183,7 +183,7 @@ void Filer::_probed(Probe *probe, const object_t& oid, __u64 size, utime_t mtime
     // keep probing!
     dout(10) << "_probed probing further" << dendl;
 
-    __u64 period = ceph_file_layout_period(probe->layout);
+    __u64 period = probe->layout.fl_stripe_count * probe->layout.fl_object_size;
     if (probe->fwd) {
       probe->probing_off += probe->probing_len;
       assert(probe->probing_off % period == 0);
@@ -225,9 +225,9 @@ void Filer::file_to_extents(inodeno_t ino, ceph_file_layout *layout,
    */
   map< object_t, ObjectExtent > object_extents;
   
-  __u32 object_size = ceph_file_layout_object_size(*layout);
-  __u32 su = ceph_file_layout_su(*layout);
-  __u32 stripe_count = ceph_file_layout_stripe_count(*layout);
+  __u32 object_size = layout->fl_object_size;
+  __u32 su = layout->fl_object_stripe_unit;
+  __u32 stripe_count = layout->fl_stripe_count;
   assert(object_size >= su);
   __u64 stripes_per_object = object_size / su;
   dout(20) << " stripes_per_object " << stripes_per_object << dendl;
index c860a582a3723c1b58b23bbc1f2568bac86b9df5..9dc2c5b06e9217e97ff9e3a00eeb977379d5de00 100644 (file)
@@ -35,7 +35,7 @@ void Journaler::create(ceph_file_layout *l)
 
   write_pos = flush_pos = ack_pos = safe_pos =
     read_pos = requested_pos = received_pos =
-    expire_pos = trimming_pos = trimmed_pos = ceph_file_layout_period(layout);
+    expire_pos = trimming_pos = trimmed_pos = layout.fl_stripe_count * layout.fl_object_size;
 }
 
 void Journaler::set_layout(ceph_file_layout *l)
@@ -48,7 +48,7 @@ void Journaler::set_layout(ceph_file_layout *l)
 
   // prefetch intelligently.
   // (watch out, this is big if you use big objects or weird striping)
-  fetch_len = ceph_file_layout_period(layout) * g_conf.journaler_prefetch_periods;
+  fetch_len = layout.fl_stripe_count * layout.fl_object_size * g_conf.journaler_prefetch_periods;
   prefetch_from = fetch_len / 2;
 }
 
@@ -315,7 +315,7 @@ __s64 Journaler::append_entry(bufferlist& bl)
 
   if (!g_conf.journaler_allow_split_entries) {
     // will we span a stripe boundary?
-    int p = ceph_file_layout_su(layout);
+    int p = layout.fl_object_stripe_unit;
     if (write_pos / p != (write_pos + (__s64)(bl.length() + sizeof(s))) / p) {
       // yes.
       // move write_pos forward.
@@ -357,7 +357,7 @@ __s64 Journaler::append_entry(bufferlist& bl)
   write_pos += sizeof(s) + s;
 
   // flush previous object?
-  int su = ceph_file_layout_su(layout);
+  int su = layout.fl_object_stripe_unit;
   int write_off = write_pos % su;
   int write_obj = write_pos / su;
   int flush_obj = flush_pos / su;
@@ -783,7 +783,7 @@ public:
 void Journaler::trim()
 {
   __s64 trim_to = last_committed.expire_pos;
-  trim_to -= trim_to % ceph_file_layout_period(layout);
+  trim_to -= trim_to % (layout.fl_stripe_count * layout.fl_object_size);
   dout(10) << "trim last_commited head was " << last_committed
           << ", can trim to " << trim_to
           << dendl;
index 0fa129558ffb74cf8c986cb51c381ba7de3e3ace..c2f665401a8cb06a6df0713526c44ecdfcb9817f 100644 (file)
@@ -243,7 +243,7 @@ public:
   __s64 get_expire_pos() const { return expire_pos; }
   __s64 get_trimmed_pos() const { return trimmed_pos; }
 
-  __s64 get_layout_period() const { return ceph_file_layout_period(layout); }
+  __s64 get_layout_period() const { return layout.fl_stripe_count * layout.fl_object_size; }
   ceph_file_layout& get_layout() { return layout; }
 
   // write