From patchwork Fri Feb 22 17:17:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2176541 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B8C41DFABD for ; Fri, 22 Feb 2013 17:17:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757912Ab3BVRRI (ORCPT ); Fri, 22 Feb 2013 12:17:08 -0500 Received: from mail-ia0-f173.google.com ([209.85.210.173]:39247 "EHLO mail-ia0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757555Ab3BVRRG (ORCPT ); Fri, 22 Feb 2013 12:17:06 -0500 Received: by mail-ia0-f173.google.com with SMTP id h37so734438iak.4 for ; Fri, 22 Feb 2013 09:17:06 -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=sHbnaptmnt4mpLUFf35Xmo93/t3VVk6P48byWttQkTc=; b=J0p7UI/zSNNgQhGjvO+uZJ18AeJr1GWBJLvdnDYpDzTzTfWy6rEFetK+iQFH42YXAm 0zjXIkMP1GTn9OjI9toXiyZ+5BLNY9j40JY6getpThyxczYoB1ELJR4AmcwUrI5sAS9M J4DHBXfogTMxbwDrpCMfaKRGC0C1w3OphaZD155e1th/aXo4febvXxXNHROChfqaEWyJ Jqn33KSrI/7exX3vpwyyIMavivkjB4aDjUXDi+Jr8RIjDOos9kPyy0fg7akiQCUJkrNt S6LqXP7xLFJGP0IbYtJQyylRyJjCD2Xc4ZnbqwhYEmMhnFdtsLfoRIN21fyc4h0WCKYs kOXg== X-Received: by 10.50.108.235 with SMTP id hn11mr1157963igb.107.1361553426413; Fri, 22 Feb 2013 09:17:06 -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 ip8sm2220542igc.4.2013.02.22.09.17.04 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Feb 2013 09:17:05 -0800 (PST) Message-ID: <5127A80F.4040301@inktank.com> Date: Fri, 22 Feb 2013 11:17:03 -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 Subject: [PATCH] rbd: ignore zero-length requests References: <5127A7C1.3070609@inktank.com> In-Reply-To: <5127A7C1.3070609@inktank.com> X-Gm-Message-State: ALoCoQl2seurT6x8MCTtk5jznYBgT4oVp63TjX0iDkGSh4Jf68emrz4Ojw1IykHAjDXQyBO327u7 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org The old request code simply ignored zero-length requests. We should still operate that same way to avoid any changes in behavior. We can implement handling for special zero-length requests separately (see http://tracker.ceph.com/issues/4236). Add some assertions based on this new constraint. This resolves: http://tracker.ceph.com/issues/4237 Signed-off-by: Alex Elder --- drivers/block/rbd.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) unsigned int clone_size; @@ -1627,8 +1628,10 @@ static void rbd_img_obj_callback(struct rbd_obj_request *obj_request) bool more = true; img_request = obj_request->img_request; + rbd_assert(img_request != NULL); rbd_assert(img_request->rq != NULL); + rbd_assert(img_request->obj_request_count > 0); rbd_assert(which != BAD_WHICH); rbd_assert(which < img_request->obj_request_count); rbd_assert(which >= img_request->next_completion); @@ -1918,6 +1921,19 @@ static void rbd_request_fn(struct request_queue *q) /* Ignore any non-FS requests that filter through. */ if (rq->cmd_type != REQ_TYPE_FS) { + dout("%s: non-fs request type %d\n", __func__, + (int) rq->cmd_type); + __blk_end_request_all(rq, 0); + continue; + } + + /* Ignore/skip any zero-length requests */ + + offset = (u64) blk_rq_pos(rq) << SECTOR_SHIFT; + length = (u64) blk_rq_bytes(rq); + + if (!length) { + dout("%s: zero-length request\n", __func__); __blk_end_request_all(rq, 0); continue; } @@ -1947,9 +1963,6 @@ static void rbd_request_fn(struct request_queue *q) goto end_request; } - offset = (u64) blk_rq_pos(rq) << SECTOR_SHIFT; - length = (u64) blk_rq_bytes(rq); - result = -EINVAL; if (WARN_ON(offset && length > U64_MAX - offset + 1)) goto end_request; /* Shouldn't happen */ diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index b0eea3e..3cc003b 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1560,6 +1560,7 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request, image_offset = img_request->offset; rbd_assert(image_offset == bio_list->bi_sector << SECTOR_SHIFT); resid = img_request->length; + rbd_assert(resid > 0); while (resid) { const char *object_name;