Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6565391ybx; Mon, 11 Nov 2019 11:03:10 -0800 (PST) X-Google-Smtp-Source: APXvYqxVP6LTqzKhywCEbRy3tMT1mIxqaFm7WYdohGZcoxDJFMnIDcyWYGzu9MyKYnfRwwiAFohx X-Received: by 2002:a05:6402:110c:: with SMTP id u12mr28327741edv.127.1573498990707; Mon, 11 Nov 2019 11:03:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573498990; cv=none; d=google.com; s=arc-20160816; b=Vn6XpGBt7yi7a820RX6YUL8cicFgkf8iE4QyKaaL1xHL/qTPCzcx2j2/Z9FmW36pz2 FwzqeRljB4xgAWuq8ySJjaM85YVppQNZFkbRip1RBhB+WmHNZmOx1Mg9RnzTeiypy0au VbW42GqdhW6oQHvAFOyRoS36VqYNcCCKoU/eUfUsUqu8PLkBwu2UR0LU5NsquOXxLi63 Vi5z7/FJwpY0OGyeghakiza22TEh56Us0K3/1tA9pjwXxt7Im8RoN4ihwIte2C5SwQwh 69/djsZYjc8u2lUPx/ZB9169Iv1hjFPIpCOvgWOlUeBRAl6/DStr6s39vUDKhnb6VhvZ DZZQ== 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=SqHuH+O1ZtrNaMwGovrIH7hD1eYbuecwgYp3TILG6e4=; b=dKRyCW7XIjLjydRLc+Zn3fZrfldafr0RwYogfmdHNnIYrPLboARYvi77h03ikTi6hq cywzJu/NElV/Zk0NUXjVDCjDlvYwoouzAo9Tt0Ppk1XqWNBn9M4fh1tA854DUGkfTTW0 xeuEtOveGHVQeBIpxs65c7ck2QYFjxR9rQBRqW21ehIjXKlv5EAjsG0zzEd0kX/D0/c3 PxxmVAIw2Ts5EWHsdf6yVy3Ui4HQHcTmPLqZPJvm5g1wmHtefgBeWfrNZSVM7nG38TaL bxCCGrTggkuHbrzVoSXSwgC3M7B5l26g7izUr7anW62UUwP99LDjhv1zpDKgkaRmZuf5 UnRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TJG431fn; 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 l15si9990214ejc.27.2019.11.11.11.02.41; Mon, 11 Nov 2019 11:03:10 -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=TJG431fn; 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 S1729937AbfKKSus (ORCPT + 99 others); Mon, 11 Nov 2019 13:50:48 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33671 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727718AbfKKSun (ORCPT ); Mon, 11 Nov 2019 13:50:43 -0500 Received: by mail-pf1-f195.google.com with SMTP id c184so11301886pfb.0 for ; Mon, 11 Nov 2019 10:50:42 -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:mime-version :content-transfer-encoding; bh=SqHuH+O1ZtrNaMwGovrIH7hD1eYbuecwgYp3TILG6e4=; b=TJG431fn1FQazvBV6Wgeh1D1wZrDk14udOcQWLRSZYNozaF4BCdB3j2A0utl5FXPFt NgTBU+vR/As+hZEKwnhqOjqj+szVkfsP89rSv7JbOcPAdAv1yAmmE5/QW3sJq4JAEBpZ 2kqULMCOeTgNBVUSkKn4qxCkgV0hofZMUgKCk= 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=SqHuH+O1ZtrNaMwGovrIH7hD1eYbuecwgYp3TILG6e4=; b=Gm12jxzDeCOyD9H/hQLe2tkSTt8Ga7BzHJsk2t42EbzGS13gCEYI17J0BAubVHwpgv vU7btfAW3GoxXok28FBpmbMEYx71GaWcxSpmVEIQBnFbKqsowSefLVQN4cQgQYdDBJWW EK5OOuDzpDHLnMzW+0n2/0vuMj1I7GSMQM/jHNHjK/glrx5VYdpDghsZjKwshQsYbSAi MmG0fCZ2hTr/P8p/7zB11NvajMc5efo8bQ78lGaQBVj3kVHS5uSwuGf+Mnh4Cden1i9P OBKeC63WHfFpCIPCkGMHPfYNb2OrsLukBLuhmLWlY/Cn9G51W8BzdVdilhgDreoRVNQV X5ow== X-Gm-Message-State: APjAAAUnDWa9vuEsJYN6bJ6VfQOU5hX1qTSENqKXSD6ueNiVCyBrf6bN pI20OKictlYIVsl8ANcujif0tQ== X-Received: by 2002:aa7:9189:: with SMTP id x9mr4439687pfa.41.1573498242139; Mon, 11 Nov 2019 10:50:42 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Nov 2019 10:50:41 -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 , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 0/2] loop: Better discard for block devices Date: Mon, 11 Nov 2019 10:50:28 -0800 Message-Id: <20191111185030.215451-1-evgreen@chromium.org> X-Mailer: git-send-email 2.21.0 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. Darrick, I see you've got a related change in linux-next. I'm not sure what the status of that is, so I didn't base my latest spin on top of yours. Changes in v6: - Updated tags 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.21.0