From patchwork Fri Apr 12 02:18:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2433921 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 16191DF230 for ; Fri, 12 Apr 2013 02:18:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752513Ab3DLCS3 (ORCPT ); Thu, 11 Apr 2013 22:18:29 -0400 Received: from mail-ia0-f182.google.com ([209.85.210.182]:33811 "EHLO mail-ia0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752461Ab3DLCS3 (ORCPT ); Thu, 11 Apr 2013 22:18:29 -0400 Received: by mail-ia0-f182.google.com with SMTP id u20so2001320iag.27 for ; Thu, 11 Apr 2013 19:18:28 -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=rpZf2RCwoIE2LkkMwjK350sDky4Ny7uGWq47Ou9Rf5Y=; b=LFdSyAB+KKQeJCojuhW0RDRyHayxYerWx5RLt4kEptgZpK5l0q9Bd+NZcS2Ua67c6K rUlU0cZJwCvHATPYJWtaCH9S0vKuQLNenefpN1DmrSj4jV6PA2z6vIvaDACCv14Ke+QL WCUim32F+ivEwOk/pOXM3SRD/hUhnsJo+i/wEgMD7UzXH2A52IKLKT21F2sxCCbgIhuu wDkWXJ+gF9IQSyASp7fvi4TU1gvgoU6d62e8NmnOXuox2tqbq+0zIHCviEpPQRrEdU3f DlW1isXBJj/WYlbTLfMgfOGvuY2gRTlw3lveZ0MM78wx6mBiCajU/bPynf4leCZcrooX DoQQ== X-Received: by 10.50.130.3 with SMTP id oa3mr414364igb.76.1365733108522; Thu, 11 Apr 2013 19:18:28 -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 dy5sm1138199igc.1.2013.04.11.19.18.27 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 11 Apr 2013 19:18:27 -0700 (PDT) Message-ID: <51676EF4.7010703@inktank.com> Date: Thu, 11 Apr 2013 21:18:28 -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 08/11] rbd: define an rbd object request flags field References: <51676E0F.2010504@inktank.com> In-Reply-To: <51676E0F.2010504@inktank.com> X-Gm-Message-State: ALoCoQk0CpRJ7s63Ams1YLzpX1VgE8EnnGPGh7tg7/owMMUe134xdlhoRQIT1CG8PCA/8ezd7a/U Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org We're going to need some more Boolean values for object requests, so create a flags bit field and use it to record whether the request is done. Signed-off-by: Alex Elder --- drivers/block/rbd.c | 58 +++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) * is conditionally set to 1 at image request initialization time @@ -1475,10 +1475,10 @@ static struct rbd_obj_request *rbd_obj_request_create(const char *object_name, obj_request->object_name = memcpy(name, object_name, size); obj_request->offset = offset; obj_request->length = length; + obj_request->flags = 0; obj_request->which = BAD_WHICH; obj_request->type = type; INIT_LIST_HEAD(&obj_request->links); - obj_request_done_init(obj_request); init_completion(&obj_request->completion); kref_init(&obj_request->kref); diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 2d27115..f7046e9 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -170,10 +170,15 @@ enum obj_request_type { OBJ_REQUEST_NODATA, OBJ_REQUEST_BIO, OBJ_REQUEST_PAGES }; +enum obj_req_flags { + OBJ_REQ_DONE, /* completion flag: not done = 0, done = 1 */ +}; + struct rbd_obj_request { const char *object_name; u64 offset; /* object start byte */ u64 length; /* bytes from offset */ + unsigned long flags; struct rbd_img_request *img_request; u64 img_offset; /* image relative offset */ @@ -194,7 +199,6 @@ struct rbd_obj_request { u64 xferred; /* bytes transferred */ u64 version; int result; - atomic_t done; rbd_obj_callback_t callback; struct completion completion; @@ -1072,6 +1076,29 @@ out_err: return NULL; } +/* + * The default/initial value for all object request flags is 0. For + * each flag, once its value is set to 1 it is never reset to 0 + * again. + */ +static void obj_request_done_set(struct rbd_obj_request *obj_request) +{ + if (test_and_set_bit(OBJ_REQ_DONE, &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 done\n", + obj_request); + } +} + +static bool obj_request_done_test(struct rbd_obj_request *obj_request) +{ + smp_mb(); + return test_bit(OBJ_REQ_DONE, &obj_request->flags) != 0; +} + static void rbd_obj_request_get(struct rbd_obj_request *obj_request) { dout("%s: obj %p (was %d)\n", __func__, obj_request, @@ -1192,33 +1219,6 @@ static int rbd_obj_request_wait(struct rbd_obj_request *obj_request) return wait_for_completion_interruptible(&obj_request->completion); } -static void obj_request_done_init(struct rbd_obj_request *obj_request) -{ - atomic_set(&obj_request->done, 0); - smp_wmb(); -} - -static void obj_request_done_set(struct rbd_obj_request *obj_request) -{ - int done; - - done = atomic_inc_return(&obj_request->done); - if (done > 1) { - 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 was already done\n", - obj_request); - } -} - -static bool obj_request_done_test(struct rbd_obj_request *obj_request) -{ - smp_mb(); - return atomic_read(&obj_request->done) != 0; -} - /* * The default/initial value for all image request flags is 0. Each