Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1223img; Wed, 27 Mar 2019 15:29:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8xYFx/yRxgtbP2F3GT/ItoAZxQ3fSZsD/+Ndox0kNhcaA12WHWXZF7YBQ9BqZlad16wi+ X-Received: by 2002:a63:6881:: with SMTP id d123mr36350031pgc.10.1553725792933; Wed, 27 Mar 2019 15:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553725792; cv=none; d=google.com; s=arc-20160816; b=lRQzB/ynol92vK+pHjvQ/UOuaqta/Pn6YXjVCEAjjCj0fylmCqc/0xdRfKz86o1ytd I4qTXdrxPkx+cCe2PSaSIus9dnWlNlfzq9ndUIHHSz2c86gLCyUG5u3AkpkDXcqiTO9c jPSjsjGjbm612wyrQNq/NW6kcKKU6ncG3CYWyXiAvbuh5nmHDo7PKd+VUEEDax5vt9ca V/Gb0aWpy6/Lkh8CpSlK4ecE0GIYnh+DBYm26i4h4g6m4Xo4chSXoR7jIhi2DMIZZpgr X9ZrFovMxAGWXc3e11FD8cnf7CtJKz7x9xUa9adE3Gsiv46EMpQKj2DfSnkC4q1d7bZV Txrw== 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=+fh5+WvkK8+4l9d2sJq6AabkUwOIion/kmkDLaN4jsE=; b=Dc56FjZtooubhEsyu7iJEnGD3UnYv8OUfP7Bqq4eYwhEc89u43SDpRuUB5QWdH3Dmd 8eLh6DreCiZSnNGA8AMO7HkXUhyngvqKDDyvAPWwqhH4xuqBZ0Fi7t4YX7ySu9Cixk3n T3RFaCgUVuvU6mMY3w4m7HHN2FNoyZuOQKOriA+sflYTysZbE4jgY5dNonUg1MN85qnO kR6pnK7aIbNwk7Ch+IjUlzwmSG0qFevinbJED+w7KSDW9nA0WkrIBibJNZAD6you891k fSbL1g8vNPkPD89l0S8MJyo9g6ZnhYs/fccjXjQi8kY1iy1Z3oZlZkjrP5on7EuMR76W bLqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="SDVfZi/F"; 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 q3si11053913pgp.40.2019.03.27.15.29.37; Wed, 27 Mar 2019 15:29:52 -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="SDVfZi/F"; 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 S1730769AbfC0W2y (ORCPT + 99 others); Wed, 27 Mar 2019 18:28:54 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45647 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729355AbfC0W2y (ORCPT ); Wed, 27 Mar 2019 18:28:54 -0400 Received: by mail-pg1-f195.google.com with SMTP id y3so10596722pgk.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=dYNncipddjNm4qqLE+t8hy7cmGd+oUkqou+xN9pcZRjGBCEjy8m+payDzP9ZVYrCex yJlpi9JH+2p2A4VlLFPaaJ1XGQc6/64NzI/eZ3t8c9WSZvHETJ3bTcNnjohrmishqjCx A3RWq9BCEeALGT9uGnkpKpgIvyeZF62abf7OOiweQoDubo4lcGG0oei2WEZv6lioHQMO qXU3PGfLh7R0Vd1BezlhhbxyVVIJIY6g6T8Zpe83HjJKk+rrBexYrDvJB+SNrT8MNLWq eAbaPsEpD+NUR4YxLI0pwJZ2NotrLG13UBenOJNpMjenjyc3OmyiRcyuAiQimtnL99lI IVcA== X-Gm-Message-State: APjAAAWk5WK/ZTjS1h0uqGkS5Pj/uBmHXbsPfXS42TXsk+8BXkHNodQp 47+XBjHWs8rbQzTx7NfDRRSM3Q== 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 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 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