From: Alex Elder <elder@ieee.org>
To: Ilya Dryomov <ilya.dryomov@inktank.com>, ceph-devel@vger.kernel.org
Subject: Re: [PATCH 8/8] rbd: take snap_id into account when reading in parent info
Date: Thu, 24 Jul 2014 13:43:35 -0500 [thread overview]
Message-ID: <53D153D7.7030804@ieee.org> (raw)
In-Reply-To: <1406191369-6746-9-git-send-email-ilya.dryomov@inktank.com>
On 07/24/2014 03:42 AM, Ilya Dryomov wrote:
> 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 <ilya.dryomov@inktank.com>
> ---
> 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);
Well that's just an outright bug. It's been there since the
original commit that added parent support:
86b00e0 rbd: get parent spec for version 2 images
Parent images *must* be snapshots, so this was never
right.
I bet that was hard to figure out...
Looks good.
Reviewed-by: Alex Elder <elder@linaro.org>
> ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_name,
> "rbd", "get_parent",
> &snapid, sizeof (snapid),
>
prev parent reply other threads:[~2014-07-24 18:43 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-24 8:42 [PATCH 0/8] wip-overlap Ilya Dryomov
2014-07-24 8:42 ` [PATCH 1/8] rbd: show the entire chain of parent images Ilya Dryomov
2014-07-24 12:31 ` Alex Elder
2014-07-24 12:45 ` Ilya Dryomov
2014-07-24 8:42 ` [PATCH 2/8] rbd: introduce rbd_dev_header_info() Ilya Dryomov
2014-07-24 12:34 ` Alex Elder
2014-07-24 8:42 ` [PATCH 3/8] rbd: remove unnecessary asserts in rbd_dev_image_probe() Ilya Dryomov
2014-07-24 12:40 ` Alex Elder
2014-07-24 8:42 ` [PATCH 4/8] rbd: split rbd_dev_spec_update() into two functions Ilya Dryomov
2014-07-24 12:55 ` Alex Elder
2014-07-24 8:42 ` [PATCH 5/8] rbd: harden rbd_dev_refresh() caller Ilya Dryomov
2014-07-24 13:09 ` Alex Elder
2014-07-24 8:42 ` [PATCH 6/8] rbd: update mapping size only on refresh Ilya Dryomov
2014-07-24 13:25 ` Alex Elder
2014-07-24 13:46 ` Ilya Dryomov
2014-07-24 15:10 ` Ilya Dryomov
2014-07-25 13:31 ` Alex Elder
2014-07-24 17:59 ` Alex Elder
2014-07-24 8:42 ` [PATCH 7/8] rbd: do not read in parent info before snap context Ilya Dryomov
2014-07-25 8:14 ` Alex Elder
2014-07-25 8:36 ` Ilya Dryomov
2014-07-25 12:46 ` Alex Elder
2014-07-24 8:42 ` [PATCH 8/8] rbd: take snap_id into account when reading in parent info Ilya Dryomov
2014-07-24 18:43 ` Alex Elder [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53D153D7.7030804@ieee.org \
--to=elder@ieee.org \
--cc=ceph-devel@vger.kernel.org \
--cc=ilya.dryomov@inktank.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.