Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp570480imu; Tue, 27 Nov 2018 17:31:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/VYnFAEBqWROKIINs/qFxrKdVwgrbZ4twZzBZFSFxqyFHMUAJaEVBDt/z4ZrPKTKwJbQ8xh X-Received: by 2002:a63:ef47:: with SMTP id c7mr31600217pgk.386.1543368686641; Tue, 27 Nov 2018 17:31:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543368686; cv=none; d=google.com; s=arc-20160816; b=V/7lTUL9D9ZLdS96rU1wre1bFHgOArz1EMjWwcMCzz7WOIMhrIjpTjJhJ8PdE3cL8U P+BcE+2njHx4w3IH+ABclsDvEWmcqj3d21mS46CbhUL60rFrheRLkTYBFvTa3OA14a77 Gi2Te0z842p8DluketR0VNLelZHlNTndq+rgtaXFalWSbQP/RtcbdZlbfZ45jwCyvDdT rLBuoWQqBA9+7ZjCURYCpgZVKlWu8WFO6uk3aV1M30IhhedUlNgzq9NA4DuSW854tbA6 rz8sn8/AFcXKJFmG0EezID088+z0ABcJ+MzuO2Jx3XGbF1ZCkZXMV7ZLihbMyskzcwfD l4Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ScRspSi7ylTRJ+yYluz4/QQUr2L5wXWE7VCVxRqFFZs=; b=MJCJxzLNDNVXS+8mXonBYUyMUrTlXXtrcIub6oc7oUZ7LZTFmDZJOMvnMFCPrIg4Ij 8VuP9VBUdzX/Yo4eDD3ohAjMC+t4h4M68aXisYFaIfsMpWKqXt03x4hW0M4tEFAKfU1N IDqlEZ5pml0IKL1B83tjRCd0aOS1TjYp+hgYkpTczU8f2dTTJ2VxbYMW1mHb+wafNFRM Retb89PIxrVj4bPZkeOfh8spGVQo8UPKCoIb/+d2RNdPJqM7fdpFG1ztkOurTH8cRnuN HRhlkNquwbpBlxP7Pmf6f1lHUJ4jep2QVF/0pDKBlsbO537+8jrkt8HAk8CetIYKz3yO 2uew== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y141si6561151pfc.180.2018.11.27.17.31.10; Tue, 27 Nov 2018 17:31:26 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727193AbeK1M2l (ORCPT + 99 others); Wed, 28 Nov 2018 07:28:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39808 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726567AbeK1M2l (ORCPT ); Wed, 28 Nov 2018 07:28:41 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D5C513084031; Wed, 28 Nov 2018 01:28:53 +0000 (UTC) Received: from ming.t460p (ovpn-8-25.pek2.redhat.com [10.72.8.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A54D56012B; Wed, 28 Nov 2018 01:28:44 +0000 (UTC) Date: Wed, 28 Nov 2018 09:28:38 +0800 From: Ming Lei To: Evan Green Cc: tom.leiming@gmail.com, axboe@kernel.dk, Gwendal Grignou , asavery@chromium.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] loop: Better discard support for block devices Message-ID: <20181128012837.GC11128@ming.t460p> References: <20181030230624.61834-1-evgreen@chromium.org> <20181030230624.61834-3-evgreen@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 28 Nov 2018 01:28:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 27, 2018 at 03:34:04PM -0800, Evan Green wrote: > Hi Ming, > > On Mon, Nov 26, 2018 at 6:55 PM Ming Lei wrote: > > > > On Tue, Nov 27, 2018 at 2:55 AM Evan Green wrote: > > > > > > On Tue, Oct 30, 2018 at 4:06 PM Evan Green wrote: > > > > > > > > If the backing device for a loop device is a block device, > > > > This shouldn't be a very common use case wrt. loop. > > Yeah, I'm starting to gather that. Or maybe I'm just the first one to > mention it on the kernel lists ;) We've used this in our Chrome OS > installer, I believe for many years. Gwendal piped in with a few > reasons we do it this way on the cover letter, but in general I think > it allows us to have a unified set of functions to install to a file, > disk, or prepare an image that may have a different block size than > those on the running system. OK, got it, it makes sense. > > > > > > > then mirror the discard properties of the underlying block > > > > device into the loop device. While in there, differentiate > > > > between REQ_OP_DISCARD and REQ_OP_WRITE_ZEROES, which are > > > > different for block devices, but which the loop device had > > > > just been lumping together. > > > > > > > > Signed-off-by: Evan Green > > > > > > Any thoughts on this patch? This fixes issues for us when using a loop > > > device backed by a block device, where we see many logs like: > > > > > > [ 372.767286] print_req_error: I/O error, dev loop5, sector 88125696 > > > > Seems not see any explanation about this IO error and the fix in your patch. > > Could you describe it a bit more? > > Sure, I probably should have included more context with the series. > > The loop device always reports that it supports discard, by setting up > the max_discard_sectors and max_write_zeroes_sectors in the blk queue. > When the loop device gets a discard or write-zeroes request, it turns > around and calls fallocate on the underlying device with the > PUNCH_HOLE flag. This makes sense when you're backed by a file and > hoping to just deallocate the space, but may fail when you're backed > by a block device that doesn't support discard, or doesn't write > zeroes to discarded sectors. Weirdly, lo_discard already had some code > for preserving EOPNOTSUPP, but then later the error is smashed into > EIO. Patch 1 pipes out EOPNOTSUPP properly, so it doesn't get squashed > into EIO. > > Patch 2 reflects the discard characteristics of the underlying device > into the loop device. That way, if you're backed by a file or a block > device that does support discard, everything works great, and user > mode can even see and use the correct discard and write zero > granularities. If you're backed by a block device that does not > support discard, this is exposed to user mode, which then usually > avoids calling fallocate, and doesn't feel betrayed that their > requests are unexpectedly failing. Thanks for your detailed explanation, and I think we need to fix it. Thanks, Ming