Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2495450pxb; Tue, 23 Feb 2021 08:21:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvvZggj3bJpvWt8fbF8Hj9ak5hnIVffYkYdbj53ymIZ6onRj4rWEpXsrKqhH4B4G40P2LQ X-Received: by 2002:a17:906:3ad0:: with SMTP id z16mr27266269ejd.72.1614097307284; Tue, 23 Feb 2021 08:21:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614097307; cv=none; d=google.com; s=arc-20160816; b=E3ezZELJI5zVPoKSo6T/oQaQXDfIuW+7sgv96zNrBoTJG1yIT2OnN6olTWrQH6Nzos i+d+NmqX0u8Hj1C24b734jWmuSZ4P+vnKzU3EireT3JdoM0n3daJSalI7Vx+8XcwQiIx nQ85ErikOJsGACH47AbiK/Bc7eH6qicgoWQMqhvoVA0ZwhSqGWaSjSfyrmaLcl01gOYO ch4zDllQFnAHcVKajmaB65NDozwyK5gC7pjx9iqyZtgZ84O3mBmWm+G3LWLszer0v2PY sSNTpteNq3pek0Pnp42XGxY64F80mNmv8kx0tLwiAeCFq6tkINXhYmskkdYiAA5GQPDm VOGQ== 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-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=K+zrze76iRN2YrZXE5PcEq0LEHohOhe646z/wxgZLw0=; b=c33bgqOYeFlfRSRxa8tdDazM/O/ePK9j3KzBZWIuNlB345aGl+21I5HrrGQvsLjIPi TkU7prAHFX1ZYDpmp16PItAWTwXCPEaGsewJplO/o7rQts1bXNxd/HG9Fd3qMuVzdDdx CjK3k69yXYUj53JCh2c9VCp6jQCeJ/Y2/UYyYhNV7t8whT1LbxJG0LMosoKkOgKb5SQY yoHTYtQvW5vnlf9EIabESV1DG1knSNJK0yR+tJvbzhO9UDzrIIZxlhn0IOjPb2yHXFT8 bbKNZEjFFd2EB6x4DRistx1cy9NgzlirdzG2w4veI5ejhnznILccqwzeNpue/C/N1FlU v9PA== 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 cc10si15256043edb.153.2021.02.23.08.20.59; Tue, 23 Feb 2021 08:21:47 -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 S233312AbhBWQTa (ORCPT + 99 others); Tue, 23 Feb 2021 11:19:30 -0500 Received: from mx2.suse.de ([195.135.220.15]:58262 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232733AbhBWQT3 (ORCPT ); Tue, 23 Feb 2021 11:19:29 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7CC53AB95; Tue, 23 Feb 2021 16:18:45 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 4578C1E14EF; Tue, 23 Feb 2021 17:18:45 +0100 (CET) Date: Tue, 23 Feb 2021 17:18:45 +0100 From: Jan Kara To: Eric Whitney Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, kernel test robot , Dan Carpenter Subject: Re: [PATCH v2] ext4: reset retry counter when ext4_alloc_file_blocks() makes progress Message-ID: <20210223161845.GC30433@quack2.suse.cz> References: <20210219172519.2117-1-enwlinux@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210219172519.2117-1-enwlinux@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri 19-02-21 12:25:19, Eric Whitney wrote: > Change the retry policy in ext4_alloc_file_blocks() to allow for a full > retry cycle whenever a portion of an allocation request has been > fulfilled. A large allocation request often results in multiple calls > to ext4_map_blocks(), each of which is potentially subject to a > temporary ENOSPC condition and retry cycle. The current code only > allows for a single retry cycle. > > This patch does not address a known bug or reported complaint. > However, it should make block allocation for fallocate and zero range > more robust. > > In addition, simplify the conditional controlling the allocation while > loop, where testing len alone is sufficient. Remove the assignment to > ret2 in the error path after the call to ext4_map_blocks() since its > value isn't subsequently used. > > v2: Silence smatch warning by initializing ret. > > For smatch warning: > Reported-by: kernel test robot > Reported-by: Dan Carpenter Looks good to me. Feel free to add: Reviewed-by: Jan Kara Honza > > Signed-off-by: Eric Whitney > --- > fs/ext4/extents.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c > index 3960b7ec3ab7..77c84d6f1af6 100644 > --- a/fs/ext4/extents.c > +++ b/fs/ext4/extents.c > @@ -4382,8 +4382,7 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset, > { > struct inode *inode = file_inode(file); > handle_t *handle; > - int ret = 0; > - int ret2 = 0, ret3 = 0; > + int ret = 0, ret2 = 0, ret3 = 0; > int retries = 0; > int depth = 0; > struct ext4_map_blocks map; > @@ -4408,7 +4407,7 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset, > depth = ext_depth(inode); > > retry: > - while (ret >= 0 && len) { > + while (len) { > /* > * Recalculate credits when extent tree depth changes. > */ > @@ -4430,9 +4429,13 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset, > inode->i_ino, map.m_lblk, > map.m_len, ret); > ext4_mark_inode_dirty(handle, inode); > - ret2 = ext4_journal_stop(handle); > + ext4_journal_stop(handle); > break; > } > + /* > + * allow a full retry cycle for any remaining allocations > + */ > + retries = 0; > map.m_lblk += ret; > map.m_len = len = len - ret; > epos = (loff_t)map.m_lblk << inode->i_blkbits; > @@ -4450,11 +4453,8 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset, > if (unlikely(ret2)) > break; > } > - if (ret == -ENOSPC && > - ext4_should_retry_alloc(inode->i_sb, &retries)) { > - ret = 0; > + if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) > goto retry; > - } > > return ret > 0 ? ret2 : ret; > } > -- > 2.20.1 > -- Jan Kara SUSE Labs, CR