From patchwork Thu May 21 12:35:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 6454661 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8E981C0432 for ; Thu, 21 May 2015 12:35:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A86820459 for ; Thu, 21 May 2015 12:35:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A67C203ED for ; Thu, 21 May 2015 12:35:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755501AbbEUMfm (ORCPT ); Thu, 21 May 2015 08:35:42 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:38831 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755115AbbEUMfg (ORCPT ); Thu, 21 May 2015 08:35:36 -0400 Received: by wichy4 with SMTP id hy4so12252775wic.1 for ; Thu, 21 May 2015 05:35:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1DCEiQkzKZyD/EGfL2nwB9q+ecnzvvKWJvU8pziU71o=; b=FjKYyQIxFZhFQiEaVhlVYlpkV53tJG0/p+pOjiLk9txXJWsaUiUv8e0VbCRvHRFORm L3IvKKnf2a96w2N6SJB9E4Pecv673vAFlh2jdcnhb6EbL6P4sJSoz0+5hRpBFDifU9pv YHT2Qz3YMQoo3k5BmJ/DrAq3u8akdX5V7TGlFsjOOF3aPubqVYlXen0005zk7OegyeBK UwWPDjnx1gn2apwlPCz8k3PItmjpphwUYDNjABQRaY4wkVneBcSzDfUiv3QzfpMyZIdU OEoUJLeJSXsjc6mKXYBFxT7oGTooRBLRUUQ/cQB4tFZvSNnJTR7TwVKvRQe8BpR5DEEA AeXQ== X-Received: by 10.180.87.98 with SMTP id w2mr5917777wiz.94.1432211735389; Thu, 21 May 2015 05:35:35 -0700 (PDT) Received: from localhost.localdomain ([109.110.66.238]) by mx.google.com with ESMTPSA id gs7sm2682352wib.10.2015.05.21.05.35.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 May 2015 05:35:34 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Cc: Zheng Yan Subject: [PATCH v2 5/5] rbd: timeout watch teardown on unmap with mount_timeout Date: Thu, 21 May 2015 15:35:06 +0300 Message-Id: <1432211706-10473-6-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1432211706-10473-1-git-send-email-idryomov@gmail.com> References: <1432211706-10473-1-git-send-email-idryomov@gmail.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=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_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 As part of unmap sequence, kernel client has to talk to the OSDs to teardown watch on the header object. If none of the OSDs are available it would hang forever, until interrupted by a signal - when that happens we follow through with the rest of unmap procedure (i.e. unregister the device and put all the data structures) and the unmap is still considired successful (rbd cli tool exits with 0). The watch on the userspace side should eventually timeout so that's fine. This isn't very nice, because various userspace tools (pacemaker rbd resource agent, for example) then have to worry about setting up their own timeouts. Timeout it with mount_timeout (60 seconds by default). Signed-off-by: Ilya Dryomov Reviewed-by: Sage Weil Reviewed-by: Alex Elder --- drivers/block/rbd.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 992683b6b299..89fe8a4bc02e 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1563,22 +1563,39 @@ static void rbd_obj_request_end(struct rbd_obj_request *obj_request) /* * Wait for an object request to complete. If interrupted, cancel the * underlying osd request. + * + * @timeout: in jiffies, 0 means "wait forever" */ -static int rbd_obj_request_wait(struct rbd_obj_request *obj_request) +static int __rbd_obj_request_wait(struct rbd_obj_request *obj_request, + unsigned long timeout) { - int ret; + long ret; dout("%s %p\n", __func__, obj_request); - - ret = wait_for_completion_interruptible(&obj_request->completion); - if (ret < 0) { - dout("%s %p interrupted\n", __func__, obj_request); + ret = wait_for_completion_interruptible_timeout( + &obj_request->completion, + ceph_timeout_jiffies(timeout)); + if (ret <= 0) { + if (ret == 0) + ret = -ETIMEDOUT; rbd_obj_request_end(obj_request); - return ret; + } else { + ret = 0; } - dout("%s %p done\n", __func__, obj_request); - return 0; + dout("%s %p ret %d\n", __func__, obj_request, (int)ret); + return ret; +} + +static int rbd_obj_request_wait(struct rbd_obj_request *obj_request) +{ + return __rbd_obj_request_wait(obj_request, 0); +} + +static int rbd_obj_request_wait_timeout(struct rbd_obj_request *obj_request, + unsigned long timeout) +{ + return __rbd_obj_request_wait(obj_request, timeout); } static void rbd_img_request_complete(struct rbd_img_request *img_request) @@ -3122,6 +3139,7 @@ static struct rbd_obj_request *rbd_obj_watch_request_helper( bool watch) { struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; + struct ceph_options *opts = osdc->client->options; struct rbd_obj_request *obj_request; int ret; @@ -3148,7 +3166,7 @@ static struct rbd_obj_request *rbd_obj_watch_request_helper( if (ret) goto out; - ret = rbd_obj_request_wait(obj_request); + ret = rbd_obj_request_wait_timeout(obj_request, opts->mount_timeout); if (ret) goto out;