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
include/blobhash.h\
include/buffer.h\
include/byteorder.h\
+ include/ceph_frag.h\
include/ceph_fs.h\
include/color.h\
include/crc32c.h\
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\
- kclient: retry alloc on ENOMEM when reading from connection?
- client authentication
+
+/- uninline frags
+/- uninline string hash
+
+
bugs
- mislinked directory?
- premature filejournal trimming?
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;
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;
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);
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;
}
{
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)
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();
}
{
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)
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+#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
--- /dev/null
+/*
+ * 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);
+}
+
#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);
/*
__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);
-}
#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 */
#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 */
#include <iostream>
#include "buffer.h"
+#include "ceph_frag.h"
+
/*
*
* the goal here is to use a binary split strategy to partition a namespace.
#include <string.h>
#include "ceph_fs.h"
+#include "ceph_frag.h"
#define _BACKWARD_BACKWARD_WARNING_H /* make gcc 4.3 shut up about hash_*. */
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
--- /dev/null
+../include/ceph_frag.cc
\ No newline at end of file
--- /dev/null
+../include/ceph_frag.h
\ No newline at end of file
--- /dev/null
+../include/ceph_fs.cc
\ No newline at end of file
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
#include "decode.h"
#include "ceph_debug.h"
-
char *ceph_osdmap_state_str(char *str, int len, int state)
{
int flag = 0;
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);
/* 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
#include <linux/string.h>
#include "ceph_fs.h"
+#include "ceph_frag.h"
/*
* Identify inodes by both their ino AND snapshot id (a u64).
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 {
// 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) {
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;
// 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);
*/
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;
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)
// 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;
}
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.
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;
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;
__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