From patchwork Fri Apr 12 02:18:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2433931 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 235C5DF230 for ; Fri, 12 Apr 2013 02:18:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752629Ab3DLCSk (ORCPT ); Thu, 11 Apr 2013 22:18:40 -0400 Received: from mail-ia0-f176.google.com ([209.85.210.176]:41136 "EHLO mail-ia0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750974Ab3DLCSk (ORCPT ); Thu, 11 Apr 2013 22:18:40 -0400 Received: by mail-ia0-f176.google.com with SMTP id o25so706576iad.7 for ; Thu, 11 Apr 2013 19:18:39 -0700 (PDT) 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=E4zmnBqlhwgPhF7sGRHf+hFbNji+XBG1Jq0sEoWPqI0=; b=n6z37wQG58J2fevaODpBPAJYBbk0QpeFvNE6ekNVU+sedmCxiMg4E1I/Z39PaHa1SV 54o+9HGkHTl5v605t3rfZfH30jD+OBssYUiW1bsmhiGfc331cMVPiudvJsPyvEErIms3 e9+IgbqtgdA15T9neT9qmVFSgJHCMTbd4TyZmrPLNCY3jJ1sx6DIXbm6/hw5MAvHWK6m stn1dUblJM1C8Lr/5nx3t6ULtJ8dG9evbRWEOlgVfCNiwihEO4prnmEu7tDOzleBBWAd fnkus/4GUSfkKwtL08Q3PEXCH5W5qJBwTWZT0NMbQQyKbAHjuU/N2H9nH41w5wN/vPWn 6RYg== X-Received: by 10.50.45.166 with SMTP id o6mr418571igm.78.1365733119477; Thu, 11 Apr 2013 19:18:39 -0700 (PDT) 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 a3sm1105366igq.5.2013.04.11.19.18.38 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 11 Apr 2013 19:18:38 -0700 (PDT) Message-ID: <51676EFF.60506@inktank.com> Date: Thu, 11 Apr 2013 21:18:39 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 09/11] rbd: add an object request flag for image data objects References: <51676E0F.2010504@inktank.com> In-Reply-To: <51676E0F.2010504@inktank.com> X-Gm-Message-State: ALoCoQnPHWT2JhUa5+Guma2felNWyfdWYRUHBwOzP9AvUyvqPQ/jIx90EsOrs6z4jeNpEo62bmfV Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Add a flag to distinguish between object requests being done on standalone objects and requests being sent for objects representing rbd image data (i.e., object requests that are the result of image request). Signed-off-by: Alex Elder --- drivers/block/rbd.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) dout("%s: obj %p (was %d)\n", __func__, obj_request, @@ -1139,6 +1158,8 @@ static inline void rbd_img_obj_request_add(struct rbd_img_request *img_request, rbd_obj_request_get(obj_request); obj_request->img_request = img_request; obj_request->which = img_request->obj_request_count; + rbd_assert(!obj_request_img_data_test(obj_request)); + obj_request_img_data_set(obj_request); rbd_assert(obj_request->which != BAD_WHICH); img_request->obj_request_count++; list_add_tail(&obj_request->links, &img_request->obj_requests); @@ -1158,6 +1179,7 @@ static inline void rbd_img_obj_request_del(struct rbd_img_request *img_request, 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_data_test(obj_request)); rbd_assert(obj_request->img_request == img_request); obj_request->img_request = NULL; obj_request->callback = NULL; @@ -1343,7 +1365,9 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req, dout("%s: osd_req %p msg %p\n", __func__, osd_req, msg); rbd_assert(osd_req == obj_request->osd_req); - rbd_assert(!!obj_request->img_request ^ + rbd_assert(obj_request_img_data_test(obj_request) ^ + !obj_request->img_request); + rbd_assert(obj_request_img_data_test(obj_request) ^ (obj_request->which == BAD_WHICH)); if (osd_req->r_result < 0) @@ -1413,12 +1437,13 @@ static struct ceph_osd_request *rbd_osd_req_create( bool write_request, struct rbd_obj_request *obj_request) { - struct rbd_img_request *img_request = obj_request->img_request; struct ceph_snap_context *snapc = NULL; struct ceph_osd_client *osdc; struct ceph_osd_request *osd_req; - if (img_request) { + if (obj_request_img_data_test(obj_request)) { + struct rbd_img_request *img_request = obj_request->img_request; + rbd_assert(write_request == img_request_write_test(img_request)); if (write_request) @@ -1605,10 +1630,13 @@ static void rbd_img_request_destroy(struct kref *kref) static bool rbd_img_obj_end_request(struct rbd_obj_request *obj_request) { - struct rbd_img_request *img_request = obj_request->img_request; + struct rbd_img_request *img_request; unsigned int xferred; int result; + rbd_assert(obj_request_img_data_test(obj_request)); + img_request = obj_request->img_request; + rbd_assert(!img_request_child_test(img_request)); rbd_assert(img_request->rq != NULL); @@ -1637,6 +1665,7 @@ static void rbd_img_obj_callback(struct rbd_obj_request *obj_request) u32 which = obj_request->which; bool more = true; + rbd_assert(obj_request_img_data_test(obj_request)); img_request = obj_request->img_request; dout("%s: img %p obj %p\n", __func__, img_request, obj_request); diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index f7046e9..3f162e2 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -172,6 +172,7 @@ enum obj_request_type { enum obj_req_flags { OBJ_REQ_DONE, /* completion flag: not done = 0, done = 1 */ + OBJ_REQ_IMG_DATA, /* object usage: standalone = 0, image = 1 */ }; struct rbd_obj_request { @@ -1099,6 +1100,24 @@ static bool obj_request_done_test(struct rbd_obj_request *obj_request) return test_bit(OBJ_REQ_DONE, &obj_request->flags) != 0; } +static void obj_request_img_data_set(struct rbd_obj_request *obj_request) +{ + if (test_and_set_bit(OBJ_REQ_IMG_DATA, &obj_request->flags)) { + struct rbd_img_request *img_request = obj_request->img_request; + struct rbd_device *rbd_dev; + + rbd_dev = img_request ? img_request->rbd_dev : NULL; + rbd_warn(rbd_dev, "obj_request %p already marked img_data\n", + obj_request); + } +} + +static bool obj_request_img_data_test(struct rbd_obj_request *obj_request) +{ + smp_mb(); + return test_bit(OBJ_REQ_IMG_DATA, &obj_request->flags) != 0; +} + static void rbd_obj_request_get(struct rbd_obj_request *obj_request) {