From patchwork Thu Jul 26 19:09:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1244281 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id F1F18DFFCE for ; Thu, 26 Jul 2012 19:09:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752189Ab2GZTJ3 (ORCPT ); Thu, 26 Jul 2012 15:09:29 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:34949 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752472Ab2GZTJ2 (ORCPT ); Thu, 26 Jul 2012 15:09:28 -0400 Received: by mail-gh0-f174.google.com with SMTP id r11so2366170ghr.19 for ; Thu, 26 Jul 2012 12:09:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=hpNOtI26d15FaPKO03q8ToLSEc/kGxv2HgxQsK20ITk=; b=aqrzDrTmVQB0e4Q410htJqdfcS1sQWBXYFZo4Ud5MgCJ/jxYRrs9tnPsYOFgx1RE8a ebn0W1J3x/PVFZUORlB6reQ8TR29OH6yUsxHtM/P/QXU4jhFkqUEQ04boviAzJ9W+8Xc 24qBHoJcym3N2EF8chqI6yUq0/Uqji3G5PrsfZCJDxlROxXG+EIOQ91h6eowDW2atF0e H0OZboKbweX9RjQnuQObiAi3/5DNdkkWZ+MFNjP2Rqlzx7JXeIp/gSLINq9bsJDdLV6N GmlWZ9CZcLArqUqVQTuwccHc+8AqGt9bYwFeoW15ZaVLWdFgBFje5qdNDaazkcDUwk+5 nULA== Received: by 10.236.136.39 with SMTP id v27mr17438663yhi.96.1343329768522; Thu, 26 Jul 2012 12:09:28 -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 x3sm34986yhd.9.2012.07.26.12.09.27 (version=SSLv3 cipher=OTHER); Thu, 26 Jul 2012 12:09:28 -0700 (PDT) Message-ID: <501195E7.2040104@inktank.com> Date: Thu, 26 Jul 2012 14:09:27 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 7/7] rbd: create rbd_refresh_header() References: <50119421.1090702@inktank.com> In-Reply-To: <50119421.1090702@inktank.com> X-Gm-Message-State: ALoCoQnvnjUAGN8lCbH1SnfD2/NcIDTb/YqzdnIO37EX1VPb/0Ianzoir7cezBlz0By81AIIuhoK Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Create a simple helper that handles the common case of calling __rbd_refresh_header() while holding the ctl_mutex. Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) " update snaps: %d\n", rbd_dev->major, rc); @@ -1746,6 +1744,17 @@ static int __rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver) return ret; } +static int rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver) +{ + int ret; + + mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); + ret = __rbd_refresh_header(rbd_dev, hver); + mutex_unlock(&ctl_mutex); + + return ret; +} + static int rbd_init_disk(struct rbd_device *rbd_dev) { struct gendisk *disk; @@ -1899,9 +1908,7 @@ static ssize_t rbd_image_refresh(struct device *dev, struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); int ret; - mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); - ret = __rbd_refresh_header(rbd_dev, NULL); - mutex_unlock(&ctl_mutex); + ret = rbd_refresh_header(rbd_dev, NULL); return ret < 0 ? ret : size; } @@ -2191,9 +2198,7 @@ static int rbd_init_watch_dev(struct rbd_device *rbd_dev) do { ret = rbd_req_sync_watch(rbd_dev); if (ret == -ERANGE) { - mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); - rc = __rbd_refresh_header(rbd_dev, NULL); - mutex_unlock(&ctl_mutex); + rc = rbd_refresh_header(rbd_dev, NULL); if (rc < 0) return rc; } diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 31be4ca..94d0745 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -240,7 +240,7 @@ static void rbd_put_dev(struct rbd_device *rbd_dev) put_device(&rbd_dev->dev); } -static int __rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver); +static int rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver); static int rbd_open(struct block_device *bdev, fmode_t mode) { @@ -1222,9 +1222,7 @@ static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data) dout("rbd_watch_cb %s notify_id=%lld opcode=%d\n", rbd_dev->header_name, notify_id, (int) opcode); - mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); - rc = __rbd_refresh_header(rbd_dev, &hver); - mutex_unlock(&ctl_mutex); + rc = rbd_refresh_header(rbd_dev, &hver); if (rc) pr_warning(RBD_DRV_NAME "%d got notification but failed to "