Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3850063ybc; Thu, 14 Nov 2019 15:52:06 -0800 (PST) X-Google-Smtp-Source: APXvYqxoHiIbpbUrpayshoiSlmwPSQmt7R4l1kR0c2Ju2k8ti0kws1aSgKnplH1qR6utgA9jWjDw X-Received: by 2002:a1c:9d07:: with SMTP id g7mr11464381wme.53.1573775526144; Thu, 14 Nov 2019 15:52:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573775526; cv=none; d=google.com; s=arc-20160816; b=beXCmesePD04MfU44nd7SChOCeDUYk/e2KymqmYIDNrPROVLKXi4IRM/BxmV8h3w+e Ta1uYrFrM0d8HE6swDQmI7ofd1uMH7MOzXa/ecUvw9QC8GEADTkOM9sChgUBKE6PWb8i wIPTj8pqDIYJ+A3+G8I2RKFyIN4zGEXJygaZ0veXSBFOt3FgLOorD1piN5zVcW8P0MBb 6ij5GUdFZnnS+LOI6nOmdL1DvXj0951DaXGlg/A1qHxHLKLKrP8M2toDK8OyULNDZlSX FM/7ffs/Nkgtolh01oCIXlSbXyt2MS3rCekV6DgBGbmEjFHYQeVeNyE/UhBpx0b3FLMp 9JSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xiAHPGc8Aj14Y5MdGFh9g/Het9kcprPusIL8MfH+JWo=; b=ESvGJe/yoN/WiRxoBceW839iT1cYsg3laWpkKP8e40317n9f4xkzSZeBEjmXUc4mNZ q8QY2j/y0MN6KcqHkyqt8Vy15walE/KWqsFRIDQHIhuCQh9YkpmOIs6i/ARwJBLRYHxn +vYfbObuFRZqIs4SiMdq68QYTAtGrfDSzXRE3XzzKgWOHomxDRCzYLXf6PsZeoQu7Qr2 C6P/QDDRPnXeQX/yxhjvOr/M7T9R9GXKG9wzwJlElav9DDMb0SNEkCtzUJXlO4e7bXY3 qTjUU67yl/5Q8gFHjZuf59y5A8Dif4JAtYZpHxiU95H426FzhSW8cA5mZRvzc9D++ktJ D9CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="khW/Eiyt"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7si4887313edg.66.2019.11.14.15.51.41; Thu, 14 Nov 2019 15:52:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="khW/Eiyt"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727185AbfKNXub (ORCPT + 99 others); Thu, 14 Nov 2019 18:50:31 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:44007 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfKNXub (ORCPT ); Thu, 14 Nov 2019 18:50:31 -0500 Received: by mail-pl1-f193.google.com with SMTP id a18so3392584plm.10 for ; Thu, 14 Nov 2019 15:50:31 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=xiAHPGc8Aj14Y5MdGFh9g/Het9kcprPusIL8MfH+JWo=; b=khW/Eiyte9ISt39PSZD+XyzsM8rumPfd6TQnOUOJhx0OMJAUC7Xvoinrf6RwwC+E9x KqvvKr9k0zjwX8wthQowSXO1EvojyovYbatrMlfGDM50J1UJ1bu2U/VIkyBkfXm+QHZH DUehIhiBlRTqy2NNG8NuZIk759/RsT4IDPWA4= 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:mime-version:content-transfer-encoding; bh=xiAHPGc8Aj14Y5MdGFh9g/Het9kcprPusIL8MfH+JWo=; b=i8mMBEfPql+qaLcD/G8dzxxnJAcnfkOZMpEQIwaGgfUHG1fJnlJ5HX91zSGCs9ewNR 324W/v2vbrjU6Tev5vgP3CHd2btUnT+UubRhQbEowKlDJAAHfHFA+lLBGBBY272EK6VH fIxl2mkIrleW/Ncssl5nJtEKyplltrPxnFoG+8Qv9sY+a8Csv/HQkcFAmNqPSjYc+zrd TSMc13YpoBV/9LyUB+LHEOVBSlyv8NUWTjLVt+L7s9iwq5a4JaMnNM7+xvgL4xOKPOf/ IKASwR8A7SQdumAI50DIYQrY5cgpHComHeoy+cSDPpdSUkIl/dtOk25C9QZvsjgkaVrh HaRQ== X-Gm-Message-State: APjAAAXmZ7Or0JsITOkrTRX71O97DfFp8r73B4sk0PLIiGwteTvdiBix 5kUZBCvNMfALdPNYKsb6DzgO8w== X-Received: by 2002:a17:902:9a8e:: with SMTP id w14mr12617831plp.215.1573775430712; Thu, 14 Nov 2019 15:50:30 -0800 (PST) Received: from evgreen2.mtv.corp.google.com ([2620:15c:202:201:ffda:7716:9afc:1301]) by smtp.gmail.com with ESMTPSA id v63sm7904458pfb.181.2019.11.14.15.50.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Nov 2019 15:50:30 -0800 (PST) From: Evan Green To: Jens Axboe , Martin K Petersen Cc: Gwendal Grignou , Christoph Hellwig , Ming Lei , "Darrick J . Wong" , Alexis Savery , Douglas Anderson , Bart Van Assche , Evan Green , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 1/2] loop: Report EOPNOTSUPP properly Date: Thu, 14 Nov 2019 15:50:07 -0800 Message-Id: <20191114154903.v7.1.I0b2734bafaa1bd6831dec49cdb4730d04be60fc8@changeid> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191114235008.185111-1-evgreen@chromium.org> References: <20191114235008.185111-1-evgreen@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes in v7: - Use errno_to_blk_status() (Christoph) Changes in v6: - Updated tags Changes in v5: None Changes in v4: None Changes in v3: - Updated tags Changes in v2: - Unnested error if statement (Bart) drivers/block/loop.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index ef6e251857c8..6a9fe1f9fe84 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -461,7 +461,7 @@ 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; + ret = errno_to_blk_status(cmd->ret); goto end_io; } @@ -1950,7 +1950,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); } } -- 2.21.0