From patchwork Mon Sep 19 17:03:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9339919 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A30C8607D0 for ; Mon, 19 Sep 2016 17:03:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9075F295C9 for ; Mon, 19 Sep 2016 17:03:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85491295D8; Mon, 19 Sep 2016 17:03:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F597295C9 for ; Mon, 19 Sep 2016 17:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752585AbcISRDw (ORCPT ); Mon, 19 Sep 2016 13:03:52 -0400 Received: from mail-yw0-f195.google.com ([209.85.161.195]:33669 "EHLO mail-yw0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752378AbcISRDs (ORCPT ); Mon, 19 Sep 2016 13:03:48 -0400 Received: by mail-yw0-f195.google.com with SMTP id g192so8608277ywh.0 for ; Mon, 19 Sep 2016 10:03:48 -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=oRugLH8zrRAKPPdGCq7E/aBCPh/MkbTJ00MN3nUg/iM=; b=rPFHQenuDxCC8/tiIMEWD8NCvHFW7RxiU8MN/1WksLu+QhgIY6Seh9iAtNW6haN42o WxPPaKWVeREniDoSWadHn1/Aon/6R2Fzksx1MeKiR4Brg8TsX9k/KdaO1rZGKcO1C6Wy c01/AIs9jXR0ebzCkrj206a5fq/dXJ2OQnnYXOPSJGymh+qM/O801lhKeCluKxu1slHZ axDIAjAmHM5JIyaY42L536YmYYBbRCqeUNq8VUodwx/sKNlP3ogqsfBAmUGhT29/2F16 HCiuGkLRAwhULYgfEpKoUcAFFomZUkKqdlfMY5vFzfN1KjMgVFah++cLOWbLCEAn42jG 5JBg== 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=oRugLH8zrRAKPPdGCq7E/aBCPh/MkbTJ00MN3nUg/iM=; b=BkZve/EF7dXgHgJOmxLDhthCg40uiox5pghX6xjwqdEw2Y7TX77FPxG/zcCjBIExDU mLxwWEId1Z9uu4J3C/FJAOS/9Gxj1y3UeRjtHkNMp4FCb+5VeEl/bGNktq0ugWVqknaH FpoGiAKxVgt5UNlRQwR/rHtGo2nDPaz24Zo/ncXSlfw8LQJAWlgzSgucZIrAfvBu5FKt 4v/y6ACvinh1Ivg5O+5lfEgsWFkxYYnKK+/wokZ5M36MI+S6NQu0AdxOSKZ6hTmMnMeg muqUKRhrUDzvXkt05Q0id6SLzONIaPa/Ezg7ur5ZwhjEyN7HCjAyep4QYd7+f3Nbz/Ll 5RUA== X-Gm-Message-State: AE9vXwPlg1YfD+pcJF+ccgLf1yNj4M7tUF3w8MsjicFPjgzig9AhOR54Wne7U67sMJ2ilQ== X-Received: by 10.129.115.133 with SMTP id o127mr27277341ywc.42.1474304627451; Mon, 19 Sep 2016 10:03:47 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id o14sm9773905ywd.3.2016.09.19.10.03.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Sep 2016 10:03:46 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Cc: Alex Elder Subject: [PATCH 4/8] rbd: move bumping img_request refcount into rbd_obj_request_submit() Date: Mon, 19 Sep 2016 19:03:24 +0200 Message-Id: <1474304608-17958-5-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1474304608-17958-1-git-send-email-idryomov@gmail.com> References: <1474304608-17958-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-Virus-Scanned: ClamAV using ClamSMTP Commit 0f2d5be792b0 ("rbd: use reference counts for image requests") added rbd_img_request_get(), which rbd_img_request_fill() calls for each obj_request added to img_request. It was an urgent band-aid for the uglyness that is rbd_img_obj_callback() and none of the error paths were updated. Given that this img_request reference is meant to represent an obj_request that hasn't passed through rbd_img_obj_callback() yet, proper cleanup in appropriate destructors is a challenge. However, noting that if we don't get a chance to call rbd_obj_request_complete(), there is not going to be a call to rbd_img_obj_callback(), we can move rbd_img_request_get() into rbd_obj_request_submit() and fixup the two places that call rbd_obj_request_complete() directly and not through rbd_obj_request_submit() to temporarily bump img_request, so that rbd_img_obj_callback() can put as usual. This takes care of img_request leaks on errors on the submit side. Signed-off-by: Ilya Dryomov Reviewed-by: Alex Elder --- drivers/block/rbd.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index b247200a0f28..d8070bd29fd1 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1610,11 +1610,17 @@ static bool obj_request_type_valid(enum obj_request_type type) } } +static void rbd_img_obj_callback(struct rbd_obj_request *obj_request); + static void rbd_obj_request_submit(struct rbd_obj_request *obj_request) { struct ceph_osd_request *osd_req = obj_request->osd_req; dout("%s %p osd_req %p\n", __func__, obj_request, osd_req); + if (obj_request_img_data_test(obj_request)) { + WARN_ON(obj_request->callback != rbd_img_obj_callback); + rbd_img_request_get(obj_request->img_request); + } ceph_osdc_start_request(osd_req->r_osdc, osd_req, false); } @@ -2580,8 +2586,6 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request, rbd_img_obj_request_fill(obj_request, osd_req, op_type, 0); - rbd_img_request_get(img_request); - img_offset += length; resid -= length; } @@ -2715,10 +2719,9 @@ rbd_img_obj_parent_read_full_callback(struct rbd_img_request *img_request) return; out_err: - /* Record the error code and complete the request */ - orig_request->result = img_result; orig_request->xferred = 0; + rbd_img_request_get(orig_request->img_request); obj_request_done_set(orig_request); rbd_obj_request_complete(orig_request); } @@ -2873,6 +2876,7 @@ static void rbd_img_obj_exists_callback(struct rbd_obj_request *obj_request) fail_orig_request: orig_request->result = result; orig_request->xferred = 0; + rbd_img_request_get(orig_request->img_request); obj_request_done_set(orig_request); rbd_obj_request_complete(orig_request); }