From patchwork Sat Apr 27 12:18:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2497051 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 924893FC64 for ; Sat, 27 Apr 2013 12:18:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754944Ab3D0MSm (ORCPT ); Sat, 27 Apr 2013 08:18:42 -0400 Received: from mail-ia0-f173.google.com ([209.85.210.173]:60696 "EHLO mail-ia0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752637Ab3D0MSl (ORCPT ); Sat, 27 Apr 2013 08:18:41 -0400 Received: by mail-ia0-f173.google.com with SMTP id 21so1036074iay.32 for ; Sat, 27 Apr 2013 05:18:41 -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 :content-type:content-transfer-encoding:x-gm-message-state; bh=KWtF9LYo5JtvIPvbPErQ/YKWdGULRjdOCqs2V+dCmJQ=; b=A6WXznP/6iJ93Fh4DBCtLskJ7m+NkJbNpwEzR4SZ7z1IZwQ4ROJCfdnbv4NPz9+q92 y//tXohswtnLuaTU8rXBxnNqHZqIpEd2uLl7YD4IZB5M3r8zbV46u46H+j4eAh1vTASu aoli+S6gIS+FAdGnc0NFhh8KCRLuamnizIX684NdlB4QDqD+GsZeR2lgXH45ppQFrGjU dTrCd+hHHaIdxgQomZ9X+wn4KTkBiSVNycU+v6thZgvQV9jyGad+PWR40jMPQ3Uty0+Q aIGCFtYn3KjgdKQJkJ4xdeXfrfRPPs9NRq61EM2wz4q3xge1s846WDJws8bVUPFuuPJa Ehhw== X-Received: by 10.50.17.8 with SMTP id k8mr4162030igd.1.1367065121129; Sat, 27 Apr 2013 05:18:41 -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 c2sm7717611igv.1.2013.04.27.05.18.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 27 Apr 2013 05:18:40 -0700 (PDT) Message-ID: <517BC21F.4030002@inktank.com> Date: Sat, 27 Apr 2013 07:18:39 -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] rbd: fix a bug in resizing a mapping X-Gm-Message-State: ALoCoQmBLRyPg0bUpQT1sEn6UoVABdZh3115OZ/1ggJZnNzwpFIZHg0tfCmSUSTd26b5MAReLKTU Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org When a snapshot context update occurs, rbd_update_mapping_size() is called to set the capacity of the disk to record the updated size of the image in case it has changed. There's a bug though. The mapping size is in units of *bytes*. The code that updates the mapping size field is assigning a value that has been scaled down to *sectors*. Fix that. Also, check to see if the size has actually changed, and don't bother updating things (specifically, calling set_capacity()) if it has not. This resolves: http://tracker.ceph.com/issues/4833 Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) /* diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 5918e0b..37d9349 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -3034,15 +3034,17 @@ static void rbd_remove_all_snaps(struct rbd_device *rbd_dev) static void rbd_update_mapping_size(struct rbd_device *rbd_dev) { - sector_t size; - if (rbd_dev->spec->snap_id != CEPH_NOSNAP) return; - size = (sector_t) rbd_dev->header.image_size / SECTOR_SIZE; - dout("setting size to %llu sectors", (unsigned long long) size); - rbd_dev->mapping.size = (u64) size; - set_capacity(rbd_dev->disk, size); + if (rbd_dev->mapping.size != rbd_dev->header.image_size) { + sector_t size; + + rbd_dev->mapping.size = rbd_dev->header.image_size; + size = (sector_t)rbd_dev->mapping.size / SECTOR_SIZE; + dout("setting size to %llu sectors", (unsigned long long)size); + set_capacity(rbd_dev->disk, size); + } }