From patchwork Wed Mar 27 14:28:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2350921 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 C7F4B3FD40 for ; Wed, 27 Mar 2013 14:28:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752685Ab3C0O2a (ORCPT ); Wed, 27 Mar 2013 10:28:30 -0400 Received: from mail-ie0-f178.google.com ([209.85.223.178]:54438 "EHLO mail-ie0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752538Ab3C0O23 (ORCPT ); Wed, 27 Mar 2013 10:28:29 -0400 Received: by mail-ie0-f178.google.com with SMTP id bn7so7766413ieb.23 for ; Wed, 27 Mar 2013 07:28:29 -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:cc :subject:content-type:content-transfer-encoding:x-gm-message-state; bh=4/TWPFnC0N7aKe4HBHFXBCGqQeKkPTjdpVNwD98GD9Y=; b=plNVDIhKnrNXjxt9WfntFNl+HPYfRbFuJYQWvks0hHS4nRPztp3t/Risc/M5C3nzmp V31xHzpcL8AyGYQkBqMCwgxNJl7TFAw8tYUSPbTrX7zEz4dhGcBxfRUePnXOKHkGUtQl PAbkdx4xljWHgP8jzUzs5KX2FzUK0d3VcGRwP396NnLmaZaWIhRJt9cEq0zPUIyrUF2u Ze350DqtuP/Qgs2dnfKpmht38w/JuEYj3A4m1DF9tyH7swPcemvTupmoUi3YbID7eW+w f8ihUSmhUq2Hl/OnH+6f+UK/vj5GcPEwaqPlRxZ21oShv31vCKF67NvopVmVt7yXnmhR Yw1A== X-Received: by 10.50.16.202 with SMTP id i10mr4448531igd.33.1364394509469; Wed, 27 Mar 2013 07:28:29 -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 ESMTPS id qn10sm6487830igc.6.2013.03.27.07.28.27 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 27 Mar 2013 07:28:28 -0700 (PDT) Message-ID: <5153020B.7050403@inktank.com> Date: Wed, 27 Mar 2013 09:28:27 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: "ceph-devel@vger.kernel.org" CC: Dan van der Ster Subject: [PATCH] rbd: don't zero-fill non-image object requests X-Gm-Message-State: ALoCoQlkZMOx9O7doAgv2V4L2znKygA7hqbG8IgEn4yE41V9WsDEGDQv7oqmrLmTOhrQG0QE8jmE Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org (This patch is available in the branch "review/wip-4559" in the ceph-client git repository.) A result of ENOENT from a read request for an object that's part of an rbd image indicates that there is a hole in that portion of the image. Similarly, a short read for such an object indicates that the remainder of the read should be interpreted a full read with zeros filling out the end of the request. This behavior is not correct for objects that are not backing rbd image data. Currently rbd_img_obj_request_callback() assumes it should be done for all objects. Change rbd_img_obj_request_callback() so it only does this zeroing for image objects. Encapsulate that special handling in its own function. Add an assertion that the image object request is a bio request, since we assume that (and we currently don't support any other types). Reported-by: Dan van der Ster Signed-off-by: Alex Elder --- drivers/block/rbd.c | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) dout("%s: obj %p cb %p\n", __func__, obj_request, @@ -1284,23 +1310,10 @@ static void rbd_osd_read_callback(struct rbd_obj_request *obj_request) { dout("%s: obj %p result %d %llu/%llu\n", __func__, obj_request, obj_request->result, obj_request->xferred, obj_request->length); - /* - * ENOENT means a hole in the object. We zero-fill the - * entire length of the request. A short read also implies - * zero-fill to the end of the request. Either way we - * update the xferred count to indicate the whole request - * was satisfied. - */ - if (obj_request->result == -ENOENT) { - zero_bio_chain(obj_request->bio_list, 0); - obj_request->result = 0; - obj_request->xferred = obj_request->length; - } else if (obj_request->xferred < obj_request->length && - !obj_request->result) { - zero_bio_chain(obj_request->bio_list, obj_request->xferred); - obj_request->xferred = obj_request->length; - } - obj_request_done_set(obj_request); + if (obj_request->img_request) + rbd_img_obj_request_read_callback(obj_request); + else + obj_request_done_set(obj_request); } static void rbd_osd_write_callback(struct rbd_obj_request *obj_request) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index cc74b2c..d54a045 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1264,6 +1264,32 @@ static bool obj_request_done_test(struct rbd_obj_request *obj_request) return atomic_read(&obj_request->done) != 0; } +static void +rbd_img_obj_request_read_callback(struct rbd_obj_request *obj_request) +{ + dout("%s: obj %p img %p result %d %llu/%llu\n", __func__, + obj_request, obj_request->img_request, obj_request->result, + obj_request->xferred, obj_request->length); + /* + * ENOENT means a hole in the image. We zero-fill the + * entire length of the request. A short read also implies + * zero-fill to the end of the request. Either way we + * update the xferred count to indicate the whole request + * was satisfied. + */ + BUG_ON(obj_request->type != OBJ_REQUEST_BIO); + if (obj_request->result == -ENOENT) { + zero_bio_chain(obj_request->bio_list, 0); + obj_request->result = 0; + obj_request->xferred = obj_request->length; + } else if (obj_request->xferred < obj_request->length && + !obj_request->result) { + zero_bio_chain(obj_request->bio_list, obj_request->xferred); + obj_request->xferred = obj_request->length; + } + obj_request_done_set(obj_request); +} + static void rbd_obj_request_complete(struct rbd_obj_request *obj_request) {