linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] ext2: introduce new helper ext2_group_last_block_no()
@ 2019-11-04 11:40 Chengguang Xu
  2019-11-04 11:40 ` [PATCH 2/5] ext2: code cleanup by calling ext2_group_last_block_no() Chengguang Xu
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Chengguang Xu @ 2019-11-04 11:40 UTC (permalink / raw)
  To: jack; +Cc: linux-ext4, Chengguang Xu

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 <cgxu519@mykernel.net>
---
 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, unsigned long group_no)
 		le32_to_cpu(EXT2_SB(sb)->s_es->s_first_data_block);
 }
 
+static inline ext2_fsblk_t
+ext2_group_last_block_no(struct super_block *sb, unsigned long group_no)
+{
+	struct ext2_sb_info *sbi = EXT2_SB(sb);
+
+	if (group_no == sbi->s_groups_count - 1)
+		return le32_to_cpu(sbi->s_es->s_blocks_count) - 1;
+	else
+		return ext2_group_first_block_no(sb, group_no) +
+			EXT2_BLOCKS_PER_GROUP(sb) - 1;
+}
+
 #define ext2_set_bit	__test_and_set_bit_le
 #define ext2_clear_bit	__test_and_clear_bit_le
 #define ext2_test_bit	test_bit_le
-- 
2.20.1




^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-11-07 11:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-04 11:40 [PATCH 1/5] ext2: introduce new helper ext2_group_last_block_no() Chengguang Xu
2019-11-04 11:40 ` [PATCH 2/5] ext2: code cleanup by calling ext2_group_last_block_no() Chengguang Xu
2019-11-06 15:42   ` Jan Kara
2019-11-07  2:54     ` Chengguang Xu
2019-11-07  9:21       ` Jan Kara
2019-11-07  9:44         ` Chengguang Xu
2019-11-07 11:36           ` Jan Kara
2019-11-04 11:40 ` [PATCH 3/5] ext2: skip unnecessary operations in ext2_try_to_allocate() Chengguang Xu
2019-11-04 11:40 ` [PATCH 4/5] ext2: code cleanup for ext2_try_to_allocate() Chengguang Xu
2019-11-06 15:59   ` Jan Kara
2019-11-07  2:58     ` Chengguang Xu
2019-11-04 11:40 ` [PATCH 5/5] ext2: fix improper function comment Chengguang Xu
2019-11-06 16:01   ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).