From patchwork Sat Apr 27 19:40:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2497431 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 F3659DF23A for ; Sat, 27 Apr 2013 19:40:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754594Ab3D0TkN (ORCPT ); Sat, 27 Apr 2013 15:40:13 -0400 Received: from mail-ia0-f180.google.com ([209.85.210.180]:56672 "EHLO mail-ia0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754461Ab3D0TkM (ORCPT ); Sat, 27 Apr 2013 15:40:12 -0400 Received: by mail-ia0-f180.google.com with SMTP id t4so3540989iag.25 for ; Sat, 27 Apr 2013 12:40:12 -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=HbvC3uLFJU+6OOfeXLu++7g/CSHxm28pXPyo8FyvWq4=; b=YZH93ZsBQebg4401I6nwQanOy/A6peGCgcqrQTAW7ybZ68NssYSzYSh/jPfugd9mPR jQlm97D7kt79y0ILxNTA8EkEMUV4YpN0DH2i1v42t1g+iD0Y0B8Lc9X8yUljkJs3m5yF Dp0D/CcBTNzI2xUvQejYMM5NOYd11oCIAje6jxLkTz8z19aRKify7pxpvM68Bs59oJnS Y/Fp2Dv5CkIy8aWMM0g6C5r+Weu5l1/J9Z6Ixtng7TX4aO3o04Kqq2q1m3QkGt/x4u22 7XqyqQV2PZfucPv10LdYVL9kfzgPD/ZiiCa3ulDOHpRUxpTjjYQS4vUjfgzxvve2+LVu n0pg== X-Received: by 10.50.78.162 with SMTP id c2mr4682780igx.11.1367091611952; Sat, 27 Apr 2013 12:40:11 -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 ESMTPSA id wx2sm10133070igb.4.2013.04.27.12.40.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 27 Apr 2013 12:40:11 -0700 (PDT) Message-ID: <517C299A.6030109@inktank.com> Date: Sat, 27 Apr 2013 14:40:10 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 5/5] rbd: set up watch in rbd_dev_probe_image() References: <517C2914.8030400@inktank.com> In-Reply-To: <517C2914.8030400@inktank.com> X-Gm-Message-State: ALoCoQkqhNcaf9VnOAwTH1j67AbaE+uT1GdpFOdf0BDQsxaSyX1wGmNaw5y8TolND3fbl3/G1T04 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Move setting up the watch request for an image so it's done in rbd_dev_probe_image() rather than rbd_dev_probe_finish(). Move it all the way up to before doing the initial probe. This avoids a potential race condition, in which we get (and use) the initial snapshot context for an image, and it gets changed between that time and the time we get the watch set up. This resolves: http://tracker.ceph.com/issues/3871 Signed-off-by: Alex Elder --- drivers/block/rbd.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) @@ -4767,7 +4763,6 @@ err_out_id: rbd_dev_id_put(rbd_dev); if (rbd_dev->parent); rbd_dev_remove_parent(rbd_dev); - (void)rbd_dev_header_watch_sync(rbd_dev, 0); return ret; } @@ -4824,12 +4819,16 @@ static int rbd_dev_probe_image(struct rbd_device *rbd_dev) if (ret) goto out_err; + ret = rbd_dev_header_watch_sync(rbd_dev, 1); + if (ret) + goto out_header_name; + if (rbd_dev->image_format == 1) ret = rbd_dev_v1_probe(rbd_dev); else ret = rbd_dev_v2_probe(rbd_dev); if (ret) - goto out_header_name; + goto err_out_watch; ret = rbd_dev_snaps_update(rbd_dev); if (ret) @@ -4841,7 +4840,7 @@ static int rbd_dev_probe_image(struct rbd_device *rbd_dev) ret = rbd_dev_probe_parent(rbd_dev); if (ret) - goto err_out_snaps; + goto err_out_watch; ret = rbd_dev_probe_finish(rbd_dev); if (ret) @@ -4857,6 +4856,8 @@ err_out_snaps: out_header_name: kfree(rbd_dev->header_name); rbd_dev->header_name = NULL; +err_out_watch: + (void)rbd_dev_header_watch_sync(rbd_dev, 0); out_err: kfree(rbd_dev->spec->image_id); rbd_dev->spec->image_id = NULL; diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 1832b6a..5fcf23f 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -4705,10 +4705,6 @@ static int rbd_dev_probe_finish(struct rbd_device *rbd_dev) { int ret; - ret = rbd_dev_header_watch_sync(rbd_dev, 1); - if (ret) - return ret; - /* generate unique id: find highest unique id, add one */ rbd_dev_id_get(rbd_dev);