From patchwork Wed Mar 27 22:28:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 10873981 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 DE60E186E for ; Wed, 27 Mar 2019 22:29:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD31925D99 for ; Wed, 27 Mar 2019 22:29:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE8A02873A; Wed, 27 Mar 2019 22:29:12 +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 25A0628BE1 for ; Wed, 27 Mar 2019 22:29:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728224AbfC0W3G (ORCPT ); Wed, 27 Mar 2019 18:29:06 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:45325 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729513AbfC0W2y (ORCPT ); Wed, 27 Mar 2019 18:28:54 -0400 Received: by mail-pf1-f194.google.com with SMTP id e24so9505620pfi.12 for ; Wed, 27 Mar 2019 15:28:53 -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=+fh5+WvkK8+4l9d2sJq6AabkUwOIion/kmkDLaN4jsE=; b=SDVfZi/F1ryoqh7vd+SSN1I+QUctJE/l6cbnCPk1wcIDYhUtTFnl3/FtgKwv4RRRAZ Pm5KDgp0ZtIEydCGLDwxiqlsR2NCOq1vfZA87sy0bJIxtlsteiTHbmY1H7jxVmcebbC6 KpGM9iFgQFDcLnGTVlCz8Qnz/zHhdzFVxdJT4= 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=+fh5+WvkK8+4l9d2sJq6AabkUwOIion/kmkDLaN4jsE=; b=ib/XVGAxOk+ITU6nBxzFSWheIXowgNuCg2f2Var6piIxqCOH//JvRMd2Zh38Q+DC2r +NKXLLrCzle5TsWNAWkRLmchffKBTJp/33fDMybWqCHkCSEFCoCkmQVjooMGC/kEMxeP BJHD3YnsGuYv5JkHMhYOdof4F94qqUGNgnkXBXDlYrf891o3yRWwYPsIych3juL5iRiT EgClqiqJODlIabA3fyYyPAXaS7cTiDlTC6p58WPoG5OFMsRhaUvvPt/xQ6Y4Tt/3Rjhz tximetRqulk1ArGqhSTkDk2dbyrtOUCKJ2V46BEjDQ86r+SjQpS1l8Z8QJgeMuUyu3rQ 1YYw== X-Gm-Message-State: APjAAAUeP2XpFIsjvkYxGysNoNCx1LRn7tCmxRMujS0bsDgzsGTfpWXV q/ws3rNM2vdsxDOKM9U1AU5bsw== X-Google-Smtp-Source: APXvYqwoa3ksrft+5W+S8EIGxaMfDSimgZWkyLTByE/vZEfpc8THu9a5aE7CP12VxpAPIW4zZpWdQg== X-Received: by 2002:a63:4383:: with SMTP id q125mr34400898pga.370.1553725733498; Wed, 27 Mar 2019 15:28:53 -0700 (PDT) Received: from evgreen2.mtv.corp.google.com ([2620:15c:202:201:ffda:7716:9afc:1301]) by smtp.gmail.com with ESMTPSA id p88sm36928347pfa.80.2019.03.27.15.28.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Mar 2019 15:28:52 -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 v3 1/2] loop: Report EOPNOTSUPP properly Date: Wed, 27 Mar 2019 15:28:40 -0700 Message-Id: <20190327222841.38650-2-evgreen@chromium.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190327222841.38650-1-evgreen@chromium.org> References: <20190327222841.38650-1-evgreen@chromium.org> MIME-Version: 1.0 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 Reviewed-by: Bart Van Assche Reviewed-by: Martin K. Petersen --- 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); } }