From patchwork Mon Aug 5 02:50:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: majianpeng X-Patchwork-Id: 2838510 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3581EBF535 for ; Mon, 5 Aug 2013 02:51:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A81EC2017A for ; Mon, 5 Aug 2013 02:51:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 29EBD20142 for ; Mon, 5 Aug 2013 02:51:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754434Ab3HECvF (ORCPT ); Sun, 4 Aug 2013 22:51:05 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:40277 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754354Ab3HECvE (ORCPT ); Sun, 4 Aug 2013 22:51:04 -0400 Received: by mail-pd0-f178.google.com with SMTP id w10so2697653pde.37 for ; Sun, 04 Aug 2013 19:51:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:reply-to:subject:x-priority:x-guid:x-has-attach :x-mailer:mime-version:message-id:content-type :content-transfer-encoding; bh=a3A9yougCuPD/RRydBt5fKWbCsbeO0+RYHEQH8g70IQ=; b=XbWaMBfE3Mg8Y2Ox07PPYj0RN2k25n9tquo8AvKWY4TDbTES6SL20MI3G+q+0LSqFn DjdGue9DVHCt3B8gOqKGvHl7YzfGe8+9yFAXyBdnBNDnBuPp6p0sLBxr8c6rGPQssxJf iyBXbB7bkX/KhlthWZ/0qJx0rsHDi2zE6FQuZGMhXsapoylQPvHe06vqPym4xRSjGAY0 A20bm7yxaqATWnUsp05jun4pftgqzlhOKxO2ZhdBml1MInVPrxC79uMuECT3DnQjnZ+K V0qReQr56D3hda3FkOGtj3FZyoIaE8JXc4QOasO4U97PJ4keQz5vkK5kAPK1dpsg5kux RHnA== X-Received: by 10.68.210.103 with SMTP id mt7mr19719966pbc.179.1375671062953; Sun, 04 Aug 2013 19:51:02 -0700 (PDT) Received: from majianpeng ([218.242.10.182]) by mx.google.com with ESMTPSA id qc5sm24354738pbc.31.2013.08.04.19.51.00 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 04 Aug 2013 19:51:02 -0700 (PDT) Date: Mon, 5 Aug 2013 10:50:58 +0800 From: majianpeng To: sage Cc: ceph-devel Reply-To: majianpeng Subject: [PATCH 1/2] libceph: Add a new func ceph_calc_ceph_temp_pg and export it. X-Priority: 3 X-GUID: B4B40FD9-FE7D-45B3-B820-52449DDBE95F X-Has-Attach: no X-Mailer: Foxmail 7.0.1.90[en] Mime-Version: 1.0 Message-ID: <201308051050567055647@gmail.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need temp seed of pg in ceph filesystem.So we add a new func and export it. Signed-off-by: Jianpeng Ma --- 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 --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. */