From patchwork Fri Jun 20 09:09:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 4387461 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 2D9A7BEEAA for ; Fri, 20 Jun 2014 09:10:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 51C7220306 for ; Fri, 20 Jun 2014 09:10:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73F42202AE for ; Fri, 20 Jun 2014 09:10:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965886AbaFTJKQ (ORCPT ); Fri, 20 Jun 2014 05:10:16 -0400 Received: from mail-la0-f50.google.com ([209.85.215.50]:61513 "EHLO mail-la0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965376AbaFTJJx (ORCPT ); Fri, 20 Jun 2014 05:09:53 -0400 Received: by mail-la0-f50.google.com with SMTP id pv20so2221100lab.9 for ; Fri, 20 Jun 2014 02:09:51 -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=l3884B4te0fk+POSl3D+ZQ3g0zXkdi/CpblqCJ6klMk=; b=ZwTo4yLe9jcT2jNUFd+P20eWTHIVuu3ef4bs1dWDUq3r4hSUlVqv4TtyJ4tyE/fYqL PxShIf8ox2uaPp9ertpHIfva2JG/qsWG+CpPT7JNFg9zju85yaO1vWLrdnI48jArCX2i diAPJjZzE7+dIF0fihel7/LUIoLQBcjMLOA+KPSl7q537cNcKk2Z+NvVHOV7+/IuNOlH D6oICcw1wXor1easypjFrATVWMOCcs2VEIR7mQ1zH8P1BU2zeul3PEzfjX3JeF4irpj7 OyVS65hItd/OTOCAJYIOlL7WKyPt5IUah4cMxDfngJIVEqQRllrEhvG4usgwqa23wEaJ eu6w== X-Gm-Message-State: ALoCoQkTmwFxPJbGVVxe9iQUz8kH9mZm6hg6N8UuK6hJyjSL1k71siiY4Z5jXI+xHayunmj/11JT X-Received: by 10.112.171.167 with SMTP id av7mr27787lbc.97.1403255391630; Fri, 20 Jun 2014 02:09:51 -0700 (PDT) Received: from localhost ([109.110.66.173]) by mx.google.com with ESMTPSA id an10sm3395090lac.4.2014.06.20.02.09.50 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 20 Jun 2014 02:09:51 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 2/4] libceph: introduce ceph_osdc_cancel_request() Date: Fri, 20 Jun 2014 13:09:41 +0400 Message-Id: <1403255383-5729-3-git-send-email-ilya.dryomov@inktank.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1403255383-5729-1-git-send-email-ilya.dryomov@inktank.com> References: <1403255383-5729-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 Introduce ceph_osdc_cancel_request() intended for canceling requests from the higher layers (rbd and cephfs). Because higher layers are in charge and are supposed to know what and when they are canceling, the request is not completed, only unref'ed and removed from the libceph data structures. Signed-off-by: Ilya Dryomov Reviewed-by: --- include/linux/ceph/osd_client.h | 1 + net/ceph/osd_client.c | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h index 94ec69672164..8ba70a213d97 100644 --- a/include/linux/ceph/osd_client.h +++ b/include/linux/ceph/osd_client.h @@ -341,6 +341,7 @@ static inline void ceph_osdc_put_request(struct ceph_osd_request *req) extern int ceph_osdc_start_request(struct ceph_osd_client *osdc, struct ceph_osd_request *req, bool nofail); +extern void ceph_osdc_cancel_request(struct ceph_osd_request *req); extern int ceph_osdc_wait_request(struct ceph_osd_client *osdc, struct ceph_osd_request *req); extern void ceph_osdc_sync(struct ceph_osd_client *osdc); diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 6b8c5e8c49ce..318d1c55485d 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -2431,6 +2431,24 @@ int ceph_osdc_start_request(struct ceph_osd_client *osdc, EXPORT_SYMBOL(ceph_osdc_start_request); /* + * Unregister a registered request. The request is not completed (i.e. + * no callbacks or wakeups) - higher layers are supposed to know what + * they are canceling. + */ +void ceph_osdc_cancel_request(struct ceph_osd_request *req) +{ + struct ceph_osd_client *osdc = req->r_osdc; + + mutex_lock(&osdc->request_mutex); + __cancel_request(req); + __unregister_request(osdc, req); + mutex_unlock(&osdc->request_mutex); + + dout("%s tid %llu canceled\n", __func__, req->r_tid); +} +EXPORT_SYMBOL(ceph_osdc_cancel_request); + +/* * wait for a request to complete */ int ceph_osdc_wait_request(struct ceph_osd_client *osdc, @@ -2440,12 +2458,9 @@ int ceph_osdc_wait_request(struct ceph_osd_client *osdc, rc = wait_for_completion_interruptible(&req->r_completion); if (rc < 0) { - mutex_lock(&osdc->request_mutex); - __cancel_request(req); - __unregister_request(osdc, req); - mutex_unlock(&osdc->request_mutex); + dout("%s tid %llu interrupted\n", __func__, req->r_tid); + ceph_osdc_cancel_request(req); complete_request(req); - dout("wait_request tid %llu canceled/timed out\n", req->r_tid); return rc; }