Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3580316pxb; Fri, 4 Feb 2022 11:35:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJw1EyA5v6A5pmyg4/0FW1oaUj0Paode0WdG1e48jmskRJdN45QX9AyTA4Cky4vWuq0IvJEC X-Received: by 2002:a17:902:c612:: with SMTP id r18mr4836004plr.64.1644003303241; Fri, 04 Feb 2022 11:35:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644003303; cv=none; d=google.com; s=arc-20160816; b=w/8wdSy454723Gyxt8fUyFmAzGkStKeKvONjG9EBaOSaRfQ4EqFKQzyPi/Rv3nhaGe LkbikW6BZoRFDAU5tP4tE+dsVKj/CNDVXtB7S9NALXvCQZHOzhs6LL/vUqihc759iuck Fk1vVwjbPJGgJ/LgzkLjXVnKrdD2+deqb/nErAAuWAJUlNh2A0B+l4JpLInhBOnP5xNB fGnj/2KkuRj3hedwWnVTTRW8KdgNz9zP8Ii6TRmDjwHP1REwIGPuqGZyZW7v7JAph1So /PG+Z4xlH6NQls/BOKwAnxG9ZdIf0J+5cpAdFUrEfmxFIepWvyUdZrleLqCXSFaZCsbn tKOw== 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=iZDEhy/NiFHNyKm3O94Qbyibs0mtD/OXpCE8gCcS7VA=; b=bWxtOA0SGrO38Mi+1iSfu1Ks+P0ggqiqXEtU5sMgIXgkhjDlEAHIXUiLD6aeKA87Zq 0ghcdOlf8jouP/55NHo4vgvtcIA/MCLbeW6rdq3ky/5MoKVU/yZs+Hjv23odLj9l1YaR E82DMHaqU5ccPF3jC7nqlzhDsqF4uPCeE5ZkcXyK1QvxkyOtKh4M8tYJ4O5XtH86dS/O lsB/dUO4ftHwo7vPvjfTNbDj7FNrNHKJo9oE4AzbuICadSODkWO/LX8CfARPpGUpocz0 S6oX3b2nQRW9HZJTt7ps6yCCNWToGZfg4xUDDOjCvoWMUuYaCx9fFz5+Jh1A4mTfgeQb sG/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=P3Jmc+AJ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bm10si3357406pgb.415.2022.02.04.11.34.45; Fri, 04 Feb 2022 11:35:03 -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; dkim=pass header.i=@ibm.com header.s=pp1 header.b=P3Jmc+AJ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237600AbiBDKI4 (ORCPT + 99 others); Fri, 4 Feb 2022 05:08:56 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:21712 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234330AbiBDKIz (ORCPT ); Fri, 4 Feb 2022 05:08:55 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2147x9hr023912; Fri, 4 Feb 2022 10:08:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=pp1; bh=iZDEhy/NiFHNyKm3O94Qbyibs0mtD/OXpCE8gCcS7VA=; b=P3Jmc+AJuB7r0VrkII+5/q1HAg/IKRhCxfsvV8kcIyo1Vd3rJ84mlF8GsRjnW1Jh5mnT 0nIpWn+hMh8NSl3CZw+KPvbSSaQZjswE1hDyL+o7CJeKUZt6r+XvI4sXOU/oD6YziVWs Ki176MQDd+cWOf9YfcYWFCDthTeSVojE9KRAhNDmGs0YhfiM8EkFAQEznZiXXMnlyLha dfuwuMOC22AKeiJ9U6rplA+ghv1Etm/niVp3sZaGVw4xenk1IOF/aMl7TvMPVKO0YaLq yxvk2c5Z7GmXfekCEgJb4GqBVwk5T41oKyLi+gU2RNxwFONDkOAcMmeC8TNVBloEfdC3 Yg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0qxft3m0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 10:08:50 +0000 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 2149ixGa012267; Fri, 4 Feb 2022 10:08:50 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e0qxft3ke-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 10:08:50 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 214A7BHh002476; Fri, 4 Feb 2022 10:08:48 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04fra.de.ibm.com with ESMTP id 3e0r0u3avh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Feb 2022 10:08:48 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 214A8j4j40108542 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Feb 2022 10:08:45 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BCBDCA4054; Fri, 4 Feb 2022 10:08:45 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4ACB1A4064; Fri, 4 Feb 2022 10:08:45 +0000 (GMT) Received: from localhost (unknown [9.43.61.133]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 4 Feb 2022 10:08:45 +0000 (GMT) Date: Fri, 4 Feb 2022 15:38:44 +0530 From: Ritesh Harjani To: Jan Kara Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, "Theodore Ts'o" , Harshad Shirwadkar Subject: Re: [RFC 2/6] ext4: Implement ext4_group_block_valid() as common function Message-ID: <20220204100844.ty23mdc5mfjbgiwj@riteshh-domain> References: <40c85b86dd324a11c962843d8ef242780a84b25f.1643642105.git.riteshh@linux.ibm.com> <20220201113453.exaikdfsc3vubqel@quack3.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220201113453.exaikdfsc3vubqel@quack3.lan> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: FUfWL4cNtv3hYdo_7EsBDY84iuqf8TD4 X-Proofpoint-ORIG-GUID: zMJWEXrYR61wFRp4z7SbRcO6YtSL6OQY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-04_03,2022-02-03_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 mlxlogscore=635 clxscore=1015 lowpriorityscore=0 adultscore=0 mlxscore=0 spamscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202040054 Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 22/02/01 12:34PM, Jan Kara wrote: > On Mon 31-01-22 20:46:51, Ritesh Harjani wrote: > > This patch implements ext4_group_block_valid() check functionality, > > and refactors all the callers to use this common function instead. > > > > Signed-off-by: Ritesh Harjani > ... > > > diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c > > index 8d23108cf9d7..60d32d3d8dc4 100644 > > --- a/fs/ext4/mballoc.c > > +++ b/fs/ext4/mballoc.c > > @@ -6001,13 +6001,7 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, > > goto error_return; > > } > > > > - if (in_range(ext4_block_bitmap(sb, gdp), block, count) || > > - in_range(ext4_inode_bitmap(sb, gdp), block, count) || > > - in_range(block, ext4_inode_table(sb, gdp), > > - sbi->s_itb_per_group) || > > - in_range(block + count - 1, ext4_inode_table(sb, gdp), > > - sbi->s_itb_per_group)) { > > - > > + if (!ext4_group_block_valid(sb, block_group, block, count)) { > > ext4_error(sb, "Freeing blocks in system zone - " > > "Block = %llu, count = %lu", block, count); > > /* err = 0. ext4_std_error should be a no op */ > > When doing this, why not rather directly use ext4_inode_block_valid() here? This is because while freeing these blocks we have their's corresponding block group too. So there is little point in checking FS Metadata of all block groups v/s FS Metadata of just this block group, no? Also, I am not sure if we changing this to check against system-zone's blocks (which has FS Metadata blocks from all block groups), can add any additional penalty? -riteshh > > > @@ -6194,11 +6188,7 @@ int ext4_group_add_blocks(handle_t *handle, struct super_block *sb, > > goto error_return; > > } > > > > - if (in_range(ext4_block_bitmap(sb, desc), block, count) || > > - in_range(ext4_inode_bitmap(sb, desc), block, count) || > > - in_range(block, ext4_inode_table(sb, desc), sbi->s_itb_per_group) || > > - in_range(block + count - 1, ext4_inode_table(sb, desc), > > - sbi->s_itb_per_group)) { > > + if (!ext4_group_block_valid(sb, block_group, block, count)) { > > ext4_error(sb, "Adding blocks in system zones - " > > "Block = %llu, count = %lu", > > block, count); > > And here I'd rather refactor ext4_inode_block_valid() a bit to provide a > more generic helper not requiring an inode and use it here... > > Honza > -- > Jan Kara > SUSE Labs, CR