From patchwork Tue Oct 30 23:06:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 10661797 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E31EB14DE for ; Tue, 30 Oct 2018 23:06:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D271628CCE for ; Tue, 30 Oct 2018 23:06:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C519B2A779; Tue, 30 Oct 2018 23:06: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 78E3828CCE for ; Tue, 30 Oct 2018 23:06:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728643AbeJaICF (ORCPT ); Wed, 31 Oct 2018 04:02:05 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34907 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728641AbeJaICF (ORCPT ); Wed, 31 Oct 2018 04:02:05 -0400 Received: by mail-pf1-f193.google.com with SMTP id z2-v6so4029975pfe.2 for ; Tue, 30 Oct 2018 16:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HqkIIj+yPtVDWhA7Dl1mMunLg/jddgwc20rm34UXfPk=; b=QKQBOXPGrfBIc5BMpy9JSoIu75TeQDveLZ3FwTHPY3hbfwqx7y9+mRFcOP3ww0GnEF ATV3k2O/MoEMxQWG1TnqxNhKpD3e+R0+C4qnqTrdSwL8GNfuUB+zqNNsjROfLywXp/YX keDUhP/QZGbolG7Rcjwxff85X7VKa7piufgzk= 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=HqkIIj+yPtVDWhA7Dl1mMunLg/jddgwc20rm34UXfPk=; b=TdTVK4vXHgwS/zGzVmVGClR5phH0CiWnSDMoLHmM1o2GPdeUCglVZXxynAedZ0/qRV U/GhWSaHj1kJ9puH9uq33w2/YABciUdiIaxJPhWJHFoV+vD1fOGBoabJp2CelRNJdfrb FQJ8HdE4XQhnVplsArdTc5UuE6F+REu62ngDY2OLwGNr6DSkHwlkzpxUpnrrSzDjDYPe RNt+uI1QdgE7K+lXBxFz2d0X+hxoqE22cKnqiUNbnUYzc1W4LEWFvsDYkXDyOk+sinip f6fdyQcpMe8EFZoX79AHMztdvdpV/bTUfjksMk50e7hMO1AZ4d2utWZUStV4MTJAdvJo rSjA== X-Gm-Message-State: AGRZ1gIrtJYnVr4i2W/blmN4He9NxSnLjCzRYHdfErVymRIKSwNNfQYQ ouWvDKCip9B/afU5RjscfTI2XQ== X-Google-Smtp-Source: AJdET5exaX9NP66IdYrFbmITcfg/g2cQ+L3CyDu1Cj2se23A/hl/hPrjkn43bSWTE+FAn1Knb2YbOQ== X-Received: by 2002:a62:968a:: with SMTP id s10-v6mr663408pfk.191.1540940798380; Tue, 30 Oct 2018 16:06:38 -0700 (PDT) Received: from evgreen2.mtv.corp.google.com ([2620:15c:202:201:e418:c825:76cf:5f64]) by smtp.gmail.com with ESMTPSA id z15-v6sm27953490pfn.170.2018.10.30.16.06.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Oct 2018 16:06:37 -0700 (PDT) From: Evan Green To: Jens Axboe Cc: Gwendal Grignou , Alexis Savery , Evan Green , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] loop: Report EOPNOTSUPP properly Date: Tue, 30 Oct 2018 16:06:23 -0700 Message-Id: <20181030230624.61834-2-evgreen@chromium.org> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20181030230624.61834-1-evgreen@chromium.org> References: <20181030230624.61834-1-evgreen@chromium.org> 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 Properly plumb out EOPNOTSUPP from loop driver operations, which may get returned when for instance a discard operation is attempted but not supported by the underlying block device. Before this change, everything was reported in the log as an I/O error, which is scary and not helpful in debugging. Signed-off-by: Evan Green Reviewed-by: Ming Lei --- drivers/block/loop.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index abad6d15f9563..28990fc94841a 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -458,8 +458,13 @@ static void lo_complete_rq(struct request *rq) if (!cmd->use_aio || cmd->ret < 0 || cmd->ret == blk_rq_bytes(rq) || req_op(rq) != REQ_OP_READ) { - if (cmd->ret < 0) - ret = BLK_STS_IOERR; + if (cmd->ret < 0) { + if (cmd->ret == -EOPNOTSUPP) + ret = BLK_STS_NOTSUPP; + else + ret = BLK_STS_IOERR; + } + goto end_io; } @@ -1788,7 +1793,10 @@ static void loop_handle_cmd(struct loop_cmd *cmd) failed: /* complete non-aio request */ if (!cmd->use_aio || ret) { - cmd->ret = ret ? -EIO : 0; + if (ret == -EOPNOTSUPP) + cmd->ret = ret; + else + cmd->ret = ret ? -EIO : 0; blk_mq_complete_request(rq); } }