From patchwork Wed May 29 20:50:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2632671 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 354333FC23 for ; Wed, 29 May 2013 20:50:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966932Ab3E2UuG (ORCPT ); Wed, 29 May 2013 16:50:06 -0400 Received: from mail-ve0-f178.google.com ([209.85.128.178]:57998 "EHLO mail-ve0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966493Ab3E2UuF (ORCPT ); Wed, 29 May 2013 16:50:05 -0400 Received: by mail-ve0-f178.google.com with SMTP id pb11so5131951veb.23 for ; Wed, 29 May 2013 13:50:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=DiU+OMngsDwAY6npaLAmozD8JhMbhRxS3b2tTmzKanE=; b=iufBAvImUoOYEsIhqYRvcrH7OUeeI1lb44ux3TPcp2EYQ7EW5J44MuVtafTSl7HPI5 xQ2f4z1QjZzvIkuZ+4X3ORGG2PbLJ/xNc2L67Q0VOh9MwKTMFbmkYliGlXcqOKg9tOWF cN/LRzz+S4Ao+PmxF35jCvRUAoq8o7k0+4FqOEfwoZaaTBQSM8uZ9gfUe+y/rgCiFKM9 SIyKi2LHJ3I+0Amg5j6l5Y86XvTPkp0M0zQEetugd/Lk9HDnTY72tE3MNM7gexwjG2br 1wiDSzqiKuf/KGIlLNxLo8tntI1p00JkvUaNFjdOMJ97OdKstKLwUlszJCT3qulT3LK0 g/cA== X-Received: by 10.58.210.162 with SMTP id mv2mr2860379vec.11.1369860604563; Wed, 29 May 2013 13:50:04 -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 l5sm16842599vev.1.2013.05.29.13.50.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 May 2013 13:50:03 -0700 (PDT) Message-ID: <51A66A0A.3010909@inktank.com> Date: Wed, 29 May 2013 15:50:18 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH] rbd: clean up a few things in the refresh path X-Gm-Message-State: ALoCoQlQ4UwMhAgH55nJX2O1/lcGMx1C6fPpWa0Io0sqDtA7qGeL5QGoqOBx8bDqz5MZ2YXb0ZyJ Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org (This and the next two patches I'm about to post are available in the "review/wip-rbd" branch of the ceph-client git repository.) This includes a few relatively small fixes I found while examining the code that refreshes image information. This resolves: http://tracker.ceph.com/issues/5040 Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 53 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 10 deletions(-) } @@ -3356,8 +3356,8 @@ static int rbd_dev_refresh(struct rbd_device *rbd_dev) int ret; rbd_assert(rbd_image_format_valid(rbd_dev->image_format)); - mapping_size = rbd_dev->mapping.size; mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); + mapping_size = rbd_dev->mapping.size; if (rbd_dev->image_format == 1) ret = rbd_dev_v1_header_info(rbd_dev); else @@ -3830,6 +3830,7 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev) void *end; u64 pool_id; char *image_id; + u64 snap_id; u64 overlap; int ret; @@ -3889,24 +3890,56 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev) (unsigned long long)pool_id, U32_MAX); goto out_err; } - parent_spec->pool_id = pool_id; image_id = ceph_extract_encoded_string(&p, end, NULL, GFP_KERNEL); if (IS_ERR(image_id)) { ret = PTR_ERR(image_id); goto out_err; } - parent_spec->image_id = image_id; - ceph_decode_64_safe(&p, end, parent_spec->snap_id, out_err); + ceph_decode_64_safe(&p, end, snap_id, out_err); ceph_decode_64_safe(&p, end, overlap, out_err); - if (overlap) { - rbd_spec_put(rbd_dev->parent_spec); + /* + * The parent won't change (except when the clone is + * flattened, already handled that). So we only need to + * record the parent spec we have not already done so. + */ + if (!rbd_dev->parent_spec) { + parent_spec->pool_id = pool_id; + parent_spec->image_id = image_id; + parent_spec->snap_id = snap_id; rbd_dev->parent_spec = parent_spec; parent_spec = NULL; /* rbd_dev now owns this */ - rbd_dev->parent_overlap = overlap; - } else { - rbd_warn(rbd_dev, "ignoring parent of clone with overlap 0\n"); + } + + /* + * We always update the parent overlap. If it's zero we + * treat it specially. + */ + rbd_dev->parent_overlap = overlap; + smp_mb(); + if (!overlap) { + + /* A null parent_spec indicates it's the initial probe */ + + if (parent_spec) { + /* + * The overlap has become zero, so the clone + * must have been resized down to 0 at some + * point. Treat this the same as a flatten. + */ + rbd_dev_parent_put(rbd_dev); + pr_info("%s: clone image now standalone\n", + rbd_dev->disk->disk_name); + } else { + /* + * For the initial probe, if we find the + * overlap is zero we just pretend there was + * no parent image. + */ + rbd_warn(rbd_dev, "ignoring parent of " + "clone with overlap 0\n"); + } } out: ret = 0; diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index f860dd6..aec2438 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -2876,7 +2876,7 @@ static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data) (unsigned int)opcode); ret = rbd_dev_refresh(rbd_dev); if (ret) - rbd_warn(rbd_dev, ": header refresh error (%d)\n", ret); + rbd_warn(rbd_dev, "header refresh error (%d)\n", ret); rbd_obj_notify_ack(rbd_dev, notify_id);