* [PATCH 1/2] libceph: Add a new func ceph_calc_ceph_temp_pg and export it.
@ 2013-08-05 2:50 majianpeng
0 siblings, 0 replies; only message in thread
From: majianpeng @ 2013-08-05 2:50 UTC (permalink / raw)
To: sage; +Cc: ceph-devel
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(+)
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.
*/
--
1.8.3.rc1.44.gb387c77
Thanks!
Jianpeng Ma
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-08-05 2:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-05 2:50 [PATCH 1/2] libceph: Add a new func ceph_calc_ceph_temp_pg and export it majianpeng
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.