From patchwork Thu Jul 24 08:42:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 4615081 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 56C969F375 for ; Thu, 24 Jul 2014 08:43:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7497E20160 for ; Thu, 24 Jul 2014 08:43:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8EF47201BB for ; Thu, 24 Jul 2014 08:43:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934456AbaGXInT (ORCPT ); Thu, 24 Jul 2014 04:43:19 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:35307 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934274AbaGXInQ (ORCPT ); Thu, 24 Jul 2014 04:43:16 -0400 Received: by mail-lb0-f174.google.com with SMTP id c11so2009779lbj.19 for ; Thu, 24 Jul 2014 01:43:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=8NNgPS+Ps62FAWgqTAmV1LPZkde7lEnBcSp2WyXE6Mk=; b=PlsP1DL24zYZeZE6ztE5hyLIv8Y+DM8dzVfPrMY8hTYaf0U+4sZcauiV1I2vitmL9E omricW1Erg4dp3zVdVLS1bmTapRq2JrhNvbumU+MHDzvEQbyKMipEpmuRvj4k/ORBZSU /LqkMbkZDJ2OctiXK7qXmD4RAQeGPQIzl65InlykfCcf+KadydcwvwayESV0TKFAzElN rEZcvrP/iyuH0kVkrxgINjakXzk6PlmJYvbMXNJX3YZEJVHpMmdJkHKwsvTb5ttvKdfR HTK2Z3NmSmPdD2Q3xyWmx8WxzlAY/GUQseECYjFs3OUd6G4U2IL9qacQsTZEgeyFR5W4 tu4g== X-Gm-Message-State: ALoCoQmlPPrqbW2TH2c8q3FwDqCXM5qAAhIZVNL1oeMAJtzOU+UrNyj2XJKDr8qQr7jEw+iEdNTj X-Received: by 10.152.8.109 with SMTP id q13mr7732247laa.31.1406191395254; Thu, 24 Jul 2014 01:43:15 -0700 (PDT) Received: from localhost ([109.110.66.237]) by mx.google.com with ESMTPSA id e5sm3884765laf.3.2014.07.24.01.43.14 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 24 Jul 2014 01:43:14 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 8/8] rbd: take snap_id into account when reading in parent info Date: Thu, 24 Jul 2014 12:42:49 +0400 Message-Id: <1406191369-6746-9-git-send-email-ilya.dryomov@inktank.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1406191369-6746-1-git-send-email-ilya.dryomov@inktank.com> References: <1406191369-6746-1-git-send-email-ilya.dryomov@inktank.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If we are mapping a snapshot, we must read in the parent_overlap value of that snapshot instead of that of the base image. Not doing so may in particular result in us returning zeros instead of user data: # cat overlap-snap.sh #!/bin/bash rbd create --size 10 --image-format 2 foo FOO_DEV=$(rbd map foo) dd if=/dev/urandom of=/dev/rbd0 bs=1M &>/dev/null echo "Base image" dd if=$FOO_DEV bs=1 count=16 skip=$(((4 << 20) - 8)) 2>/dev/null | xxd rbd snap create foo@snap rbd snap protect foo@snap rbd clone foo@snap bar rbd snap create bar@snap BAR_DEV=$(rbd map bar@snap) echo "Snapshot" dd if=$BAR_DEV bs=1 count=16 skip=$(((4 << 20) - 8)) 2>/dev/null | xxd rbd resize --allow-shrink --size 4 bar echo "Snapshot after base image resize" dd if=$BAR_DEV bs=1 count=16 skip=$(((4 << 20) - 8)) 2>/dev/null | xxd # ./overlap-snap.sh Base image 0000000: e781 e33b d34b 2225 6034 2845 a2e3 36ed ...;.K"%`4(E..6. Snapshot 0000000: e781 e33b d34b 2225 6034 2845 a2e3 36ed ...;.K"%`4(E..6. Resizing image: 100% complete...done. Snapshot after base image resize 0000000: e781 e33b d34b 2225 0000 0000 0000 0000 ...;.K"%........ Even though bar@snap was taken with the old bar parent_overlap (8M), reads from bar@snap beyond the new bar parent_overlap (4M) return zeroes. Fix it. Signed-off-by: Ilya Dryomov Reviewed-by: Alex Elder --- drivers/block/rbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index c4606987e9d1..cbc89fa9a677 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -4020,7 +4020,7 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev) goto out_err; } - snapid = cpu_to_le64(CEPH_NOSNAP); + snapid = cpu_to_le64(rbd_dev->spec->snap_id); ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_name, "rbd", "get_parent", &snapid, sizeof (snapid),