From patchwork Thu Mar 27 18:18:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 3899361 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 38ECCBF540 for ; Thu, 27 Mar 2014 18:19:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 50AA120256 for ; Thu, 27 Mar 2014 18:19:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 69BFD20225 for ; Thu, 27 Mar 2014 18:19:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757206AbaC0STl (ORCPT ); Thu, 27 Mar 2014 14:19:41 -0400 Received: from mail-ee0-f41.google.com ([74.125.83.41]:55316 "EHLO mail-ee0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757204AbaC0STj (ORCPT ); Thu, 27 Mar 2014 14:19:39 -0400 Received: by mail-ee0-f41.google.com with SMTP id t10so3246223eei.0 for ; Thu, 27 Mar 2014 11:19:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=SUH3jLeDyOmpV4ilbmWXlcZ3No2HAFXlWXre0QaKmgs=; b=ktvn1//ZDqHwzUaAqjAD4Ul6raGR1wJzk5yOTMqAk3/Z45xlSpas56mGn8H3O0d4wz FPO99Gar/1dGqfssVhpDR+HeEID2x79wgmlASW0tAnmFBSw2UtTK4/9/1sMLPjtJVA/g JZ34O69fHWvD479NgTgmO0Wmv01jb9354vBCejjUyRZ7OHm1QqdbdLR59JwkSeit8eiU y9aKbwZMdqNBcdKbRzmhM+WkN0dLl47MhLifNx3htuFR1AE0ecE9FdaDBwxETNJgq9hm lskisba8PlDxfkFkOlxbgyxhXmhPR5IyTp4Uktnl2ylfzHBRDuxg0saMj9ImKeBhbUz0 9r1A== X-Gm-Message-State: ALoCoQn2fXXeU3ecI06u8wARcuRa6bBCe6oez2ela515uT2ATV8iE+snukg3vW9atexjurM2hQKE X-Received: by 10.15.91.77 with SMTP id r53mr101172eez.70.1395944378120; Thu, 27 Mar 2014 11:19:38 -0700 (PDT) Received: from localhost ([109.110.66.7]) by mx.google.com with ESMTPSA id bc51sm5969944eeb.22.2014.03.27.11.19.37 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 27 Mar 2014 11:19:37 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 32/33] libceph: redo ceph_calc_pg_primary() in terms of ceph_calc_pg_acting() Date: Thu, 27 Mar 2014 20:18:18 +0200 Message-Id: <1395944299-21970-33-git-send-email-ilya.dryomov@inktank.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1395944299-21970-1-git-send-email-ilya.dryomov@inktank.com> References: <1395944299-21970-1-git-send-email-ilya.dryomov@inktank.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=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Reimplement ceph_calc_pg_primary() in terms of ceph_calc_pg_acting() and get rid of the now unused calc_pg_raw(). Signed-off-by: Ilya Dryomov Reviewed-by: Alex Elder --- net/ceph/osdmap.c | 79 +++-------------------------------------------------- 1 file changed, 4 insertions(+), 75 deletions(-) diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index 8c596a13c60f..f0567d8ca683 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c @@ -1449,71 +1449,6 @@ static int do_crush(struct ceph_osdmap *map, int ruleno, int x, } /* - * Calculate raw osd vector for the given pgid. Return pointer to osd - * array, or NULL on failure. - */ -static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid, - int *osds, int *num) -{ - struct ceph_pg_mapping *pg; - struct ceph_pg_pool_info *pool; - int ruleno; - int r; - u32 pps; - - pool = __lookup_pg_pool(&osdmap->pg_pools, pgid.pool); - if (!pool) - return NULL; - - /* pg_temp? */ - pgid.seed = ceph_stable_mod(pgid.seed, pool->pg_num, - pool->pg_num_mask); - pg = __lookup_pg_mapping(&osdmap->pg_temp, pgid); - if (pg) { - *num = pg->pg_temp.len; - return pg->pg_temp.osds; - } - - /* crush */ - ruleno = crush_find_rule(osdmap->crush, pool->crush_ruleset, - pool->type, pool->size); - if (ruleno < 0) { - pr_err("no crush rule pool %lld ruleset %d type %d size %d\n", - pgid.pool, pool->crush_ruleset, pool->type, - pool->size); - return NULL; - } - - if (pool->flags & CEPH_POOL_FLAG_HASHPSPOOL) { - /* hash pool id and seed sothat pool PGs do not overlap */ - pps = crush_hash32_2(CRUSH_HASH_RJENKINS1, - ceph_stable_mod(pgid.seed, pool->pgp_num, - pool->pgp_num_mask), - pgid.pool); - } else { - /* - * legacy ehavior: add ps and pool together. this is - * not a great approach because the PGs from each pool - * will overlap on top of each other: 0.5 == 1.4 == - * 2.3 == ... - */ - pps = ceph_stable_mod(pgid.seed, pool->pgp_num, - pool->pgp_num_mask) + - (unsigned)pgid.pool; - } - r = do_crush(osdmap, ruleno, pps, osds, min_t(int, pool->size, *num), - osdmap->osd_weight, osdmap->max_osd); - if (r < 0) { - pr_err("error %d from crush rule: pool %lld ruleset %d type %d" - " size %d\n", r, pgid.pool, pool->crush_ruleset, - pool->type, pool->size); - return NULL; - } - *num = r; - return osds; -} - -/* * Calculate raw (crush) set for given pgid. * * Return raw set length, or error. @@ -1769,17 +1704,11 @@ int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid, */ int ceph_calc_pg_primary(struct ceph_osdmap *osdmap, struct ceph_pg pgid) { - int rawosds[CEPH_PG_MAX_SIZE], *osds; - int i, num = CEPH_PG_MAX_SIZE; + int osds[CEPH_PG_MAX_SIZE]; + int primary; - osds = calc_pg_raw(osdmap, pgid, rawosds, &num); - if (!osds) - return -1; + ceph_calc_pg_acting(osdmap, pgid, osds, &primary); - /* primary is first up osd */ - for (i = 0; i < num; i++) - if (ceph_osd_is_up(osdmap, osds[i])) - return osds[i]; - return -1; + return primary; } EXPORT_SYMBOL(ceph_calc_pg_primary);