Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp195030pxt; Wed, 4 Aug 2021 08:53:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwowLG01NDpCdFc17HjmTvfw4xTQpl9y6H8ak15muPk5dG0It9lc2Jekv6qTbj+BKP6Uxug X-Received: by 2002:a17:906:9c84:: with SMTP id fj4mr26216930ejc.274.1628092419744; Wed, 04 Aug 2021 08:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628092419; cv=none; d=google.com; s=arc-20160816; b=rVpp4EElKXw3EMisvodHaVrQWIyIuE43G0vuxabQG9eU+jV0q/WpLb2mGvoIp6fn1r b5U69Wo2vZUMkB0c2ZidBigM8syJNnX/rCHnOBaPkq6LApxaCTvITa4nGPOBfQH0og93 +S0dP/p5MA/Ym9vEJSunBhxl87ZFiq+IG4IfRzQf2p+MuUGUeLPu8WWCWlIiHQc/HL9A J32Sv11tmk6j7Lf6MTqlRkV/Tsxkj+IohVdAIf6HgRvFmYKf+gCOtK4A+WAi9LYBpw9X 6NHIrIfxdsnjI20UP0h5gEw116UDb9Ls6/L3hg/7s/bB4WAkt4/6cVo1AQp3IKNnzANC Bi2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=DsQZleP+a92Q9m/XYDgfuGFJXRSyYXNyPiGtDd47CFc=; b=yYIy80c5/fXlOyK19+/nyriwe56oq3BFyr1xMsrCW24BKMF8Umh7eTHyvx8oTnEf1C c+s7OAcL6fapNDBm8ltT/M6l+ztXBk2mYUy5BpDTB4PEs5AUIEaFRreLrMgkIZ914rtU 5iBDM59pQeUvjqvbOtQJNDEXqyWh+vQL0x+pBejiWsB3IeJd/MQNBQTx+5ICBp0qTHBH HgCQkY6ZDrtlhjIlxw1TcAShreedrzANPKiG2TTstr1ErHyy98OKtgmK++t4VLjPUB7U EJzeVvXdHn95LPItVttvF80MRULoBDKja0/83ntsh9ogEQ8rWJreUeKzYXBHNsWFUdJ+ NB2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=fkuHI02L; dkim=neutral (no key) header.i=@suse.cz header.b=JfCoMrYQ; 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 v6si2569648edx.27.2021.08.04.08.53.15; Wed, 04 Aug 2021 08:53:39 -0700 (PDT) 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; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=fkuHI02L; dkim=neutral (no key) header.i=@suse.cz header.b=JfCoMrYQ; 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 S239564AbhHDPwa (ORCPT + 99 others); Wed, 4 Aug 2021 11:52:30 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:41558 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239567AbhHDPwa (ORCPT ); Wed, 4 Aug 2021 11:52:30 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id F150C1FDFE; Wed, 4 Aug 2021 15:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628092336; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DsQZleP+a92Q9m/XYDgfuGFJXRSyYXNyPiGtDd47CFc=; b=fkuHI02LvqjMYRclhitwjoI9XYIBcDuLNYF1E4FwrbECKJx1Itje5zImfKp6syAWT6zpSg DFFwDZyAbsG7oJEDFXuXDclREyWZrv/W30tOEO1pf4cia53LEhR0yeHSN0Nk72U+v6lW5Z XrutC5cAgY6b/y2yi8slcQFZCoGLKBw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628092336; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DsQZleP+a92Q9m/XYDgfuGFJXRSyYXNyPiGtDd47CFc=; b=JfCoMrYQ5IDLBP8he7K7aoZeAbEIubobla7byGvV3wBqhFBb80/ppRPmdS6HSgYxWbO2FH Uuuapa8oQs2JGRCw== Received: from quack2.suse.cz (jack.udp.ovpn2.nue.suse.de [10.163.43.118]) by relay2.suse.de (Postfix) with ESMTP id DD87BA3BD6; Wed, 4 Aug 2021 15:52:16 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 3CE871F2B83; Wed, 4 Aug 2021 17:52:14 +0200 (CEST) Date: Wed, 4 Aug 2021 17:52:14 +0200 From: Jan Kara To: Wang Jianchao Cc: Guoqing Jiang , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca Subject: Re: [PATCH V3 5/5] ext4: make fallocate retry when err is ENOSPC Message-ID: <20210804155214.GN4578@quack2.suse.cz> References: <20210724074124.25731-1-jianchao.wan9@gmail.com> <20210724074124.25731-6-jianchao.wan9@gmail.com> <0ac551b1-6295-9117-757d-12bee70de588@linux.dev> <2888807f-2822-a73d-4c01-f073f8fffae2@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2888807f-2822-a73d-4c01-f073f8fffae2@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon 26-07-21 15:05:41, Wang Jianchao wrote: > > > On 2021/7/26 11:40 AM, Guoqing Jiang wrote: > > Hi, > > > > On 7/24/21 3:41 PM, Wang Jianchao wrote: > >> From: Wang Jianchao > >> > >> The blocks may be waiting for journal commit to be freed back to > >> mb buddy. Let fallocate wait and retry in that case. > >> > >> Signed-off-by: Wang Jianchao > >> --- > >> ? fs/ext4/extents.c | 6 +++++- > >> ? 1 file changed, 5 insertions(+), 1 deletion(-) > >> > >> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c > >> index 92ad64b89d9b..ad0b874d3448 100644 > >> --- a/fs/ext4/extents.c > >> +++ b/fs/ext4/extents.c > >> @@ -4635,7 +4635,7 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) > >> ????? struct inode *inode = file_inode(file); > >> ????? loff_t new_size = 0; > >> ????? unsigned int max_blocks; > >> -??? int ret = 0; > >> +??? int ret = 0, retries = 0; > >> ????? int flags; > >> ????? ext4_lblk_t lblk; > >> ????? unsigned int blkbits = inode->i_blkbits; > >> @@ -4656,6 +4656,7 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) > >> ?????????????? FALLOC_FL_INSERT_RANGE)) > >> ????????? return -EOPNOTSUPP; > >> ? +retry: > >> ????? ext4_fc_start_update(inode); > >> ? ????? if (mode & FALLOC_FL_PUNCH_HOLE) { > >> @@ -4722,6 +4723,9 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) > >> ????? trace_ext4_fallocate_exit(inode, offset, max_blocks, ret); > >> ? exit: > >> ????? ext4_fc_stop_update(inode); > >> +??? if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) > >> +??????? goto retry; > >> + > > > > Not sure if it is necessary since ext4_alloc_file_blocks already retries allocate. > > Yes, this patch should be get rid of. But it is indeed helpful to fix > the xfstest generic/371 which does concurrently write/rm and > fallocate/rm. I'll figure out some other way to improve that Note that the retry logic is only a heuristic. It is not guaranteed any number of retries is enough, we just do three to not give up too easily... Your patch effectively raised number of retries to 9 so that may have masked the issue. But I don't think so high number of retries is a sensible choice because that way it may take too long to return ENOSPC. Honza -- Jan Kara SUSE Labs, CR