From patchwork Tue Mar 26 02:27:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2334441 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 426813FC54 for ; Tue, 26 Mar 2013 02:27:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759193Ab3CZC1d (ORCPT ); Mon, 25 Mar 2013 22:27:33 -0400 Received: from mail-ia0-f181.google.com ([209.85.210.181]:46587 "EHLO mail-ia0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756064Ab3CZC1d (ORCPT ); Mon, 25 Mar 2013 22:27:33 -0400 Received: by mail-ia0-f181.google.com with SMTP id o25so6019479iad.26 for ; Mon, 25 Mar 2013 19:27:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=+ZOoqTxmGdX2kUor92Jef6vk70/kpYTOL3l3WUbeL1o=; b=NnELjjwEWfWCrPXb5qBlusiB01T5iapBBO84Wb7xExkPk1yK5968M4voWXqZ6Sm8Ec zld/UJUDfCTjQR3tX86+2qbu7C43T7+n/a8KxIzjDqAwbVFAz4YwLdbcd4zOvY0n61eC YEbWJjFf/udH81kR5ykskkz5I2N2mb0PD9/mu8BERzFoVju5/pq+Ultt44mHQpg0tCA4 yeC+i3jt4Al0Pa4GDadqI+SGyrnigE4zsMKhlHLIIYU5vS1R0078VZN2eJ2zaaBvVn/V v5qilAbAfQwjv7nYknx3PS5X/fg+pMmYmcXap0ozav6XlknWc6mDTe5UzVd+NPba1kkN szXg== X-Received: by 10.50.57.168 with SMTP id j8mr142480igq.51.1364264852770; Mon, 25 Mar 2013 19:27:32 -0700 (PDT) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPS id ip2sm656302igc.5.2013.03.25.19.27.27 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Mar 2013 19:27:31 -0700 (PDT) Message-ID: <5151078F.5000509@inktank.com> Date: Mon, 25 Mar 2013 21:27:27 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 2/6] libceph: no more kick_requests() race References: <5151071C.3000309@inktank.com> In-Reply-To: <5151071C.3000309@inktank.com> X-Gm-Message-State: ALoCoQmLx6lbQcJGvQ4zkkkvF/UtT+Xrxxgc/5HuSMLEcjjNGlHz3j0M0Fr+MCrotu87RdsP4C6/ Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Since we no longer drop the request mutex between registering and mapping an osd request in ceph_osdc_start_request(), there is no chance of a race with kick_requests(). We can now therefore map and send the new request unconditionally (but we'll issue a warning should it ever occur). Signed-off-by: Alex Elder --- net/ceph/osd_client.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) up_read(&osdc->map_sem); diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index f9276cb..3723a7f 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -1779,31 +1779,24 @@ int ceph_osdc_start_request(struct ceph_osd_client *osdc, down_read(&osdc->map_sem); mutex_lock(&osdc->request_mutex); - /* - * a racing kick_requests() may have sent the message for us - * while we dropped request_mutex above, so only send now if - * the request still han't been touched yet. - */ __register_request(osdc, req); - if (req->r_sent == 0) { - rc = __map_request(osdc, req, 0); - if (rc < 0) { - if (nofail) { - dout("osdc_start_request failed map, " - " will retry %lld\n", req->r_tid); - rc = 0; - } - goto out_unlock; - } - if (req->r_osd == NULL) { - dout("send_request %p no up osds in pg\n", req); - ceph_monc_request_next_osdmap(&osdc->client->monc); - } else { - __send_request(osdc, req); + WARN_ON(req->r_sent); + rc = __map_request(osdc, req, 0); + if (rc < 0) { + if (nofail) { + dout("osdc_start_request failed map, " + " will retry %lld\n", req->r_tid); + rc = 0; } - rc = 0; + goto out_unlock; } - + if (req->r_osd == NULL) { + dout("send_request %p no up osds in pg\n", req); + ceph_monc_request_next_osdmap(&osdc->client->monc); + } else { + __send_request(osdc, req); + } + rc = 0; out_unlock: mutex_unlock(&osdc->request_mutex);