diff mbox

[1/2] libceph: Add a new func ceph_calc_ceph_temp_pg and export it.

Message ID 201308051050567055647@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

majianpeng Aug. 5, 2013, 2:50 a.m. UTC
We need temp seed of pg in ceph filesystem.So we add a new func and
export it.

Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>

---
 include/linux/ceph/osdmap.h |  2 ++
 net/ceph/osdmap.c           | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

-- 
1.8.3.rc1.44.gb387c77

Thanks!
Jianpeng Ma
diff mbox

Patch

diff --git a/include/linux/ceph/osdmap.h b/include/linux/ceph/osdmap.h
index d05cc44..2cf524b 100644
--- a/include/linux/ceph/osdmap.h
+++ b/include/linux/ceph/osdmap.h
@@ -157,6 +157,8 @@  extern int ceph_calc_file_object_mapping(struct ceph_file_layout *layout,
 /* 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_calc_ceph_temp_pg(struct ceph_pg *pg, const char *oid,
+					struct ceph_osdmap *osdmap, uint64_t pool);
 extern int ceph_calc_pg_acting(struct ceph_osdmap *osdmap,
 			       struct ceph_pg pgid,
 			       int *acting);
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index 603ddd9..e775b03 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -1111,6 +1111,30 @@  int ceph_calc_ceph_pg(struct ceph_pg *pg, const char *oid,
 EXPORT_SYMBOL(ceph_calc_ceph_pg);
 
 /*
+ * Using temp pg.seed only by cephfs.We want to dispaly the same name like
+ * command 'ceph pg dump'
+ */
+int ceph_calc_ceph_temp_pg(struct ceph_pg *pg, const char *oid,
+				struct ceph_osdmap *osdmap, uint64_t pool)
+{
+	struct ceph_pg_pool_info *pool_info;
+
+	BUG_ON(!osdmap);
+	pool_info = __lookup_pg_pool(&osdmap->pg_pools, pool);
+	if (!pool_info)
+		return -EIO;
+	pg->pool = pool;
+	pg->seed = ceph_str_hash(pool_info->object_hash, oid, strlen(oid));
+	pg->seed = ceph_stable_mod(pg->seed, pool_info->pg_num,
+				    pool_info->pgp_num_mask);
+
+	dout("%s '%s' pgid(temp) %lld.%x\n", __func__, 
+		oid, pg->pool, pg->seed);
+	return 0;
+}
+EXPORT_SYMBOL(ceph_calc_ceph_temp_pg);
+
+/*
  * Calculate raw osd vector for the given pgid.  Return pointer to osd
  * array, or NULL on failure.
  */