Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3850340ybx; Mon, 4 Nov 2019 03:58:52 -0800 (PST) X-Google-Smtp-Source: APXvYqykgiWmUrbeGSMr4ntZQ8hCk2V8mn25ggcQQWtz/9eRxIR7dtbpZZjQfpuxVbCNKwP+8Bta X-Received: by 2002:a50:cc43:: with SMTP id n3mr29360656edi.287.1572868732724; Mon, 04 Nov 2019 03:58:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1572868732; cv=pass; d=google.com; s=arc-20160816; b=DJt3FwY9DZgHDrgHVEPZmQQ3e+PiJAasSGys4ZZIm1bltKUYhZ+UH7aoTHIn6MNGkh 0c6JhKStPgvfCZZydyhsIufOeUmMgbW/rREL7JD1blA56KQNbohUQ0M0n41aovmqfXZq VmZ8RmflIN8NuMJTj0BQcFxplue7s+7o4j3wIuNkxES1Lmp+/VY+qG7N/8OUF9zBRMwG iMJUMgM5q25g04ZHm7w4WJ4wCL0qEZGgM+RilEViHGh4Ea+U6rzeE5P42Mtd06WwAGMf ajL7MNkBsRMP1wnARFyIPyEVer81lL8BQgTVXdrtXLPRPLP6EXdoSRFyScUFLeufv+J3 8JCQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :date:subject:message-id:cc:to:from:dkim-signature; bh=m6R7At4+C/REK1yLQtQ2YRUko1s/FbpG1OERsvSbHl0=; b=vAmv3d00qWNUjzQGCFaRDwCrKERTb4rq4Czz/upLkaQnRpq2mBiGMHTD9pSi8SELVP np6dGZtAEa/7ydLO6H/ksuTOOUDlA5oGZrQuccCfZ2D+bMsdnvuxyTU0fD2Yyb2btN1q 30PbAAdQq6ozmwnJ85rBhVWGAAJoaqazv/9E8gyQ5vobg80CiN22ukPOTibHuEn2BmgT 5wn8bNABkJBzRjjt0lwrhQo46nwHsZ1aK1MAnFVAkPoDlmqqY/tFoPNpDbsaBU0c5lrH Vg2TAL/9GU8kCM2WJFh7Svjp60WnfJYolLtS6nbGBZCXAW3BwhK9yzNHJ0e0pnF9xpBz 76og== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mykernel.net header.s=zohomail header.b=gxwq13VV; arc=pass (i=1 spf=pass spfdomain=mykernel.net dkim=pass dkdomain=mykernel.net dmarc=pass fromdomain=mykernel.net>); 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 s20si7061455edd.294.2019.11.04.03.58.28; Mon, 04 Nov 2019 03:58:52 -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; dkim=pass header.i=@mykernel.net header.s=zohomail header.b=gxwq13VV; arc=pass (i=1 spf=pass spfdomain=mykernel.net dkim=pass dkdomain=mykernel.net dmarc=pass fromdomain=mykernel.net>); 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 S1728847AbfKDL4N (ORCPT + 99 others); Mon, 4 Nov 2019 06:56:13 -0500 Received: from sender3-of-o52.zoho.com.cn ([124.251.121.247]:21922 "EHLO sender2.zoho.com.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727663AbfKDL4N (ORCPT ); Mon, 4 Nov 2019 06:56:13 -0500 X-Greylist: delayed 906 seconds by postgrey-1.27 at vger.kernel.org; Mon, 04 Nov 2019 06:56:09 EST ARC-Seal: i=1; a=rsa-sha256; t=1572867659; cv=none; d=zoho.com.cn; s=zohoarc; b=rY0x6zTB1/c6EuqPvJdRCRxK2Zmh5ahjD6H0UhscfMqrQgG/JnFwr/GD1YbAEUEYWSTYscE/j4tV/afSiL3HGYLWZVU4EtP9oPH4FfoWge1R2VCn/+hxyAhVUVCOTVgp/07DZP8VYCNdcfTwYIC45tcfApYyfN+ExR38mnvPzG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1572867659; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=m6R7At4+C/REK1yLQtQ2YRUko1s/FbpG1OERsvSbHl0=; b=JszRGn+O6CaXfIjFC1tCBx04qZqb7g1MSdQVik8EunfaP5Uti7c9V2jNAasnbsxxUjecoGNe+yg9cltkb8ckhCWpxMLrM1TypURh5ZUZVydQxGM7hwSzSqVKzyvq4Z9wBqKMZ9vYsAEbdBrtvRQKN5/BZ2fpi+ctcbJpuTB431s= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1572867659; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Transfer-Encoding:Content-Type; l=1133; bh=m6R7At4+C/REK1yLQtQ2YRUko1s/FbpG1OERsvSbHl0=; b=gxwq13VVxOr6+wye9SLbLj4GowWQl4UTkyAF74g2WI6Fqr53C0ZWAnl/G4Fpkxbz seGIOXtzs5516O3kbs9YGYU5EaFazN6p37JToyk+7I+vKNyj6pntrWFuhQ/3rvy6BOH r9scbX+HDuw/FxaWNJctJL+L0E3Dz7ekv/Y5ljUA= Received: from localhost.localdomain (218.18.229.179 [218.18.229.179]) by mx.zoho.com.cn with SMTPS id 15728676574231004.4041585412566; Mon, 4 Nov 2019 19:40:57 +0800 (CST) From: Chengguang Xu To: jack@suse.com Cc: linux-ext4@vger.kernel.org, Chengguang Xu Message-ID: <20191104114036.9893-1-cgxu519@mykernel.net> Subject: [PATCH 1/5] ext2: introduce new helper ext2_group_last_block_no() Date: Mon, 4 Nov 2019 19:40:32 +0800 X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoCNMailClient: External Content-Type: text/plain; charset=utf8 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Introduce new helper ext2_group_last_block_no() to calculate last block num for specific block group, we can replace open coded logic by calling this common helper. Signed-off-by: Chengguang Xu --- fs/ext2/ext2.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index 10ab238de9a6..8178bd38a9d6 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h @@ -813,6 +813,18 @@ ext2_group_first_block_no(struct super_block *sb, unsi= gned long group_no) =09=09le32_to_cpu(EXT2_SB(sb)->s_es->s_first_data_block); } =20 +static inline ext2_fsblk_t +ext2_group_last_block_no(struct super_block *sb, unsigned long group_no) +{ +=09struct ext2_sb_info *sbi =3D EXT2_SB(sb); + +=09if (group_no =3D=3D sbi->s_groups_count - 1) +=09=09return le32_to_cpu(sbi->s_es->s_blocks_count) - 1; +=09else +=09=09return ext2_group_first_block_no(sb, group_no) + +=09=09=09EXT2_BLOCKS_PER_GROUP(sb) - 1; +} + #define ext2_set_bit=09__test_and_set_bit_le #define ext2_clear_bit=09__test_and_clear_bit_le #define ext2_test_bit=09test_bit_le --=20 2.20.1