From patchwork Sat Jan 26 20:41:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2050311 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id C71D53FCDE for ; Sat, 26 Jan 2013 20:41:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754320Ab3AZUlL (ORCPT ); Sat, 26 Jan 2013 15:41:11 -0500 Received: from mail-ia0-f175.google.com ([209.85.210.175]:54190 "EHLO mail-ia0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754305Ab3AZUlK (ORCPT ); Sat, 26 Jan 2013 15:41:10 -0500 Received: by mail-ia0-f175.google.com with SMTP id r4so2374700iaj.6 for ; Sat, 26 Jan 2013 12:41:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=lg+fNgzN0zLTk6FOwft7odQL+LfsxFGzsxLiaAGuH8I=; b=fe7hK5Xf4Crmramqol/LruwmYYClR9wRWo0DPa0H4S6tNPtmoWmF7+M2TR1JuxyAkD qTLe8OuKzeMWEJ0gzoDXwMh4zvOn9vSUUBYR6WSbyFgji88FH8icWDAQSMDPqbkPt00Q MSjmKPHKdf/3xjtA0FeKkTzGJ7FvK6SIEtYhgZMeBqDeGJEQweeutuvccybLPhuQXxcd daIS/yBG81t1gqvxW6YhQvHv+M2kwCV3hQGjS/hnFqrcsAO1DdJpj9lnYhtu+wB+BhkN Wi9OdWFGVCVTEU5njMONJYvkI1DS2tDT0H+US8E22Qdh92dlpRKuIIykIMikb0Yclj8g wJdA== X-Received: by 10.42.212.4 with SMTP id gq4mr5887392icb.38.1359232869424; Sat, 26 Jan 2013 12:41:09 -0800 (PST) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPS id fa6sm2393265igb.2.2013.01.26.12.41.07 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 26 Jan 2013 12:41:08 -0800 (PST) Message-ID: <51043F64.6020800@inktank.com> Date: Sat, 26 Jan 2013 14:41:08 -0600 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: "ceph-devel@vger.kernel.org" Subject: [PATCH 3/4] rbd: decrement obj request count when deleting References: <51043EF2.4070305@inktank.com> In-Reply-To: <51043EF2.4070305@inktank.com> X-Gm-Message-State: ALoCoQlVzrE+W9d/qf/cOrLXVq7orT/DNebdAf5Ksd05iYo7JGgX9QtLqB8StkkXUHB10FpT9MNZ Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Decrement the obj_request_count value when deleting an object request from its image request's list. Rearrange a few lines in the surrounding code. Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) rbd_obj_request_put(obj_request); } @@ -1482,6 +1489,7 @@ static void rbd_img_request_destroy(struct kref *kref) for_each_obj_request_safe(img_request, obj_request, next_obj_request) rbd_img_obj_request_del(img_request, obj_request); + rbd_assert(img_request->obj_request_count == 0); if (img_request->write_request) ceph_put_snap_context(img_request->snapc); diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 4e78402..340773f 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1071,22 +1071,29 @@ static void rbd_img_request_put(struct rbd_img_request *img_request) static inline void rbd_img_obj_request_add(struct rbd_img_request *img_request, struct rbd_obj_request *obj_request) { + rbd_assert(obj_request->img_request == NULL); + rbd_obj_request_get(obj_request); obj_request->img_request = img_request; - list_add_tail(&obj_request->links, &img_request->obj_requests); - obj_request->which = img_request->obj_request_count++; + obj_request->which = img_request->obj_request_count; rbd_assert(obj_request->which != BAD_WHICH); + img_request->obj_request_count++; + list_add_tail(&obj_request->links, &img_request->obj_requests); } static inline void rbd_img_obj_request_del(struct rbd_img_request *img_request, struct rbd_obj_request *obj_request) { rbd_assert(obj_request->which != BAD_WHICH); - obj_request->which = BAD_WHICH; + list_del(&obj_request->links); + rbd_assert(img_request->obj_request_count > 0); + img_request->obj_request_count--; + rbd_assert(obj_request->which == img_request->obj_request_count); + obj_request->which = BAD_WHICH; rbd_assert(obj_request->img_request == img_request); - obj_request->callback = NULL; obj_request->img_request = NULL; + obj_request->callback = NULL;