From patchwork Wed Jun 25 17:16:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 4422421 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 5447EBEEAA for ; Wed, 25 Jun 2014 17:17:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 771EB20394 for ; Wed, 25 Jun 2014 17:17:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A31002038D for ; Wed, 25 Jun 2014 17:17:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757683AbaFYRRT (ORCPT ); Wed, 25 Jun 2014 13:17:19 -0400 Received: from mail-la0-f41.google.com ([209.85.215.41]:52152 "EHLO mail-la0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757668AbaFYRRR (ORCPT ); Wed, 25 Jun 2014 13:17:17 -0400 Received: by mail-la0-f41.google.com with SMTP id hz20so1007735lab.28 for ; Wed, 25 Jun 2014 10:17:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=B0eydTUrTO+OxH7OdY42NBWJS49Iv1KeT5ikR396qUI=; b=T39y7tf4AFGXc1MtxrYeMgYvDX0/Ks0ncOA0OlqfudD/cWEE2UwzYRrJDfRFG+ldVN QXoumbnzh5+1P8LZMfwciiA7XjgLx6BKF9RIqeWChO18AJrKEsoTaQ8WEekCFFX0PCRh QuBqUuqm6hd+iXHoWTrELHXRRrj7dRDQ0d6hv6GCbJ5tbCphXbcEoS78MkqLQD3jFC2T 4A2hJR8V74Np6IcqvHRY3UdFzlDUN70yYmSIdDfcoQM5VuT/5tdVFUM1QmQikWK3Y+eq wctHSApz4UmiEK2RUKVf2DV0DcAp1sVqIlx7HeQQZjBNnY8seO3+PofzmCxXvpZswHNZ iGpQ== X-Gm-Message-State: ALoCoQnq+A3YWI4jwBOyDlMhXWg+WQRliotQT1XXZ2eC+RvNykqWKUZwB3e1IXOknHp5NUt7I5fu X-Received: by 10.112.51.37 with SMTP id h5mr6441318lbo.24.1403716635745; Wed, 25 Jun 2014 10:17:15 -0700 (PDT) Received: from localhost ([109.110.67.53]) by mx.google.com with ESMTPSA id ui5sm4216270lbb.32.2014.06.25.10.17.14 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 25 Jun 2014 10:17:14 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 10/14] rbd: rbd_obj_request_wait() should cancel the request if interrupted Date: Wed, 25 Jun 2014 21:16:43 +0400 Message-Id: <1403716607-13535-11-git-send-email-ilya.dryomov@inktank.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1403716607-13535-1-git-send-email-ilya.dryomov@inktank.com> References: <1403716607-13535-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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 rbd_obj_request_wait() should cancel the underlying OSD request if interrupted. Otherwise libceph will hold onto it indefinitely, causing assert failures or leaking the original object request. This also adds an rbd wrapper around ceph_osdc_cancel_request() to match rbd_obj_request_submit() and rbd_obj_request_wait(). Signed-off-by: Ilya Dryomov Reviewed-by: Alex Elder --- drivers/block/rbd.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index b2c98c1bc037..20147aec86f3 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1527,11 +1527,37 @@ static bool obj_request_type_valid(enum obj_request_type type) static int rbd_obj_request_submit(struct ceph_osd_client *osdc, struct rbd_obj_request *obj_request) { - dout("%s: osdc %p obj %p\n", __func__, osdc, obj_request); - + dout("%s %p\n", __func__, obj_request); return ceph_osdc_start_request(osdc, obj_request->osd_req, false); } +static void rbd_obj_request_end(struct rbd_obj_request *obj_request) +{ + dout("%s %p\n", __func__, obj_request); + ceph_osdc_cancel_request(obj_request->osd_req); +} + +/* + * Wait for an object request to complete. If interrupted, cancel the + * underlying osd request. + */ +static int rbd_obj_request_wait(struct rbd_obj_request *obj_request) +{ + int 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); + rbd_obj_request_end(obj_request); + return ret; + } + + dout("%s %p done\n", __func__, obj_request); + return 0; +} + static void rbd_img_request_complete(struct rbd_img_request *img_request) { @@ -1558,15 +1584,6 @@ static void rbd_img_request_complete(struct rbd_img_request *img_request) rbd_img_request_put(img_request); } -/* Caller is responsible for rbd_obj_request_destroy(obj_request) */ - -static int rbd_obj_request_wait(struct rbd_obj_request *obj_request) -{ - dout("%s: obj %p\n", __func__, obj_request); - - return wait_for_completion_interruptible(&obj_request->completion); -} - /* * The default/initial value for all image request flags is 0. Each * is conditionally set to 1 at image request initialization time