From patchwork Mon Dec 16 20:05:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 3356611 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B73D0C0D4A for ; Mon, 16 Dec 2013 20:06:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8847820219 for ; Mon, 16 Dec 2013 20:06:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 78214201F5 for ; Mon, 16 Dec 2013 20:06:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752131Ab3LPUG0 (ORCPT ); Mon, 16 Dec 2013 15:06:26 -0500 Received: from mail-ea0-f178.google.com ([209.85.215.178]:61593 "EHLO mail-ea0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751037Ab3LPUGZ (ORCPT ); Mon, 16 Dec 2013 15:06:25 -0500 Received: by mail-ea0-f178.google.com with SMTP id d10so2432619eaj.37 for ; Mon, 16 Dec 2013 12:06:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OHHFcu1nEt6PU8iS6DR6lGaqGCA6I68eNhoZKsXjfWE=; b=XT2WGP7PJ/3V737N0z7Gtu8cMerOet1th4i39KmjAb8ACs7fhlmuF3XgB1v1rSLks3 m8HVYqrD82ogmzRtt1KceyZ9mjsjk48ntly5dbFQMTsZU1Fz87NIrDz3lgfCeCZ09sEj QEVcd8RIGdHWOaD/OQmShwdxr1gNU+g3oRevlyxrJMHmUSBZnOtJw4x68Gkf1vJ1bbWe OeNhy4atkfy0Lk15cVFvX946VnMvyBOZQ1DDw8tYfANGfAJ8WULy48LFs/dD4kcQS9kw 7IURYbiH3K9wM8QFqj1odL2s34iciL8kCLnDlVIc7SeEJpEx+HWIDaJgN64wFbhrkhmt 2PMw== X-Gm-Message-State: ALoCoQn76G0oPZoIckBHvb1oABmAeG0e3cpVXH8gdBqv2CB4ic6Z08hlMbqBXRV7+XVPN6kH/2RH X-Received: by 10.14.6.136 with SMTP id 8mr18684643een.11.1387224384530; Mon, 16 Dec 2013 12:06:24 -0800 (PST) Received: from localhost ([109.110.66.47]) by mx.google.com with ESMTPSA id g47sm46044300eeo.19.2013.12.16.12.06.23 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 16 Dec 2013 12:06:23 -0800 (PST) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Cc: ilya.dryomov@inktank.com Subject: [PATCH 1/2] rbd: introduce rbd_dev_header_unwatch_sync() and switch to it Date: Mon, 16 Dec 2013 22:05:34 +0200 Message-Id: <1387224335-902-2-git-send-email-ilya.dryomov@inktank.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1387224335-902-1-git-send-email-ilya.dryomov@inktank.com> References: <1387224335-902-1-git-send-email-ilya.dryomov@inktank.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Rename rbd_dev_header_watch_sync() to __rbd_dev_header_watch_sync() and introduce two helpers: rbd_dev_header_{,un}watch_sync() to make it more clear what is going on. Signed-off-by: Ilya Dryomov --- drivers/block/rbd.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index cb1db2979d3d..c91108b760cf 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -2866,7 +2866,7 @@ static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data) * Request sync osd watch/unwatch. The value of "start" determines * whether a watch request is being initiated or torn down. */ -static int rbd_dev_header_watch_sync(struct rbd_device *rbd_dev, bool start) +static int __rbd_dev_header_watch_sync(struct rbd_device *rbd_dev, bool start) { struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; struct rbd_obj_request *obj_request; @@ -2941,6 +2941,22 @@ out_cancel: return ret; } +static int rbd_dev_header_watch_sync(struct rbd_device *rbd_dev) +{ + return __rbd_dev_header_watch_sync(rbd_dev, true); +} + +static void rbd_dev_header_unwatch_sync(struct rbd_device *rbd_dev) +{ + int ret; + + ret = __rbd_dev_header_watch_sync(rbd_dev, false); + if (ret) { + rbd_warn(rbd_dev, "unable to tear down watch request: %d\n", + ret); + } +} + /* * Synchronous osd object method call. Returns the number of bytes * returned in the outbound buffer, or a negative error code. @@ -4961,7 +4977,6 @@ static void rbd_dev_image_release(struct rbd_device *rbd_dev) static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping) { int ret; - int tmp; /* * Get the id from the image id object. Unless there's an @@ -4980,7 +4995,7 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping) goto err_out_format; if (mapping) { - ret = rbd_dev_header_watch_sync(rbd_dev, true); + ret = rbd_dev_header_watch_sync(rbd_dev); if (ret) goto out_header_name; } @@ -5007,12 +5022,8 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping) err_out_probe: rbd_dev_unprobe(rbd_dev); err_out_watch: - if (mapping) { - tmp = rbd_dev_header_watch_sync(rbd_dev, false); - if (tmp) - rbd_warn(rbd_dev, "unable to tear down " - "watch request (%d)\n", tmp); - } + if (mapping) + rbd_dev_header_unwatch_sync(rbd_dev); out_header_name: kfree(rbd_dev->header_name); rbd_dev->header_name = NULL; @@ -5191,16 +5202,14 @@ static ssize_t rbd_remove(struct bus_type *bus, if (ret < 0 || already) return ret; - ret = rbd_dev_header_watch_sync(rbd_dev, false); - if (ret) - rbd_warn(rbd_dev, "failed to cancel watch event (%d)\n", ret); - + rbd_dev_header_unwatch_sync(rbd_dev); /* * flush remaining watch callbacks - these must be complete * before the osd_client is shutdown */ dout("%s: flushing notifies", __func__); ceph_osdc_flush_notifies(&rbd_dev->rbd_client->client->osdc); + /* * Don't free anything from rbd_dev->disk until after all * notifies are completely processed. Otherwise