Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp849375ybx; Thu, 7 Nov 2019 03:37:40 -0800 (PST) X-Google-Smtp-Source: APXvYqw1XSoefKzJFSjWEDVn40heCpoGiQrhu7MDJlVZfl/EQIBIV9+au/+wtuoxDYICvJI7qBLj X-Received: by 2002:a17:906:1982:: with SMTP id g2mr2522358ejd.254.1573126660783; Thu, 07 Nov 2019 03:37:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573126660; cv=none; d=google.com; s=arc-20160816; b=oZnEXTpURY7d7WiWI8zH/41Mbm0Hi9f22paTo6k/JvmKxCD+aOjaaoLB5qdZAcHZod 4CjiBtQJ/tR5zDksu6JLx5sL/UcvMWfqyImwK90/bhBbEV3iREvzz1lsYt5SqL18SKnR f2QpoJruyQH8MQj0dq2lZxiHjCL/zW2MRAlirA0UKIpz4F8sBzbT1vuroZj/qgxmB7kz LT5bMpLrlpCRuRStdXqC/IFCECxzH6VGj62QO+Zl2xZ+GWCNlurnUanmP9zk0FayREun khHdVX3J/ZlhbBmC/gumajwP9l8MbymPb0JQIGX6gNqF+WtX+C21Ng0aVQG5qLnEwLEY 0pmw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=MAOGcyZWafkNkhAjatqvX+rimcmNXNTsKgwscvPjg08=; b=PtgQliNWvwCGVeGcC62Am6EdtC5Jyvil46aPNOECP5LX7JdWoqym1U+liH7k2g0heQ skx6OvUQOJuV5Vm0eU8SgtjpzucxnEXkVgjREvMT5Y4nmyhbMS0iIZB9HdxybSwLd6iG kncBbLf36pKgxJOyHcF/na+pVUlDBvR+64jjYAadfTTU9Z2gQoJwymNoT+g0kDWA3wy7 QBpLDyTf+YVhG/Gb2t5tX3ot+FoQCCyEf/U1m5fWCLHydlOgAcPvmH/9UJbmYyQbb/Ts ulY45LRhUSi7N7EczQ/eLJG4sKOiJPrQ5jfbBYgIIwOhxsj6VfaJYfhm1mzWtLIdnQfs UTCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a47si1011429edc.145.2019.11.07.03.37.10; Thu, 07 Nov 2019 03:37:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388116AbfKGLgp (ORCPT + 99 others); Thu, 7 Nov 2019 06:36:45 -0500 Received: from mx2.suse.de ([195.135.220.15]:44440 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727278AbfKGLgp (ORCPT ); Thu, 7 Nov 2019 06:36:45 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 655E1AFBA; Thu, 7 Nov 2019 11:36:43 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id C1D621E4415; Thu, 7 Nov 2019 12:36:42 +0100 (CET) Date: Thu, 7 Nov 2019 12:36:42 +0100 From: Jan Kara To: Chengguang Xu Cc: Jan Kara , jack , linux-ext4 Subject: Re: [PATCH 2/5] ext2: code cleanup by calling ext2_group_last_block_no() Message-ID: <20191107113642.GB11400@quack2.suse.cz> References: <20191104114036.9893-1-cgxu519@mykernel.net> <20191104114036.9893-2-cgxu519@mykernel.net> <20191106154236.GB12685@quack2.suse.cz> <16e43c91b4e.12c0f5d17918.413402503051848643@mykernel.net> <20191107092117.GA11400@quack2.suse.cz> <16e45402a18.c7fb3dc01505.2507377017571315195@mykernel.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <16e45402a18.c7fb3dc01505.2507377017571315195@mykernel.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu 07-11-19 17:44:23, Chengguang Xu wrote: > ---- 在 星期四, 2019-11-07 17:21:17 Jan Kara 撰写 ---- > > On Thu 07-11-19 10:54:43, Chengguang Xu wrote: > > > ---- 在 星期三, 2019-11-06 23:42:36 Jan Kara 撰写 ---- > > > > On Mon 04-11-19 19:40:33, Chengguang Xu wrote: > > > > > Call common helper ext2_group_last_block_no() to > > > > > calculate group last block number. > > > > > > > > > > Signed-off-by: Chengguang Xu > > > > > > > > Thanks for the patch! I've applied it (as well as 1/5) and added attached > > > > simplification on top. > > > > > > > > > > In ext2_try_to_allocate() > > > > > > + if (my_rsv->_rsv_end < group_last_block) > > > + end = my_rsv->_rsv_end - group_first_block + 1; > > > + if (grp_goal < start || grp_goal > end) > > > > > > Based on original code, shouldn't it be if (grp_goal < start || grp_goal > > > >=end) ? > > > > Hum, that's a good point. The original code actually had an off-by-one bug > > because 'end' is really the last block that can be used so grp_goal == end > > still makes sense. And my cleanup fixed it. Now looking at the code in > > ext2_try_to_allocate() we also have a similar bug in the loop allocating > > blocks. There we can also go upto 'end' inclusive. Added a patch to fix > > that. Thanks for pointing me to this! > > > > Doesn't it depend on what starting number for grp_block inside block group? > if it starts from 0, is the end number block still available for allocation? Argh! You are right, I've misread the initialization of 'end' and that is really one block past the last one. I've fixed up things in my tree. Thanks for review! Honza -- Jan Kara SUSE Labs, CR