From patchwork Thu Mar 27 18:18:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 3899341 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 63C33BF540 for ; Thu, 27 Mar 2014 18:19:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8651F20225 for ; Thu, 27 Mar 2014 18:19:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D7F720253 for ; Thu, 27 Mar 2014 18:19:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757201AbaC0STh (ORCPT ); Thu, 27 Mar 2014 14:19:37 -0400 Received: from mail-ee0-f44.google.com ([74.125.83.44]:42626 "EHLO mail-ee0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757189AbaC0STc (ORCPT ); Thu, 27 Mar 2014 14:19:32 -0400 Received: by mail-ee0-f44.google.com with SMTP id e49so3216376eek.31 for ; Thu, 27 Mar 2014 11:19:31 -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=HgIc2zaCsiF4kf57C7/jpjZMc5vggf9UykczBsnpzGA=; b=iGJpC8qT9tuEFbZo6EbQ3DCGl8PeLdi2A+a7ps8C7rb2/1ZUUs5LVSgqkMe9EPDHGS mb2VNfUopUiyeyMjs0zSNxHKKVFi/WLPMP6/CMcZQEIAd18gQXLI2V1Gyiq7t28SZdCE /eOLt1LV79gk+HQ7WKHl0U/O7fqUqtqMV1uTUHA9cna+dfqt18pkoyv1Th0zlTmooG1P 1UtoWw+Le2ybStTwLaq1RBNzCraA0hxm67Pd2OkpXJVmio+6Z4uzP0SkJF8SzVJMdOrc uIx0wYfHN1QuYELdEUpvvs0e4GOynVB/VkMN3hKupgPkgXNLKx4DqRu61jZY5DH9fOYk SA7A== X-Gm-Message-State: ALoCoQm0dt5ouN8I+e6b0d+G98PahpvQ8xRmgVoTrNqjPw6c0JFP+K6sn4w81nDmOAE1Q5ZQZLc8 X-Received: by 10.14.204.199 with SMTP id h47mr3134480eeo.48.1395944371238; Thu, 27 Mar 2014 11:19:31 -0700 (PDT) Received: from localhost ([109.110.66.7]) by mx.google.com with ESMTPSA id x45sm5980508eef.15.2014.03.27.11.19.30 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 27 Mar 2014 11:19:30 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 29/33] libceph: return primary from ceph_calc_pg_acting() Date: Thu, 27 Mar 2014 20:18:15 +0200 Message-Id: <1395944299-21970-30-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 In preparation for adding support for primary_temp, stop assuming primaryness: add a primary out parameter to ceph_calc_pg_acting() and change call sites accordingly. Primary is now specified separately from the order of osds in the set. Signed-off-by: Ilya Dryomov Reviewed-by: Alex Elder --- include/linux/ceph/osdmap.h | 2 +- net/ceph/osd_client.c | 10 ++++------ net/ceph/osdmap.c | 20 ++++++++++++-------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/include/linux/ceph/osdmap.h b/include/linux/ceph/osdmap.h index b0c8f8490663..561ea896c657 100644 --- a/include/linux/ceph/osdmap.h +++ b/include/linux/ceph/osdmap.h @@ -212,7 +212,7 @@ extern int ceph_oloc_oid_to_pg(struct ceph_osdmap *osdmap, extern int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid, - int *osds); + int *osds, int *primary); extern int ceph_calc_pg_primary(struct ceph_osdmap *osdmap, struct ceph_pg pgid); diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 6f64eec18851..b4157dc22199 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -1333,7 +1333,7 @@ static int __map_request(struct ceph_osd_client *osdc, { struct ceph_pg pgid; int acting[CEPH_PG_MAX_SIZE]; - int o = -1, num = 0; + int num, o; int err; bool was_paused; @@ -1346,11 +1346,9 @@ static int __map_request(struct ceph_osd_client *osdc, } req->r_pgid = pgid; - err = ceph_calc_pg_acting(osdc->osdmap, pgid, acting); - if (err > 0) { - o = acting[0]; - num = err; - } + num = ceph_calc_pg_acting(osdc->osdmap, pgid, acting, &o); + if (num < 0) + num = 0; was_paused = req->r_paused; req->r_paused = __req_should_be_paused(osdc, req); diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index 1963623bd488..7193b012ee02 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c @@ -1644,19 +1644,21 @@ static int apply_temps(struct ceph_osdmap *osdmap, /* * Calculate acting set for given pgid. * - * Return acting set length, or error. + * Return acting set length, or error. *primary is set to acting + * primary osd id, or -1 if acting set is empty or on error. */ int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid, - int *osds) + int *osds, int *primary) { struct ceph_pg_pool_info *pool; u32 pps; int len; - int primary; pool = __lookup_pg_pool(&osdmap->pg_pools, pgid.pool); - if (!pool) - return 0; + if (!pool) { + *primary = -1; + return -ENOENT; + } if (pool->flags & CEPH_POOL_FLAG_HASHPSPOOL) { /* hash pool id and seed so that pool PGs do not overlap */ @@ -1677,12 +1679,14 @@ int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid, } len = pg_to_raw_osds(osdmap, pool, pgid, pps, osds); - if (len < 0) + if (len < 0) { + *primary = -1; return len; + } - len = raw_to_up_osds(osdmap, pool, osds, len, &primary); + len = raw_to_up_osds(osdmap, pool, osds, len, primary); - len = apply_temps(osdmap, pool, pgid, osds, len, &primary); + len = apply_temps(osdmap, pool, pgid, osds, len, primary); return len; }