From patchwork Fri Feb 8 16:33:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2116961 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 EAD393FCA4 for ; Fri, 8 Feb 2013 16:33:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946739Ab3BHQdP (ORCPT ); Fri, 8 Feb 2013 11:33:15 -0500 Received: from mail-ie0-f169.google.com ([209.85.223.169]:57344 "EHLO mail-ie0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1946736Ab3BHQdO (ORCPT ); Fri, 8 Feb 2013 11:33:14 -0500 Received: by mail-ie0-f169.google.com with SMTP id 13so5340028iea.28 for ; Fri, 08 Feb 2013 08:33:13 -0800 (PST) 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=vQys3jbOfrDJQHoqEOHcWt8FDasuBYu33KSrWoaT7M4=; b=jTKYh/z1oLXPJ6yhDIcw/kjJDqR6w47QKQZ81Uy2eNc0pxttjsTGunA0YrWdDO592H D07A3jhMIMIfObtxVF78b32b+047hc4+FDDSzlwEMqA54C4A3fQSZj8OT7zo4pYmT3h0 61UgqQwpyrVFLjB40dayM/rah6tKtYkuRyT5/4oL9qgW9V1BaoX57I/L8BHZK3zVvlfl I2hodwroWN9ZJbp91pR64c3mQKJ+OTY2aYMyvd8EDZSq31L9qTxrj0SD4BoerAhMqd56 Xckr1QNuskCnL74rtV7RdiyTQ+2TMfHsCLQs5B65AkpFQcOAOUy2J5K4Thglca7xSzbH 5bgw== X-Received: by 10.50.88.226 with SMTP id bj2mr3355767igb.105.1360341193387; Fri, 08 Feb 2013 08:33:13 -0800 (PST) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPS id fa6sm15797691igb.2.2013.02.08.08.33.11 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Feb 2013 08:33:12 -0800 (PST) Message-ID: <511528C6.2030804@inktank.com> Date: Fri, 08 Feb 2013 10:33:10 -0600 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: "ceph-devel@vger.kernel.org" Subject: [PATCH 4/5] rbd: ignore result of ceph_copy_from_page_vector() References: <51152847.2030305@inktank.com> In-Reply-To: <51152847.2030305@inktank.com> X-Gm-Message-State: ALoCoQmGkqhinzOQQWhuED15049H3hvcnbFEr6Zlc1tYoqLc3T8t8HV0RDPzqmwDsNb+pnsV0Gzw Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org The result of ceph_copy_from_page_vector() is simply the length argument it is provided. This is called by rbd_obj_method_sync(), which returns the result if it's non-negative. But we always either ignore or overwrite that return value. So explicitly ignore what's returned by the copy function, and have rbd_obj_method_sync() always return either a negative errno or 0. We also return the result of ceph_copy_from_page_vector() in rbd_obj_read_sync(). There we still want to return the number of bytes transferred, but we can use the value we already have in hand rather than what ceph_copy_from_page_vector() provides. Signed-off-by: Alex Elder --- drivers/block/rbd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) *version = obj_request->version; @@ -2088,7 +2089,9 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev, rbd_assert(obj_request->xferred <= (u64) SIZE_MAX); size = (size_t) obj_request->xferred; - ret = ceph_copy_from_page_vector(pages, buf, 0, size); + (void) ceph_copy_from_page_vector(pages, buf, 0, size); + rbd_assert(size <= (size_t) INT_MAX); + ret = (int) size; if (version) *version = obj_request->version; out: @@ -2141,7 +2144,6 @@ rbd_dev_v1_header_read(struct rbd_device *rbd_dev, u64 *version) ret = rbd_obj_read_sync(rbd_dev, rbd_dev->header_name, 0, size, (char *) ondisk, version); - if (ret < 0) goto out_err; if (WARN_ON((size_t) ret < size)) { @@ -2803,7 +2805,6 @@ static int rbd_dev_v2_object_prefix(struct rbd_device *rbd_dev) dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret); if (ret < 0) goto out; - ret = 0; /* rbd_obj_method_sync() can return positive */ p = reply_buf; rbd_dev->header.object_prefix = ceph_extract_encoded_string(&p, @@ -3742,7 +3743,6 @@ static int rbd_dev_image_id(struct rbd_device *rbd_dev) dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret); if (ret < 0) goto out; - ret = 0; /* rbd_obj_method_sync() can return positive */ p = response; rbd_dev->spec->image_id = ceph_extract_encoded_string(&p, diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 99f1a29..958e733 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1889,7 +1889,8 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev, ret = obj_request->result; if (ret < 0) goto out; - ret = ceph_copy_from_page_vector(pages, inbound, 0, + ret = 0; + (void) ceph_copy_from_page_vector(pages, inbound, 0, obj_request->xferred); if (version)