From patchwork Fri Mar 24 18:08:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9643591 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9481360327 for ; Fri, 24 Mar 2017 18:10:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B5CA201BD for ; Fri, 24 Mar 2017 18:10:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8015C269DA; Fri, 24 Mar 2017 18:10:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 781F8201BD for ; Fri, 24 Mar 2017 18:10:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755531AbdCXSKn (ORCPT ); Fri, 24 Mar 2017 14:10:43 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:32857 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755408AbdCXSIv (ORCPT ); Fri, 24 Mar 2017 14:08:51 -0400 Received: by mail-qt0-f193.google.com with SMTP id r45so1427998qte.0 for ; Fri, 24 Mar 2017 11:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ShYM5NFT6URtq9koC7xkTolSght4CJ1CTaGn3vf3+os=; b=Vzngf6peBe18LY+zjHE4nqyGmS6Ba2/hIc1qrXoFXiEOEouT9ZfH4TEbpAiik7nKSr NyqnD0eHRaWQAPU928u4chfMk0O9MVWkr29Eu42T3sJSLeF3m7j8a/wRTHLghL/qpmO8 zE+le9PE4PRyQ4zpDzUfwNVccdw6dp7l6PNvsDuo3NgnXLZdsWvuslb1W9fRW0z6Z3Ir 4LwhUCv/HpfJxmvflb2Bqa/mpItwMx57I6isucGV0ybctW2i9uM4vLuGimtzpvnjxUZl xwltia6S7rPj3YjG4RsFuxg1Kc3Ehod2nmQqeTQmdp3n1ToUbSGzojsTfF+tuIRjzwA4 ACng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ShYM5NFT6URtq9koC7xkTolSght4CJ1CTaGn3vf3+os=; b=cL0BVavLHJyIoUb6KJ+2SkCYWSuB0Eq+Sx2+fqCJoRRSa7PWNRVrgZz4lnEKUTAcyi 0mI+O7ML4Lk38bIGc3O2lehGmGD2IsRdjZLWyLcswBzJV+ONTc0f6UKUX/mqFpRzt7S8 vKEpOipFQ15rGqZ8jYYWVy5TaNAPa81tXrbplzOAtBHtJ0yMPDOizD6LYVm+oTIHRx/c x6BI2YIRrhLO9M3KMP6z12KNa67E4KNm5Vwf4tJ/H4zMiDtrsKYRbM8FxCcyv2m+aGME N64eoc2Gv3lsNgIBAIzXjiPcWerdIXNUod1NAPCNNdKdg3JzgQaT0e+5G9aegAPWxFy3 ZP1Q== X-Gm-Message-State: AFeK/H2WC2p4l03BayBFX9R1BjSPPdotQZBQJTSKHCydZY3KJdEoxdTfWfMZmgxipnKE5A== X-Received: by 10.237.39.150 with SMTP id a22mr9013308qtd.233.1490378919678; Fri, 24 Mar 2017 11:08:39 -0700 (PDT) Received: from localhost (cpe-2606-A000-4381-1201-225-22FF-FEB3-E51A.dyn6.twc.com. [2606:a000:4381:1201:225:22ff:feb3:e51a]) by smtp.gmail.com with ESMTPSA id w63sm1998872qte.38.2017.03.24.11.08.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Mar 2017 11:08:39 -0700 (PDT) From: Josef Bacik To: axboe@kernel.dk, nbd-general@lists.sourceforge.net, linux-block@vger.kernel.org, kernel-team@fb.com Cc: Josef Bacik Subject: [PATCH 2/4] nbd: set rq->errors to actual error code Date: Fri, 24 Mar 2017 14:08:27 -0400 Message-Id: <1490378909-4056-3-git-send-email-josef@toxicpanda.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490378909-4056-1-git-send-email-josef@toxicpanda.com> References: <1490378909-4056-1-git-send-email-josef@toxicpanda.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Josef Bacik We've been relying on the block layer to assume rq->errors being set translates into -EIO. I noticed in testing that sometimes this isn't true, and really there's not much of a reason to have a counter instead of just using -EIO. So set it properly so we don't leak random numbers to unsuspecting victims. Signed-off-by: Josef Bacik --- drivers/block/nbd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 3d1fc37a..dbc22f4 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -192,7 +192,7 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req, dev_err(nbd_to_dev(nbd), "Connection timed out, shutting down connection\n"); set_bit(NBD_TIMEDOUT, &nbd->runtime_flags); - req->errors++; + req->errors = -EIO; mutex_lock(&nbd->config_lock); sock_shutdown(nbd); @@ -432,7 +432,7 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index) if (ntohl(reply.error)) { dev_err(disk_to_dev(nbd->disk), "Other side returned error (%d)\n", ntohl(reply.error)); - req->errors++; + req->errors = -EIO; return cmd; } @@ -448,7 +448,7 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index) if (result <= 0) { dev_err(disk_to_dev(nbd->disk), "Receive data failed (result %d)\n", result); - req->errors++; + req->errors = -EIO; return cmd; } dev_dbg(nbd_to_dev(nbd), "request %p: got %d bytes data\n", @@ -518,7 +518,7 @@ static void nbd_clear_req(struct request *req, void *data, bool reserved) if (!blk_mq_request_started(req)) return; cmd = blk_mq_rq_to_pdu(req); - req->errors++; + req->errors = -EIO; nbd_end_request(cmd); }