Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6567370ybx; Mon, 11 Nov 2019 11:04:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwKHIXirka8cnrO5MmNLYMEZo/ZBRf179hnVt8nWsgeEjTp6+TGgSZlFmKVJKSY7abkHYpY X-Received: by 2002:a17:906:2615:: with SMTP id h21mr24519545ejc.212.1573499095740; Mon, 11 Nov 2019 11:04:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573499095; cv=none; d=google.com; s=arc-20160816; b=gH95JP6xTtj8jdb3QQZvWQLuPTVo4+/sGU7uKkzmUsJBJqjqCbsqre7cPrczUsS++H xupoDJxQRLKtHXSOA5Z9XmbrGAcGXaINnpNBw6t9Mcyd/WrFa82Lslm22ZmHj121cI6p ZfPhwYFa3uVDUWfzecUhOO4+PSGaL1+MVM2ZhP8B5Pd3/hXL56161NUVcrP9sBhaN3QP loKyds+Cf36nNk0opN4RXuaoid0m22+B2myKEYUkbF4UQYTJUDtvS0mlOf5qUYSWE99G +q8doZP1KSJnB/Rs1Ypuke026aE9f16/eHuV1NQrX7XAjGwbkTFLP6xaoGZ7rA3laqDb IxKQ== 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=Cj9EDPrGBtXH1r7z1h31u4mvPDvEY9hEU3TV12jxQYU=; b=aGdFogdcu4j7fbMu+gnbOVAvoRhG9ZpvUmHIX5J6diUSirtGyp5q9vcRvxiPeDmD+j Sx1LPK/HYkRZI7hrnmEc63O5Prm0Zp3IezWXA7dFo0frV54qCY9s0GIMQjOxkifmlmGe HSJsdOgHkU0gpkVLqc8X5+gmyVQ2adWKGF/QVcDJvGy6g/RAnsV0p5SDx0GLqoUshOrP tz06byLFAYeGi2skcPo4DTPC/c/LXkTM7orbKskR/j3T4TJes5UiLsnrJVZAakKR1V1X lV5SK14ysXA+dP6/hLbafdsdBSzgaPJ8NMGveXCf7bO7GmXT7xh0EWm6/ZvmZPY3UaYm pNKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NZTpU1UE; 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 f10si14000081edc.221.2019.11.11.11.04.27; Mon, 11 Nov 2019 11:04:55 -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=NZTpU1UE; 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 S1730175AbfKKTBp (ORCPT + 99 others); Mon, 11 Nov 2019 14:01:45 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:35138 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728969AbfKKSus (ORCPT ); Mon, 11 Nov 2019 13:50:48 -0500 Received: by mail-pl1-f195.google.com with SMTP id s10so8162179plp.2 for ; Mon, 11 Nov 2019 10:50:48 -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=Cj9EDPrGBtXH1r7z1h31u4mvPDvEY9hEU3TV12jxQYU=; b=NZTpU1UE5cacrL70YHIATCygG5yvGdKJ2bJwCakmjoZk2TRDbTo1cq/30lw/WokZaQ /5OETKfVamEbRA9JDXpE+Mt13M+pILP/r8uGQ4G8HANMBgeuXIm6lN1tt1cpcnuYg/Mq o5LgGSPxa1SSQz2THqJPPxW+uZfkg13VKHhnA= 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=Cj9EDPrGBtXH1r7z1h31u4mvPDvEY9hEU3TV12jxQYU=; b=EbjgzU/Z+qWRiAtZhAt3LlvW3tmPL5Zu7kbmgSCCrYYzeNZbh4wMOcTR8BW7zdNSJQ Ti3UYslVrb4XZAIXvWF8qYzzjKRCWKTDtZW1lw+D8s24OCvP5nZlhdBL3PbQ48w/KfJO sra1DxDWGjzPoQPzAjXKi4y1qHToLXCxCZy+OdaJpylF1QpfvIClWQlHI2EoRSobSPMe 1AxynDE4E75+DY7XJ1mVV7KAb28N5FVDi6bEyeBvHP5sTtWhGQLDqbpaqd8AWH1iGHxl WTOT/iftMxdgu4/XKF1vRM38A/JkXopySSFQq0QZtxL6h/V4K0xxnpM1f8sK5de4t/ze wefw== X-Gm-Message-State: APjAAAUpyn5nDBCFb1JbwLbTxE50BCduWirm33rLvbfgUZQrauBmypQ9 hsiSkq7PMOAiBOxgKRzoyKeEmQ== X-Received: by 2002:a17:902:5acd:: with SMTP id g13mr27808948plm.242.1573498247918; Mon, 11 Nov 2019 10:50:47 -0800 (PST) Received: from evgreen2.mtv.corp.google.com ([2620:15c:202:201:ffda:7716:9afc:1301]) by smtp.gmail.com with ESMTPSA id v63sm15220971pfb.181.2019.11.11.10.50.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Nov 2019 10:50:46 -0800 (PST) From: Evan Green To: Jens Axboe , Martin K Petersen Cc: Gwendal Grignou , Ming Lei , "Darrick J . Wong" , Alexis Savery , Douglas Anderson , Bart Van Assche , Evan Green , Chaitanya Kulkarni , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 1/2] loop: Report EOPNOTSUPP properly Date: Mon, 11 Nov 2019 10:50:29 -0800 Message-Id: <20191111185030.215451-2-evgreen@chromium.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191111185030.215451-1-evgreen@chromium.org> References: <20191111185030.215451-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 Reviewed-by: Ming Lei Reviewed-by: Bart Van Assche Reviewed-by: Martin K. Petersen Reviewed-by: Gwendal Grignou Reviewed-by: Chaitanya Kulkarni --- 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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index f6f77eaa7217..d749156a3d88 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -458,7 +458,9 @@ 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) + if (cmd->ret == -EOPNOTSUPP) + ret = BLK_STS_NOTSUPP; + else if (cmd->ret < 0) ret = BLK_STS_IOERR; goto end_io; } @@ -1940,7 +1942,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