]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - include/linux/ceph/osdmap.h
libceph: replace ceph_calc_ceph_pg() with ceph_oloc_oid_to_pg()
[mirror_ubuntu-artful-kernel.git] / include / linux / ceph / osdmap.h
index d05cc4451af62dd158929b39e6684fc19fd85cb2..ebb8ec285de6cd5394d8b080c288564712ef4901 100644 (file)
@@ -40,8 +40,19 @@ struct ceph_pg_pool_info {
 };
 
 struct ceph_object_locator {
-       uint64_t pool;
-       char *key;
+       s64 pool;
+};
+
+/*
+ * Maximum supported by kernel client object name length
+ *
+ * (probably outdated: must be >= RBD_MAX_MD_NAME_LEN -- currently 100)
+ */
+#define CEPH_MAX_OID_NAME_LEN 100
+
+struct ceph_object_id {
+       char name[CEPH_MAX_OID_NAME_LEN];
+       int name_len;
 };
 
 struct ceph_pg_mapping {
@@ -73,33 +84,30 @@ 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_pool(l) \
-       ((__s32)le32_to_cpu((l).fl_pg_pool))
-
-static inline unsigned ceph_file_layout_stripe_width(struct ceph_file_layout *l)
+static inline void ceph_oid_set_name(struct ceph_object_id *oid,
+                                    const char *name)
 {
-       return le32_to_cpu(l->fl_stripe_unit) *
-               le32_to_cpu(l->fl_stripe_count);
+       int len;
+
+       len = strlen(name);
+       if (len > sizeof(oid->name)) {
+               WARN(1, "ceph_oid_set_name '%s' len %d vs %zu, truncating\n",
+                    name, len, sizeof(oid->name));
+               len = sizeof(oid->name);
+       }
+
+       memcpy(oid->name, name, len);
+       oid->name_len = len;
 }
 
-/* "period" == bytes before i start on a new set of objects */
-static inline unsigned ceph_file_layout_period(struct ceph_file_layout *l)
+static inline void ceph_oid_copy(struct ceph_object_id *dest,
+                                struct ceph_object_id *src)
 {
-       return le32_to_cpu(l->fl_object_size) *
-               le32_to_cpu(l->fl_stripe_count);
+       BUG_ON(src->name_len > sizeof(dest->name));
+       memcpy(dest->name, src->name, src->name_len);
+       dest->name_len = src->name_len;
 }
 
-
 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);
@@ -155,8 +163,11 @@ extern int ceph_calc_file_object_mapping(struct ceph_file_layout *layout,
                                         u64 *bno, u64 *oxoff, u64 *oxlen);
 
 /* calculate mapping of object to a placement group */
-extern int ceph_calc_ceph_pg(struct ceph_pg *pg, const char *oid,
-                         struct ceph_osdmap *osdmap, uint64_t pool);
+extern int ceph_oloc_oid_to_pg(struct ceph_osdmap *osdmap,
+                              struct ceph_object_locator *oloc,
+                              struct ceph_object_id *oid,
+                              struct ceph_pg *pg_out);
+
 extern int ceph_calc_pg_acting(struct ceph_osdmap *osdmap,
                               struct ceph_pg pgid,
                               int *acting);