Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2787687yba; Mon, 6 May 2019 11:31:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQ6zCGGlEiPuOncfWWQkrOMa2pKfXehnsmBIJ8PkrVRzaQl6cTFBWyMg5/yVsu0QNwx4Ze X-Received: by 2002:a62:582:: with SMTP id 124mr20523719pff.209.1557167489340; Mon, 06 May 2019 11:31:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557167489; cv=none; d=google.com; s=arc-20160816; b=GF0I8hQKZoxlzC23e+hf3kB+8dOS5cPn6uuBX170Yg1GaVIBXL54DtWRlTOH184l9N xDXvCi5M3M9xK9cV0WYgTpxWuQVQxZSBsPLiJ4CDplUczBBucUo7f/E9NhK5ZyURN97Q FMh33wzPua4++ZPfa01BDxZP8N4Jk1rjYpSNzpEuHQJBEpgFtgtWxCGxdMzNM1m+MJO/ SIF32XkNhPbiAMqo3JJrDelMiRXF1YZ8do8I3q9LbFYdOH2nsbR0PgVoM0CVulztBYFO 7TLo0sA/wyxWfZQDpqxmY+uXU8lzCK0mg9n3+MoybENwj/+Xz00snwaUgMC82Wl2mBLL iUMg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=FWiIIVTvafssa7j5YFzK8jBCCcMF1hHZ27yFT6HUiho=; b=Thf/DFHzTsJGIGdt47xui9tIwYUSY0asM6nSovWtmEjNlugyLsA0dA1z3hQB0BW1OS lWAoU4w14xsPMOVTzFd4cJTSJQH9U5s136bNCZi64NwvkGfjnAGcJjOopM8fbwK4TXgx +yIK4TZy6Yld40GKpHu0FUjTFmIHPeM2jqiJ8NPpMANuOKnPHm+HPSQwdkvoA0qePMZX w3bQkVpNKc9YvEoxVHrLJtK+KKoQY20R+HZl/AKlZ5p39jFs1qhcrFkFBMwxXNtQ0VNJ /tKUD57wkskVGMQm+dsyBSyTNI+vG2fAnXPRWelIpGwL9caPNxdWFU3FcNAsHmXpdsjo NMtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VratITt3; 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 d137si5723856pga.23.2019.05.06.11.31.12; Mon, 06 May 2019 11:31:29 -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=VratITt3; 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 S1726503AbfEFSaT (ORCPT + 99 others); Mon, 6 May 2019 14:30:19 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:46081 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbfEFSaS (ORCPT ); Mon, 6 May 2019 14:30:18 -0400 Received: by mail-pg1-f193.google.com with SMTP id t187so2747460pgb.13 for ; Mon, 06 May 2019 11:30:18 -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:mime-version :content-transfer-encoding; bh=FWiIIVTvafssa7j5YFzK8jBCCcMF1hHZ27yFT6HUiho=; b=VratITt3OckNpkTxBZmxmeeBz10CUAb/72hiWmNGZIyDt6Rx8s7JILbsP3ytTf4MLZ xQ3bzgaughDO59vyRGYHyS+tdAN5djfgX5XflzdqlujfPYO/6DmX5rQVJ/iqp/Kl6ay9 mLJ6koEBR7aMD9PbYgYeulv2p0N+35KVTbLys= 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:mime-version :content-transfer-encoding; bh=FWiIIVTvafssa7j5YFzK8jBCCcMF1hHZ27yFT6HUiho=; b=ZPQAu+g7hCW171eQy0q24x4cAhybYyh6nDTO3Sl5fSMf+c/j2snjoRrrUopUg2uVbo AjiCshMvvIr6c3acQ8vVlJ9N7w728YVawvae4SrNm0UmwTOJp/A82WgJdbTRDZxcgiod psJKevVB8MZ8+WG0jSg8p1Aq47+MUhAHrWxLNKIgBuQgJ91sSRmqLsN5uUlu/TSEseGK SgOulvF121tdMDy6Zm/HBIi2u5G5sZNl6UVXwhJImR/SvKsVm1zO5AEubC8ejFSgvdC+ A5ZqT92tUJS2WAl2DhrSbPDAp+xB/8MRuhsLq86oGjgpMUtDYyubAdAohhw+gIulQU3V wP5g== X-Gm-Message-State: APjAAAUadPyt/4tvBXvySJ6UaSFlPz9T3O0KC+L53jJn8K53Hn2AiRo8 PVLuy09HfS1hniXZ9pwA3yChdw== X-Received: by 2002:a62:41cd:: with SMTP id g74mr35756752pfd.216.1557167418165; Mon, 06 May 2019 11:30:18 -0700 (PDT) Received: from evgreen2.mtv.corp.google.com ([2620:15c:202:201:ffda:7716:9afc:1301]) by smtp.gmail.com with ESMTPSA id o81sm18858033pfa.156.2019.05.06.11.30.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 May 2019 11:30:17 -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 v5 0/2] loop: Better discard for block devices Date: Mon, 6 May 2019 11:27:34 -0700 Message-Id: <20190506182736.21064-1-evgreen@chromium.org> X-Mailer: git-send-email 2.20.1 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 This series addresses some errors seen when using the loop device directly backed by a block device. The first change plumbs out the correct error message, and the second change prevents the error from occurring in many cases. The errors look like this: [ 90.880875] print_req_error: I/O error, dev loop5, sector 0 The errors occur when trying to do a discard or write zeroes operation on a loop device backed by a block device that does not support write zeroes. Firstly, the error itself is incorrectly reported as I/O error, but is actually EOPNOTSUPP. The first patch plumbs out EOPNOTSUPP to properly report the error. The second patch prevents these errors from occurring by mirroring the zeroing capabilities of the underlying block device into the loop device. Before this change, discard was always reported as being supported, and the loop device simply turns around and does an fallocate operation on the backing device. After this change, backing block devices that do support zeroing will continue to work as before, and continue to get all the benefits of doing that. Backing devices that do not support zeroing will fail earlier, avoiding hitting the loop device at all and ultimately avoiding this error in the logs. I can also confirm that this fixes test block/003 in the blktests, when running blktests on a loop device backed by a block device. Changes in v5: - Don't mirror discard if lo_encrypt_key_size is non-zero (Gwendal) Changes in v4: - Mirror blkdev's write_zeroes into loopdev's discard_sectors. Changes in v3: - Updated tags - Updated commit description Changes in v2: - Unnested error if statement (Bart) Evan Green (2): loop: Report EOPNOTSUPP properly loop: Better discard support for block devices drivers/block/loop.c | 66 +++++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 22 deletions(-) -- 2.20.1