From patchwork Thu Apr 10 14:13:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 3963111 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C56209F375 for ; Thu, 10 Apr 2014 14:13:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E7FF020121 for ; Thu, 10 Apr 2014 14:13:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8BA020127 for ; Thu, 10 Apr 2014 14:13:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934771AbaDJONL (ORCPT ); Thu, 10 Apr 2014 10:13:11 -0400 Received: from mail-ee0-f47.google.com ([74.125.83.47]:35746 "EHLO mail-ee0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934712AbaDJONJ (ORCPT ); Thu, 10 Apr 2014 10:13:09 -0400 Received: by mail-ee0-f47.google.com with SMTP id b15so3072338eek.20 for ; Thu, 10 Apr 2014 07:13:08 -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; bh=g6llFKZRRgmnfdQfpoxvNd95j27CQjoxM9ZwoY3vqVg=; b=D1fcA6kK+tx1jR7/GwxtXoiWZeySzmYUCst5yMR+K+cAYMHpYgEScu2lmdju5rHHxe sEpER0y+6PVnTM1WlXdqbehB5B2CIoq7VIxfYLPFVBCKD21AdzsJmaPNidzGXbBCVEt3 WKmdeCQd5Nt4GPv8EfCGy+tp3Qb4Q7MRzmOo7b+WKczcxMf8D/s9YenH33SeMVxlCXwq UqDsxxDLXXMFIPkS1mTJp1gkzQha/aymHJAL2nzBSpKP1YYcBbV6HrNVhR9XnI5X4NP8 SW2YphtPZq8wm1rl3sod0/DtY28kxsQoJmZ0GsXZfACfF5XsCbFULxsI4liJTwhZBcRn KXmQ== X-Gm-Message-State: ALoCoQnE52bVGI1NBxZnTYgxHx52lnvd8pGhcmojIK1Y1Ce+qHiToIFlL3Wxrwzy54hviFQsae7h X-Received: by 10.14.115.195 with SMTP id e43mr3280647eeh.76.1397139188300; Thu, 10 Apr 2014 07:13:08 -0700 (PDT) Received: from localhost ([109.110.67.38]) by mx.google.com with ESMTPSA id x45sm10236779eef.15.2014.04.10.07.13.07 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 10 Apr 2014 07:13:07 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH] libceph: fix non-default values check in apply_primary_affinity() Date: Thu, 10 Apr 2014 18:13:05 +0400 Message-Id: <1397139185-5492-1-git-send-email-ilya.dryomov@inktank.com> X-Mailer: git-send-email 1.7.10.4 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.5 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 osd_primary_affinity array is indexed into incorrectly when checking for non-default primary-affinity values. This nullifies the impact of the rest of the apply_primary_affinity() and results in misdirected requests. if (osds[i] != CRUSH_ITEM_NONE && osdmap->osd_primary_affinity[i] != ^^^ CEPH_OSD_DEFAULT_PRIMARY_AFFINITY) { For a pool with size 2, this always ends up checking osd0 and osd1 primary_affinity values, instead of the values that correspond to the osds in question. E.g., given a [2,3] up set and a [max,max,0,max] primary affinity vector, requests are still sent to osd2, because both osd0 and osd1 happen to have max primary_affinity values and therefore we return from apply_primary_affinity() early on the premise that all osds in the given set have max (default) values. Fix it. Fixes: http://tracker.ceph.com/issues/7954 Signed-off-by: Ilya Dryomov Reviewed-by: Sage Weil --- net/ceph/osdmap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index e632b5a52f5b..8b8a5a24b223 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c @@ -1548,8 +1548,10 @@ static void apply_primary_affinity(struct ceph_osdmap *osdmap, u32 pps, return; for (i = 0; i < len; i++) { - if (osds[i] != CRUSH_ITEM_NONE && - osdmap->osd_primary_affinity[i] != + int osd = osds[i]; + + if (osd != CRUSH_ITEM_NONE && + osdmap->osd_primary_affinity[osd] != CEPH_OSD_DEFAULT_PRIMARY_AFFINITY) { break; } @@ -1563,10 +1565,9 @@ static void apply_primary_affinity(struct ceph_osdmap *osdmap, u32 pps, * osd's pgs get rejected as primary. */ for (i = 0; i < len; i++) { - int osd; + int osd = osds[i]; u32 aff; - osd = osds[i]; if (osd == CRUSH_ITEM_NONE) continue;