From patchwork Sat May 11 17:47:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2554511 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 37159DF230 for ; Sat, 11 May 2013 17:47:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753240Ab3EKRrW (ORCPT ); Sat, 11 May 2013 13:47:22 -0400 Received: from mail-ie0-f173.google.com ([209.85.223.173]:41815 "EHLO mail-ie0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753110Ab3EKRrW (ORCPT ); Sat, 11 May 2013 13:47:22 -0400 Received: by mail-ie0-f173.google.com with SMTP id k5so10050844iea.4 for ; Sat, 11 May 2013 10:47:21 -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=HmnITJwdA52w72xlFepty/lKhRFGxMQ1qT9l0NXQ3+E=; b=IKN5xZnE+FdDf+1qfT1iSyLnj0zXKKp60256CYUWtoXjQqS0YWGkwiunLwJkWP9YNp ofB73JimR5JFMX+euXxsSb5FKn4lkP8fe9t6CXJGGrVcCggepNqLskVnCnHYK6Cd6v9C 8ASh7l4095vsqpyKxsN0RSJoVQ3hPEJqkxPb3Rwm/nbbivUeLN4o1f/2p7SkswOtP6kA I7bTMpqLtUn4z5XSFbzVOUgu5IXZZGV+ELMEQvj0UXs08TPZC3ijzvxKhUExp8PSCdR/ oWkpov7wDU3RGss3a/y5Q4c7diACP3sM7NAVqx91h3N948evGZYhAorJpYurLt/KWeoV NxAg== X-Received: by 10.50.128.134 with SMTP id no6mr5668561igb.10.1368294441737; Sat, 11 May 2013 10:47:21 -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 ESMTPSA id wx2sm6116856igb.4.2013.05.11.10.47.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 11 May 2013 10:47:21 -0700 (PDT) Message-ID: <518E8428.2060403@inktank.com> Date: Sat, 11 May 2013 12:47:20 -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 2/4] rbd: re-submit read request for flattened clone References: <518E83D3.4050709@inktank.com> In-Reply-To: <518E83D3.4050709@inktank.com> X-Gm-Message-State: ALoCoQmbiBTwXPkR9Wa69zHhJXAxIQVzGy64p9mwc5h5/kh80wrHDLxqDnwUsSGA9SAqGgbHmQMQ Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org If a clone image gets flattened while a parent read request is underway, the original rbd object request needs to be resubmitted. The reason is that by the time we get the response to the parent read request, the data read from the parent may be out of date. In other words, we could see this sequence of events: rbd client parent image/osd ---------- ---------------- original object ENOENT; issue parent read respond to parent read child image flattened original image header refresh <--- original object written independently here parent read response received Add code to rbd_img_parent_read_callback() to detect when a clone's parent image has disappeared (as evidenced by its parent overlap becoming 0), and re-submit the original read request in that case. Signed-off-by: Alex Elder --- drivers/block/rbd.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) @@ -2692,7 +2714,6 @@ static void rbd_img_parent_read_callback(struct rbd_img_request *img_request) */ rbd_assert(obj_request->img_offset < U64_MAX - obj_request->length); obj_end = obj_request->img_offset + obj_request->length; - rbd_dev = obj_request->img_request->rbd_dev; if (obj_end > rbd_dev->parent_overlap) { u64 xferred = 0; @@ -2700,12 +2721,11 @@ static void rbd_img_parent_read_callback(struct rbd_img_request *img_request) xferred = rbd_dev->parent_overlap - obj_request->img_offset; - obj_request->xferred = min(img_request->xferred, xferred); + obj_request->xferred = min(img_xferred, xferred); } else { - obj_request->xferred = img_request->xferred; + obj_request->xferred = img_xferred; } out: - rbd_img_request_put(img_request); rbd_img_obj_request_read_callback(obj_request); rbd_obj_request_complete(obj_request); } diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 6cd08ba..4dca3ce 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -2672,14 +2672,36 @@ static void rbd_img_parent_read_callback(struct rbd_img_request *img_request) struct rbd_obj_request *obj_request; struct rbd_device *rbd_dev; u64 obj_end; + u64 img_xferred; + int img_result; rbd_assert(img_request_child_test(img_request)); + /* First get what we need from the image request and release it */ + obj_request = img_request->obj_request; + img_xferred = img_request->xferred; + img_result = img_request->result; + rbd_img_request_put(img_request); + + /* + * If the overlap has become 0 (most likely because the + * image has been flattened) we need to re-submit the + * original request. + */ rbd_assert(obj_request); rbd_assert(obj_request->img_request); + rbd_dev = obj_request->img_request->rbd_dev; + if (!rbd_dev->parent_overlap) { + struct ceph_osd_client *osdc; + + osdc = &rbd_dev->rbd_client->client->osdc; + img_result = rbd_obj_request_submit(osdc, obj_request); + if (!img_result) + return; + } - obj_request->result = img_request->result; + obj_request->result = img_result; if (obj_request->result) goto out;