All of lore.kernel.org
 help / color / mirror / Atom feed
From: majianpeng <majianpeng@gmail.com>
To: sage <sage@inktank.com>
Cc: ceph-devel <ceph-devel@vger.kernel.org>
Subject: [PATCH 1/2] libceph: Add a new func ceph_calc_ceph_temp_pg and export it.
Date: Mon, 5 Aug 2013 10:50:58 +0800	[thread overview]
Message-ID: <201308051050567055647@gmail.com> (raw)

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

                 reply	other threads:[~2013-08-05  2:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201308051050567055647@gmail.com \
    --to=majianpeng@gmail.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=sage@inktank.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.