From patchwork Wed May 1 21:32:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2508901 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 682BA3FD85 for ; Wed, 1 May 2013 21:32:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932307Ab3EAVcp (ORCPT ); Wed, 1 May 2013 17:32:45 -0400 Received: from mail-ie0-f173.google.com ([209.85.223.173]:57052 "EHLO mail-ie0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758667Ab3EAVco (ORCPT ); Wed, 1 May 2013 17:32:44 -0400 Received: by mail-ie0-f173.google.com with SMTP id k5so2449805iea.4 for ; Wed, 01 May 2013 14:32:43 -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=OrGx/xRqTacSjGg6jqaC1V6i4lj+eo1s+ArWG4RlQPo=; b=H8fmCirsQjItoeXb+nca+xyWUuKM06BVVNvhvS4yiO3hjNvPVpWP9bbp8NtATi/keI s202/Bhp5BFpPxJbHvGAcb8PvasCwVvL5NMUwOIIZccwmFckXdWAdBQRoTZDUxKh8XPD yhknpnOY0HbjTbnoq7rRrFxQ8BXh1WdjmQmK+HYG8l0iwqNtWI6Ia5n+ONzevyy2n0Ko 5rKplxcNur0S6SL67AfMBju6G56QBYjmIz3LyNi1l1Js21yH75br2+P8j88HgYoCCSce nMkg38sfvZ6xk0z1iHPBiudYGW+LFDS+la+KwrBo7d+UoWsJkTj45iYO3EBlJoXfrqFm Zv4A== X-Received: by 10.50.106.52 with SMTP id gr20mr2548353igb.109.1367443963735; Wed, 01 May 2013 14:32:43 -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 o10sm5766714igh.2.2013.05.01.14.32.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 01 May 2013 14:32:42 -0700 (PDT) Message-ID: <518189F9.3070603@inktank.com> Date: Wed, 01 May 2013 16:32:41 -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 1/2] rbd: clear EXISTS flag if mapped snapshot disappears References: <51818945.1040002@inktank.com> In-Reply-To: <51818945.1040002@inktank.com> X-Gm-Message-State: ALoCoQmBlrzbnxK5xlsUyXdEJizF6SgxXYdsFKjDsgM61OYgNgk7WxKkIxO+46CT8xaERn+C38c3 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org This functionality inadvertently disappeared in the last patch. Image snapshots can get removed at just about any time. In particular it can disappear even if it is in use by an rbd client as a mapped image. The rbd client deals with such a disappearance by responding to new requests with ENXIO. This is implemented by each rbd device maintaining an EXISTS flag, which is normally set but cleared if a snapshot disappears. This patch (re-)implements the clearing of that flag. Whenever mapped image header information is refreshed, if the mapping is for a snapshot, verify the mapped snapshot is still present in the updated snapshot context. If it is not, clear the flag. It is not necessary to check this in the initial probe, because the probe will not succeed if the snapshot doesn't exist. This resolves: http://tracker.ceph.com/issues/4880 Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) u64 image_size; @@ -3126,6 +3145,10 @@ static int rbd_dev_refresh(struct rbd_device *rbd_dev) ret = rbd_dev_v1_refresh(rbd_dev); else ret = rbd_dev_v2_refresh(rbd_dev); + + /* If it's a mapped snapshot, validate its EXISTS flag */ + + rbd_exists_validate(rbd_dev); mutex_unlock(&ctl_mutex); if (ret) rbd_warn(rbd_dev, "got notification but failed to " diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 0ca959f..3f58aba 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -3114,6 +3114,25 @@ static int rbd_dev_v1_refresh(struct rbd_device *rbd_dev) return ret; } +/* + * Clear the rbd device's EXISTS flag if the snapshot it's mapped to + * has disappeared from the (just updated) snapshot context. + */ +static void rbd_exists_validate(struct rbd_device *rbd_dev) +{ + u64 snap_id; + + if (!test_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags)) + return; + + snap_id = rbd_dev->spec->snap_id; + if (snap_id == CEPH_NOSNAP) + return; + + if (rbd_dev_snap_index(rbd_dev, snap_id) == BAD_SNAP_INDEX) + clear_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); +} + static int rbd_dev_refresh(struct rbd_device *rbd_dev) {