From patchwork Fri Sep 7 14:50:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1423071 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 30FEF3FC33 for ; Fri, 7 Sep 2012 14:50:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933033Ab2IGOuQ (ORCPT ); Fri, 7 Sep 2012 10:50:16 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:54481 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932990Ab2IGOuP (ORCPT ); Fri, 7 Sep 2012 10:50:15 -0400 Received: by ieje11 with SMTP id e11so5147910iej.19 for ; Fri, 07 Sep 2012 07:50:14 -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=/eLK/ntiQ6RqGyieFRw/kFNjbobGIWxR3STpTkFQ0JY=; b=lLfqJ1fHOt4FWxsdMj3N2bSwCDyFGaZRbuMO5YxBeBwkTuUE+m84UhZiNV428J4f+z db1IVNV8eo4U94V8TmC+Qb3ArjVzWIua/MAfrZUIgTulV3QM1KK51CffeIJ5UHPtzX9+ 8MskL4karOdtPtFBjR+H4/5im/vLtGJOdBEYOwkHRnyHlxfuyPG/PsCfyDUy2d1vsROp KsCxXITT3reEhFI1jI4jmWBnoVjqpRjvfMeXaskbC2s4FKqiSKPMUpi86+JC13T6e7Rp JW7kQ7/In/FByYk+gUNjjjhBOMtst+ffmgNaYLIT45xds4BaMy+fyt/12DwKbuWdzVvj 18Pw== Received: by 10.50.1.204 with SMTP id 12mr9162818igo.56.1347029414829; Fri, 07 Sep 2012 07:50:14 -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 ua2sm13319601igb.7.2012.09.07.07.50.12 (version=SSLv3 cipher=OTHER); Fri, 07 Sep 2012 07:50:12 -0700 (PDT) Message-ID: <504A09A4.7050404@inktank.com> Date: Fri, 07 Sep 2012 09:50:12 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 1/4] rbd: move locking out of rbd_header_set_snap() References: <504A090F.7000706@inktank.com> In-Reply-To: <504A090F.7000706@inktank.com> X-Gm-Message-State: ALoCoQlj9uxe3SYwE9z4HnP3Vf6WYDOqGrn31Q23zRF81nNmIoF7yj9Br+xcxIojqSoeJizhnCxi Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Move the calls to get the header semaphore out of rbd_header_set_snap() and into its caller. Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) rbd_dev->mapping.snap_id = CEPH_NOSNAP; @@ -666,7 +664,6 @@ static int rbd_header_set_snap(struct rbd_device *rbd_dev, char *snap_name) ret = 0; done: - up_write(&rbd_dev->header_rwsem); return ret; } @@ -2608,7 +2605,9 @@ static ssize_t rbd_add(struct bus_type *bus, if (rc) goto err_out_bus; + down_write(&rbd_dev->header_rwsem); rc = rbd_header_set_snap(rbd_dev, snap_name); + up_write(&rbd_dev->header_rwsem); if (rc) goto err_out_bus; diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 634a16c..214c937 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -647,8 +647,6 @@ static int rbd_header_set_snap(struct rbd_device *rbd_dev, char *snap_name) { int ret; - down_write(&rbd_dev->header_rwsem); - if (!memcmp(snap_name, RBD_SNAP_HEAD_NAME, sizeof (RBD_SNAP_HEAD_NAME))) {