Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7491543yba; Thu, 2 May 2019 10:46:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7tgL0H/nOjNT6o7o4VJYH3EbXGRToKFrtEzNbUJE9H4cg7uOoGQUpH5ZcwH2YAcbF6Bvv X-Received: by 2002:a63:ef46:: with SMTP id c6mr5258177pgk.392.1556819165589; Thu, 02 May 2019 10:46:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556819165; cv=none; d=google.com; s=arc-20160816; b=nLizbf2ALtptEzOqLTPXb2e5J1DSuHd/LBtC7i4xvv2juOIPQGla3KBQrlGgARdktt zxSEOg7oQbrqc6B0MIyvM6r93iOZhD+ObuBVDy6x+EoYGvLg35EHaDK/9fI1lCFI3MMo qrUDYx3I+iccezA2vum0+PXRayfjfpUkxsUUD3BuZKc1c2AYCAzYv3Skm3cAiuH8CXYr 3pbQwks/qTD93T8/2gfAZ3agiheLvLN4O/TT9u3sMdGUjzBHVqAI13uOsZGlXse5Pauu QeU3nQ8lvq5hSIlpQbdREUyCoxjRo3myOJFBq05tHLUjPHaSA6++jC/xN5mIts2hsf1h Ee4Q== 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=GUp7h+veODMik8pQbwsoI+ANQjqMfD2BY5Z1tO2egIk=; b=hGHbD39HLHBgHRDmMtwFN65k+03u6GwrTk1epXYFpuAcYs9if11+tppigaAEsf7GUo ByA0Xd6Ee+tRlmLzbUk9rJGyhoRAiihbhST8+pyGjTkVGHfzKSm+e/bF4Hy7K5C+Qt0p /e22JCVSKlj+FlLj7iqUlaOhNADFRV8lqH6bJbDLRdw8PH+HKoN146AQEYkMQquE+df+ X3btsBaQ9D5EcpZZjZtmoFYir93YW86o5GAwnrUJqS82r/HUE588DMyjPTKPCovrrPX7 +m64IAwkhCgMxZRuYaoDIqbITrNZJmoeWZkbokoiOD4UjBep79rsnhewrrRGVG8rJ1g1 2M2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=e4vAlzdy; 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 g17si3171762pfb.29.2019.05.02.10.45.50; Thu, 02 May 2019 10:46:05 -0700 (PDT) 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=e4vAlzdy; 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 S1726407AbfEBRoS (ORCPT + 99 others); Thu, 2 May 2019 13:44:18 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38379 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726145AbfEBRoR (ORCPT ); Thu, 2 May 2019 13:44:17 -0400 Received: by mail-pf1-f194.google.com with SMTP id 10so1483241pfo.5 for ; Thu, 02 May 2019 10:44:17 -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 :mime-version:content-transfer-encoding; bh=GUp7h+veODMik8pQbwsoI+ANQjqMfD2BY5Z1tO2egIk=; b=e4vAlzdyFwrD/FzVxBUhnit3alGUE0OS5x3VxhBE9+YNPyWoMUsGCbXjALySNeIpce ou4bvXUd+3/r3dDOw1zqKtb3J8fvZs4nzqJ2JdyYC0F5ytfJIaHCXXLxYD2S53dQL0u5 HHn/SVQjzBBtwqfSt/GhfHug2ZyCpzcKhrc7M= 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=GUp7h+veODMik8pQbwsoI+ANQjqMfD2BY5Z1tO2egIk=; b=SrGyO0T6GxIbJj07c39V03R7ujbz4rfaCRYTzfe/3xXlAyh89L1A8zCayp+VAo33gv 7+s3bOBpA08RYC+QfmaoG93aC4bcRvZVvduiP/14GNzrv/O8ZxDJb4dWUTHfXVPubmns trswOjtNTJz5WyIusc28QsqpfOp00XgmJzHJyNYrkzIUT6g68kgo3Ue8WzMslud5aXBD FkGsS3ZLuhMHuZb62RbIt3I79oeM1E1ztx56OU066LXdGPcmJWvvCdioh63OMA79k8jv BvSh1XJ4j5BJuEmIjzn4iiDBFV41i70lFYpy7/fXa6EHoyrDN8yjnxMBkJU+uwzTFSc7 ZmoA== X-Gm-Message-State: APjAAAUupxcQlCJEMzwwx1Vb7st6x7zBvDs5+vLwvGJ1s6bCtBEh4uxd iATTnXgvRbKBRLzFgTAjPhe3lHlidH0= X-Received: by 2002:aa7:820c:: with SMTP id k12mr5517004pfi.177.1556819056848; Thu, 02 May 2019 10:44:16 -0700 (PDT) Received: from evgreen2.mtv.corp.google.com ([2620:15c:202:201:ffda:7716:9afc:1301]) by smtp.gmail.com with ESMTPSA id w38sm48319600pgk.90.2019.05.02.10.44.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 May 2019 10:44:15 -0700 (PDT) From: Evan Green To: Jens Axboe , Martin K Petersen Cc: Bart Van Assche , Gwendal Grignou , Alexis Savery , Ming Lei , Evan Green , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/2] loop: Report EOPNOTSUPP properly Date: Thu, 2 May 2019 10:44:08 -0700 Message-Id: <20190502174409.74623-2-evgreen@chromium.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502174409.74623-1-evgreen@chromium.org> References: <20190502174409.74623-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 --- 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 bf1c61cab8eb..bbf21ebeccd3 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; } @@ -1892,7 +1894,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.20.1