Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2056780pxb; Fri, 5 Mar 2021 06:29:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/JXicEmrxDPJ/H/EaehrBRL9rheWMhHgf5bXHmPBj5HJaYRk7qq4ZbI6FxWt/Q/SHZpjq X-Received: by 2002:a17:906:3395:: with SMTP id v21mr2444916eja.322.1614954542834; Fri, 05 Mar 2021 06:29:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614954542; cv=none; d=google.com; s=arc-20160816; b=sCSK1QdgfQJzlaDjNKuGYXg5ouUpsnl5iH7u2z2epVkOFRoQ3nhxEqdV0dELEKVwlv XFpBGq5fQEWYDa1GSuMD7MLHYUu674+P8XBXVF+O+Jdj32Qb+uyg44+FltEzRsNhKEjN 5/ZgGHMkr3GDCJYChIMlpDIzWkGLEI00K5qhDWsleQ+3oabzlMCQ9JwRjPp2PfPvPKQ9 FwSUzhISCAmaBLtk1lnAb0TeikE6a66dIC45syruG7ljwCHLNLrQys+vQ+7BV+3nNl5R 1Ver5in4fhllaglJ06lZA2r6Yd9274ySVKvdaUl8zEsddVDtcW/pp+wdxti0+KbR8mgj F2Ag== 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; bh=6utR0ddYPMrEhNBy9tPztgLMIbpA8kfKtdXnRuxLXTA=; b=SdFiVxcI+3Z55PXQytY4Horiu5vWzBKk2BgZorh3s/7O8Xz/BicAF3dXmOQ+E2tgs9 D18Vgp2iC6ki1/tBLuN35qMOIN18iWrhR7tXmptai0jiHe7YTsh+ApNPId5HyVa6q3G9 SchrFoQf0mz+hhVCPyoNY1MT9I5lEiGUSD+5q1EYTCNt2gPumohXwPbrGiU5gWlftJdS cidO6S6GFmJb107XBZ4NEi5o7HYG8Hw8i0TYWkav15dy9E0pBGRxL6nczSyQUM9CMjxI Rh5qrS8d7xtPjUIDSTC8X2/bmELMVmaotMB/Mc4HkdA93J8ugsl6s8jskTyyiDQUIRTc 6ROw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h14si1360886ejt.198.2021.03.05.06.28.31; Fri, 05 Mar 2021 06:29:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229562AbhCEO1r (ORCPT + 99 others); Fri, 5 Mar 2021 09:27:47 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:45238 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230496AbhCEO1Y (ORCPT ); Fri, 5 Mar 2021 09:27:24 -0500 Received: from cwcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 125ERKBK020870 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 5 Mar 2021 09:27:21 -0500 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 9AA4315C3A88; Fri, 5 Mar 2021 09:27:20 -0500 (EST) Date: Fri, 5 Mar 2021 09:27:20 -0500 From: "Theodore Ts'o" To: Eric Whitney Cc: linux-ext4@vger.kernel.org Subject: Re: [PATCH] ext4: shrink race window in ext4_should_retry_alloc() Message-ID: References: <20210218151132.19678-1-enwlinux@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210218151132.19678-1-enwlinux@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, Feb 18, 2021 at 10:11:32AM -0500, Eric Whitney wrote: > When generic/371 is run on kvm-xfstests using 5.10 and 5.11 kernels, it > fails at significant rates on the two test scenarios that disable > delayed allocation (ext3conv and data_journal) and force actual block > allocation for the fallocate and pwrite functions in the test. The > failure rate on 5.10 for both ext3conv and data_journal on one test > system typically runs about 85%. On 5.11, the failure rate on ext3conv > sometimes drops to as low as 1% while the rate on data_journal > increases to nearly 100%. > > The observed failures are largely due to ext4_should_retry_alloc() > cutting off block allocation retries when s_mb_free_pending (used to > indicate that a transaction in progress will free blocks) is 0. > However, free space is usually available when this occurs during runs > of generic/371. It appears that a thread attempting to allocate > blocks is just missing transaction commits in other threads that > increase the free cluster count and reset s_mb_free_pending while > the allocating thread isn't running. Explicitly testing for free space > availability avoids this race. > > The current code uses a post-increment operator in the conditional > expression that determines whether the retry limit has been exceeded. > This means that the conditional expression uses the value of the > retry counter before it's increased, resulting in an extra retry cycle. > The current code actually retries twice before hitting its retry limit > rather than once. > > Increasing the retry limit to 3 from the current actual maximum retry > count of 2 in combination with the change described above reduces the > observed failure rate to less that 0.1% on both ext3conv and > data_journal with what should be limited impact on users sensitive to > the overhead caused by retries. > > A per filesystem percpu counter exported via sysfs is added to allow > users or developers to track the number of times the retry limit is > exceeded without resorting to debugging methods. This should provide > some insight into worst case retry behavior. > > Signed-off-by: Eric Whitney Thanks, applied. - Ted