From patchwork Tue Apr 16 03:38:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2447411 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 550A73FD40 for ; Tue, 16 Apr 2013 03:38:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935611Ab3DPDin (ORCPT ); Mon, 15 Apr 2013 23:38:43 -0400 Received: from mail-ia0-f169.google.com ([209.85.210.169]:59916 "EHLO mail-ia0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935355Ab3DPDin (ORCPT ); Mon, 15 Apr 2013 23:38:43 -0400 Received: by mail-ia0-f169.google.com with SMTP id h23so50498iae.0 for ; Mon, 15 Apr 2013 20:38:42 -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=drP+oyG28gZlFOnlyivBQdVdQMK78JkCaj2MN4G4I+k=; b=CiZTIeKAl4Kh4vbQOqMKK0S5x4abIkR6fAzZCKah4rw2Znn9JXPrRq8IVNYYTcwMBL QnKQQba6QE91DK5Pr/D9brqU43Zkl2GXcqU8PhYfMMxkw4rDzZsI8jLpj0aGqgRHNQ+L AAe4QX2CyfmkhPATk1FiT1oouDuc3dw2JE0Bsy/VpCYcMmM5smjiay+zzwDRBYuZAyZf If4b3q5iwPJJ8y55fPDtBE/+6Pwa6ObQDx0j2pczuTueNoGIih1XP8w5BKzJozZTFlzV rAY9n7QK0SLzIDKAW/OAXRBQU/PZzlo9nNtnBP+zVF/sIXpGld8X3XyssSASZR5Di9fE KhFQ== X-Received: by 10.50.108.45 with SMTP id hh13mr6851337igb.110.1366083522605; Mon, 15 Apr 2013 20:38:42 -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 qn10sm14048341igc.6.2013.04.15.20.38.40 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Apr 2013 20:38:41 -0700 (PDT) Message-ID: <516CC7C0.2070109@inktank.com> Date: Mon, 15 Apr 2013 22:38:40 -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 6/7] rbd: add target object existence flags References: <516CC6E4.6070307@inktank.com> In-Reply-To: <516CC6E4.6070307@inktank.com> X-Gm-Message-State: ALoCoQkD9L04hVXkx+V/elY1AW4oTIrRvwh53AFhn1qn5hzsCEknQBQqlilYvFFmUsh0UW16fzic Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org This creates two new flags for object requests to indicate what is known about the existence of the object to which a request is to be sent. The KNOWN flag will be true if the the EXISTS flag is meaningful. That is: KNOWN EXISTS ----- ------ 0 0 don't know whether the object exists 0 1 (no used/invalid) 1 0 object is known to not exist 1 0 object is known to exist This will be used in determining how to handle write requests for data objects for layered rbd images. Signed-off-by: Alex Elder --- drivers/block/rbd.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) dout("%s: obj %p (was %d)\n", __func__, obj_request, @@ -1623,6 +1656,10 @@ static struct rbd_img_request *rbd_img_request_create( INIT_LIST_HEAD(&img_request->obj_requests); kref_init(&img_request->kref); + (void) obj_request_existence_set; + (void) obj_request_known_test; + (void) obj_request_exists_test; + rbd_img_request_get(img_request); /* Avoid a warning */ rbd_img_request_put(img_request); /* TEMPORARY */ diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 211baa7f..b1b8ef8 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -173,6 +173,8 @@ 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 */ + OBJ_REQ_KNOWN, /* EXISTS flag valid: no = 0, yes = 1 */ + OBJ_REQ_EXISTS, /* target exists: no = 0, yes = 1 */ }; struct rbd_obj_request { @@ -1129,6 +1131,37 @@ static bool obj_request_done_test(struct rbd_obj_request *obj_request) return test_bit(OBJ_REQ_DONE, &obj_request->flags) != 0; } +/* + * This sets the KNOWN flag after (possibly) setting the EXISTS + * flag. The latter is set based on the "exists" value provided. + * + * Note that for our purposes once an object exists it never goes + * away again. It's possible that the response from two existence + * checks are separated by the creation of the target object, and + * the first ("doesn't exist") response arrives *after* the second + * ("does exist"). In that case we ignore the second one. + */ +static void obj_request_existence_set(struct rbd_obj_request *obj_request, + bool exists) +{ + if (exists) + set_bit(OBJ_REQ_EXISTS, &obj_request->flags); + set_bit(OBJ_REQ_KNOWN, &obj_request->flags); + smp_mb(); +} + +static bool obj_request_known_test(struct rbd_obj_request *obj_request) +{ + smp_mb(); + return test_bit(OBJ_REQ_KNOWN, &obj_request->flags) != 0; +} + +static bool obj_request_exists_test(struct rbd_obj_request *obj_request) +{ + smp_mb(); + return test_bit(OBJ_REQ_EXISTS, &obj_request->flags) != 0; +} + static void rbd_obj_request_get(struct rbd_obj_request *obj_request) {