Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2655181pxb; Thu, 3 Feb 2022 11:08:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxLC76/xRQDELEjpDsmYIqLLJr+wj7zsBiv9QnDTCCOI99r1iZaGhZMxpr8QWfJhmtIP2Z5 X-Received: by 2002:a17:907:7242:: with SMTP id ds2mr24231682ejc.181.1643915292000; Thu, 03 Feb 2022 11:08:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643915291; cv=none; d=google.com; s=arc-20160816; b=rbW3iZrVbgYQ8ZDdnNhwKP65c9ZMfM1d4d1VtcEIrBb1PNdzfgAWBaXhWrXCRNlryF LYPZu4M+XNK3OpIVE/fQ12zw11ZNg+EIF2+CTTWglE79pVI/RgC17ZNHvxPuBjtlacjV cyTnUlZheIXDwTIzNwxtaMDyAcDVTyp3EFZpvCU6P91hHaAbcqqiP4GptvX0oMcXafK9 PA6fABAbzw+rY9NGYoFo7PjBuJvUWNTfVoX+r7ySQeWfR9gocOZyloSXT+FpaC+OsMW/ y22Kd2ibIe7u4qvkMin1kb73LV0+Ihvf7uckjwfPVgzc/+anm1pgRsLbcPmfhe1b42Kx ONHg== 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 :dkim-signature; bh=HbuHJy6CrGouy41rG/0CABF4plHh4zuZeKwTmZ0I87M=; b=P2/xSvUX4PdvSiiicW3+Y7h01EyXV1ZqXNHKMdjwdAKSmkvsS6ZbY/AC2sI9Vl/rCu 5M7OJA6msj7Bb9lqXYYQ1KGMLXCLBHHW/uoQVNWqYAQNk8rgddfRl2xK/ulPSVdgk/MY 05aW/3MfdVHZSls93PtIWWg86cV4S3/aO2wUf3NMKsuP44nH6phzZYX1qqkB5SurcvRS hLCJB1AKeRsTtuN86UzBMdPZJ2Z/4o7J/Thj1VT7qTW4uGFNxNl7sYVOpKm10vZ99QK9 dy+ekjGnDLAFwsz8/NG/lB7JoMN9yR7m7jdURu9N5kSGnxcx9LBF43g+kkjIABzlB4om K+3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=jN3XkKHu; dkim=neutral (no key) header.i=@suse.cz header.b=4z4TZZG2; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh14si14030711ejc.266.2022.02.03.11.07.40; Thu, 03 Feb 2022 11:08:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=jN3XkKHu; dkim=neutral (no key) header.i=@suse.cz header.b=4z4TZZG2; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235649AbiBALez (ORCPT + 99 others); Tue, 1 Feb 2022 06:34:55 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:56532 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233560AbiBALey (ORCPT ); Tue, 1 Feb 2022 06:34:54 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D9B6221100; Tue, 1 Feb 2022 11:34:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1643715293; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HbuHJy6CrGouy41rG/0CABF4plHh4zuZeKwTmZ0I87M=; b=jN3XkKHuR1+Dgaa0woCbskeD/BMUSPvAIfspTTI7lz8xXsxrL1rYj/S6aYhYdyK1Krgxd0 foedoVB0rgzGIjHYzLbfXrWaJ/YBuDdIlHLMGKLUEddXvki8Bjpm3XD7M+uEdMSzNN1X+5 4tlUc1bX1EWDEenV9f8knHmLuS2YY20= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1643715293; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HbuHJy6CrGouy41rG/0CABF4plHh4zuZeKwTmZ0I87M=; b=4z4TZZG2d+m1zkOx3yIEl2luWzPPMsfJns0B4Y+NapWd3+xFv4XDLD6IElTBWf/wnViBcn btjVRaqVGXlJoYBQ== Received: from quack3.suse.cz (unknown [10.163.28.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id C4B8EA3B83; Tue, 1 Feb 2022 11:34:53 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id 39F37A05B1; Tue, 1 Feb 2022 12:34:53 +0100 (CET) Date: Tue, 1 Feb 2022 12:34:53 +0100 From: Jan Kara To: Ritesh Harjani Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, Theodore Ts'o , Jan Kara , Harshad Shirwadkar Subject: Re: [RFC 2/6] ext4: Implement ext4_group_block_valid() as common function Message-ID: <20220201113453.exaikdfsc3vubqel@quack3.lan> References: <40c85b86dd324a11c962843d8ef242780a84b25f.1643642105.git.riteshh@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <40c85b86dd324a11c962843d8ef242780a84b25f.1643642105.git.riteshh@linux.ibm.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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? > @@ -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