Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3482097pxj; Tue, 15 Jun 2021 01:43:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqVxB9Wn1yEFc+78a4WBHmKi2wnaeSjpG/2XcLzdVPDU9rtKvuEpGpLFWbjF1QEQFL96YY X-Received: by 2002:a5d:9694:: with SMTP id m20mr1884277ion.185.1623746633521; Tue, 15 Jun 2021 01:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623746633; cv=none; d=google.com; s=arc-20160816; b=W7XMIAUq54payhPsI+80ABAwXeIDYWk9O8CAvUmtkIIljLhRQewaavdOKkeF9xTw+q vxNXe9OCgXbLL2uj2jcv0zFLXGGjkrlvX2UJSOVrh+oAfTGfG6ons9a3Fm1OroUMSZ5v G61dPADR6f/RSJISeNZQ3LNlO1ed7BtGqYy/Kgo//kRUgoZzO4efQ1n0velCxwy2I3KI gonYG9QAHnkSnwLAe8dQfF+3SEWLtddg4MITMaLfgFZPN6MjKgmd9OgQkJBKDPORS2DE EZSbOT9ert6nVMeDJ5/UrW1CB8NRQmARCPyWbC2Vl+SpQY8W4p38fJgzGDpcu6RpS4Wr Pk5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7Rf5EQc2dlRjbEjOR5oC7PZqtQNIsTvI0zL1js735B4=; b=rcKg59FBkGcn9x+IkYCIkUkM55yHVQWQtKwqJDcqhEbVCXVNCrNhX3SmdGBYEXF9H8 giX2cLxff/jmvM0G4quh5iljrMIWJgfD6RqsSv+yAQ59rYR76mei8Mrhe2+C/W2NnUnh G01d3+tS541zksZB23IcV1ETqwDXioPJt2vAN8GLb9TI4qs2YK3nEWh0SwkriUdZj8cb TIsHA/SPvXKypZLaVNAp2Ujp5ZigXQnkB99SbhYLBmYqPZQgvoXkL9m4h9E5loYWCnGO wtN1cg6g9dLl72nbsd08vfNgr74P1V5OtP/SwWdO2TjQIrk5oudqIscLIwSep+vLtSYP L4MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GN8cO1ao; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p11si3805794ioo.38.2021.06.15.01.43.41; Tue, 15 Jun 2021 01:43:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GN8cO1ao; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230454AbhFOIpN (ORCPT + 99 others); Tue, 15 Jun 2021 04:45:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48354 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230455AbhFOIpN (ORCPT ); Tue, 15 Jun 2021 04:45:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623746589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7Rf5EQc2dlRjbEjOR5oC7PZqtQNIsTvI0zL1js735B4=; b=GN8cO1ao0lguRq+7lE0w57LAEm7HePDxPAjOLrj2URXfmFib4Njsh8I+gPhxui41ZGShOt O0K4hlya4FZdoDnOym+XMt/DA/cIwu6erSjyS3JyN/x+quN0HjmzXW+E+N6aGhEMhcgysa kZrRa/6UaiWuCh13bnRIaUEpSqCjbrU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-477-ByxdRH-SMsG5S8STH9sNLg-1; Tue, 15 Jun 2021 04:43:07 -0400 X-MC-Unique: ByxdRH-SMsG5S8STH9sNLg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7E63B1850606; Tue, 15 Jun 2021 08:43:06 +0000 (UTC) Received: from ws.net.home (ovpn-113-152.ams2.redhat.com [10.36.113.152]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D653A5D9CA; Tue, 15 Jun 2021 08:43:01 +0000 (UTC) Date: Tue, 15 Jun 2021 10:42:59 +0200 From: Karel Zak To: Ingo Franzki Cc: Ming Lei , Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Juergen Christ Subject: Re: loop_set_block_size: loop0 () has still dirty pages (nrpages=2) Message-ID: <20210615084259.yj5pmyjonfqcg7lg@ws.net.home> References: <8bed44f2-273c-856e-0018-69f127ea4258@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 14, 2021 at 09:35:30AM +0200, Ingo Franzki wrote: > However, shouldn't then the losetup userspace utility implement some kind of retry logic in case of -EAGAIN ? > I don't see that in the source of losetup.c nor in loopdev.c in the util-linux package. There is a retry loop in create_loop() in losetup.c retrying loopcxt_setup_device() in case of EBUSY, but not in case of EAGAIN. > > And losetup also hides the original error code and just returns EXIT_FAILURE in case of a failure. So no real good chance for the script that uses losetup to catch that error situation and perform a retry itself. > > Adding Karel Zak (the maintainer of util-linux). > > @Karel Zak: How about adding EAGAIN to the condition for performing a retry? > > Something like this: > > - if (errno == EBUSY && !hasdev && ntries < 64) { > + if ((errno == EBUSY || errno == EAGAIN) && !hasdev && ntries < 64) { > xusleep(200000); > ntries++; > continue; > } EAGAIN sounds like the best reason to try it again :-) Committed, it will be also available in v2.37.1. Karel -- Karel Zak http://karelzak.blogspot.com