From patchwork Sat Feb 16 16:34:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2151831 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 939333FD4F for ; Sat, 16 Feb 2013 16:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753600Ab3BPQeW (ORCPT ); Sat, 16 Feb 2013 11:34:22 -0500 Received: from mail-qa0-f48.google.com ([209.85.216.48]:58142 "EHLO mail-qa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753559Ab3BPQeV (ORCPT ); Sat, 16 Feb 2013 11:34:21 -0500 Received: by mail-qa0-f48.google.com with SMTP id j8so735045qah.0 for ; Sat, 16 Feb 2013 08:34:20 -0800 (PST) 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=uA9INVul1RoErufiGhBwHrg8chcZp1V5Nr50IugyJgk=; b=Rs2NEzzF3xGUl5YHrAutoLY+BBhx5uqbGo96OuBl7f7myJyrtXWJVJ0coWFQNQJZo2 oHDoiywMd4yIORu5XHvrESK3UrEG3GbdMsstFr0otf8iJk4C32C3D/JkdJk2HrTh0EcW 71eVffuN3K0Dnz1p8zGge7WoujF+02S9SRmcWP62Q/ihtx4U4esbAVjBaw+IaOEgT8jt 8nrvPx7uraD9jD7boIqtOFpEzrI8W0DG3BGestinQeHq7x+jEiceT/vP3tbqSPpTpeyp MyoAo7XIjokjlbpRhjoMW5D1jlDCTUXmZYCh7OODIfytHpOoh7mwuR5Ae2yXEtGtqL08 zpKg== X-Received: by 10.224.39.139 with SMTP id g11mr3211217qae.35.1361032460763; Sat, 16 Feb 2013 08:34:20 -0800 (PST) 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 gw9sm21213525qab.10.2013.02.16.08.34.18 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 16 Feb 2013 08:34:19 -0800 (PST) Message-ID: <511FB50A.6090604@inktank.com> Date: Sat, 16 Feb 2013 10:34:18 -0600 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 1/3] libceph: lock outside send_queued() References: <511FB4D9.7050009@inktank.com> In-Reply-To: <511FB4D9.7050009@inktank.com> X-Gm-Message-State: ALoCoQn1HpUjM78bvU0Oggo0bUhtMrHXqKMP9H40xjYseIQCINTwiqSLS6KahiXyAyPJDk5M5ZCw Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Two of the three callers of the osd client's send_queued() function already hold the osd client mutex and drop it before the call. Change send_queued() so it assumes the caller holds the mutex, and update all callers accordingly. Rename it __send_queued() to match the convention used elsewhere in the file with respect to the lock. Signed-off-by: Alex Elder --- net/ceph/osd_client.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) /* @@ -1058,8 +1055,8 @@ static void handle_timeout(struct work_struct *work) } __schedule_osd_timeout(osdc); + __send_queued(osdc); mutex_unlock(&osdc->request_mutex); - send_queued(osdc); up_read(&osdc->map_sem); } @@ -1397,7 +1394,9 @@ done: if (ceph_osdmap_flag(osdc->osdmap, CEPH_OSDMAP_FULL)) ceph_monc_request_next_osdmap(&osdc->client->monc); - send_queued(osdc); + mutex_lock(&osdc->request_mutex); + __send_queued(osdc); + mutex_unlock(&osdc->request_mutex); up_read(&osdc->map_sem); wake_up_all(&osdc->client->auth_wq); return; diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index d3e7513..edda070 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -23,7 +23,7 @@ static const struct ceph_connection_operations osd_con_ops; -static void send_queued(struct ceph_osd_client *osdc); +static void __send_queued(struct ceph_osd_client *osdc); static int __reset_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd); static void __register_request(struct ceph_osd_client *osdc, struct ceph_osd_request *req); @@ -554,8 +554,8 @@ static void osd_reset(struct ceph_connection *con) down_read(&osdc->map_sem); mutex_lock(&osdc->request_mutex); __kick_osd_requests(osdc, osd); + __send_queued(osdc); mutex_unlock(&osdc->request_mutex); - send_queued(osdc); up_read(&osdc->map_sem); } @@ -997,16 +997,13 @@ static void __send_request(struct ceph_osd_client *osdc, /* * Send any requests in the queue (req_unsent). */ -static void send_queued(struct ceph_osd_client *osdc) +static void __send_queued(struct ceph_osd_client *osdc) { struct ceph_osd_request *req, *tmp; - dout("send_queued\n"); - mutex_lock(&osdc->request_mutex); - list_for_each_entry_safe(req, tmp, &osdc->req_unsent, r_req_lru_item) { + dout("__send_queued\n"); + list_for_each_entry_safe(req, tmp, &osdc->req_unsent, r_req_lru_item) __send_request(osdc, req); - } - mutex_unlock(&osdc->request_mutex); }