From patchwork Mon Mar 3 15:38:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 3755031 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 849999F1EE for ; Mon, 3 Mar 2014 15:38:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A74D9203E3 for ; Mon, 3 Mar 2014 15:38:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BA51B203E5 for ; Mon, 3 Mar 2014 15:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754172AbaCCPi1 (ORCPT ); Mon, 3 Mar 2014 10:38:27 -0500 Received: from mail-ee0-f53.google.com ([74.125.83.53]:40699 "EHLO mail-ee0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754099AbaCCPi0 (ORCPT ); Mon, 3 Mar 2014 10:38:26 -0500 Received: by mail-ee0-f53.google.com with SMTP id e51so3098391eek.12 for ; Mon, 03 Mar 2014 07:38:25 -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:subject:date:message-id; bh=ryuKUay9edl75yALvOI6h9L9x43wn2yKHbBOORlVaeA=; b=HbIcIpTO+hf+pRLoOWPmdTTNwVtWx+AUSQD0i0QJT1pl6ouGm3IKX1lyLLbLqfI1AF ingHV7jak9t4guueblrQ08rN7YN28Hdt1Aebdt57VcZXnHwwRRH+u4JWemZnUKCmPxUD qJYZNH6G9NFyJN2YDEE5/ZoABW+yIqHxSBoOY7KL0tJLi2s+a2QxbdI7LygUwi0wlHBl R56Qd5i+t4g1mlKgrAkLI2/cWVgtYXQHmhDvw3EXq1M9i8M2ev16+NQBfRPzuZ+nedvK ghHovlFm6zaWk2eRmfVcM6DbsgryjUwshJ9GjrKhLTWjOYzSVqqNwOHALl+jhweTmkMd Xw4w== X-Gm-Message-State: ALoCoQnZDzPAyTguhl/xJG750KNSgjnL/5W55LltmdILPD90Lsa2JfqAQR4H/lD1JWx0azlO0QYo X-Received: by 10.14.205.3 with SMTP id i3mr39716567eeo.23.1393861105338; Mon, 03 Mar 2014 07:38:25 -0800 (PST) Received: from localhost ([109.110.66.27]) by mx.google.com with ESMTPSA id w6sm13469818eex.9.2014.03.03.07.38.24 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 03 Mar 2014 07:38:24 -0800 (PST) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH] rbd: fix error paths in rbd_img_request_fill() Date: Mon, 3 Mar 2014 17:38:22 +0200 Message-Id: <1393861102-5123-1-git-send-email-ilya.dryomov@inktank.com> X-Mailer: git-send-email 1.7.10.4 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, 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 Doing rbd_obj_request_put() in rbd_img_request_fill() error paths is not only insufficient, but also triggers an rbd_assert() in rbd_obj_request_destroy(): Assertion failure in rbd_obj_request_destroy() at line 1867: rbd_assert(obj_request->img_request == NULL); rbd_img_obj_request_add() adds obj_requests to the img_request, the opposite is rbd_img_obj_request_del(). Use it. While at it, commit 03507db631c94 ("rbd: fix buffer size for writes to images with snapshots") moved the call to rbd_img_obj_request_add() up, making the out_partial label bogus. Remove it. Fixes: http://tracker.ceph.com/issues/7327 Signed-off-by: Ilya Dryomov Reviewed-by: Alex Elder --- drivers/block/rbd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index b365e0dfccb6..53d492e83586 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -2191,6 +2191,7 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request, rbd_segment_name_free(object_name); if (!obj_request) goto out_unwind; + /* * set obj_request->img_request before creating the * osd_request so that it gets the right snapc @@ -2208,7 +2209,7 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request, clone_size, GFP_ATOMIC); if (!obj_request->bio_list) - goto out_partial; + goto out_unwind; } else { unsigned int page_count; @@ -2223,7 +2224,7 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request, osd_req = rbd_osd_req_create(rbd_dev, write_request, obj_request); if (!osd_req) - goto out_partial; + goto out_unwind; obj_request->osd_req = osd_req; obj_request->callback = rbd_img_obj_callback; @@ -2250,11 +2251,9 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request, return 0; -out_partial: - rbd_obj_request_put(obj_request); out_unwind: for_each_obj_request_safe(img_request, obj_request, next_obj_request) - rbd_obj_request_put(obj_request); + rbd_img_obj_request_del(img_request, obj_request); return -ENOMEM; }