Skip to contentSkip to conversation

f2fs: Allocate and stat mem used by free nid bitmap more accurately

PATCH Superseded Yunlei He 2 participants 2 messages Jun 27, 2018 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH 1/1 f2fs: Allocate and stat mem used by free nid bitmap more accurately

This patch used f2fs_bitmap_size macro to calculate mem used by free nid bitmap, and stat used mem including aligned part.

---
 fs/f2fs/debug.c         | 2 +-
 include/linux/f2fs_fs.h | 5 +----
 2 files changed, 2 insertions(+), 5 deletions(-)
fs/f2fs/debug.c +1 -1
index 2d65e77..a1f24c5 100644
@@ -215,7 +215,7 @@ static void update_mem_info(struct f2fs_sb_info *sbi)
 	si->base_mem += sizeof(struct f2fs_nm_info);
 	si->base_mem += __bitmap_size(sbi, NAT_BITMAP);
 	si->base_mem += (NM_I(sbi)->nat_bits_blocks << F2FS_BLKSIZE_BITS);
-	si->base_mem += NM_I(sbi)->nat_blocks * NAT_ENTRY_BITMAP_SIZE;
+	si->base_mem += NM_I(sbi)->nat_blocks * NAT_ENTRY_BITMAP_SIZE_ALIGNED;
 	si->base_mem += NM_I(sbi)->nat_blocks / 8;
 	si->base_mem += NM_I(sbi)->nat_blocks * sizeof(unsigned short);
 
include/linux/f2fs_fs.h +1 -4
index aa5db8b..4fa7e5e 100644
@@ -304,10 +304,7 @@ struct f2fs_node {
  * For NAT entries
  */
 #define NAT_ENTRY_PER_BLOCK (PAGE_SIZE / sizeof(struct f2fs_nat_entry))
-#define NAT_ENTRY_BITMAP_SIZE	((NAT_ENTRY_PER_BLOCK + 7) / 8)
-#define NAT_ENTRY_BITMAP_SIZE_ALIGNED				\
-	((NAT_ENTRY_BITMAP_SIZE + BITS_PER_LONG - 1) /		\
-	BITS_PER_LONG * BITS_PER_LONG)
+#define NAT_ENTRY_BITMAP_SIZE_ALIGNED	f2fs_bitmap_size(NAT_ENTRY_PER_BLOCK)
 
 
 struct f2fs_nat_entry {
Signature · 6 lines
1.9.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
#1 lore raw
Quoted 2 lines · Yunlei He

This patch used f2fs_bitmap_size macro to calculate mem used by free nid bitmap, and stat used mem including aligned part.

We can remove both NAT_ENTRY_BITMAP_SIZE and NAT_ENTRY_BITMAP_SIZE_ALIGNED, and then using f2fs_bitmap_size instead.

Thanks,

Quoted 27 lines
---
 fs/f2fs/debug.c         | 2 +-
 include/linux/f2fs_fs.h | 5 +----
 2 files changed, 2 insertions(+), 5 deletions(-)
fs/f2fs/debug.c +1 -1
index 2d65e77..a1f24c5 100644
@@ -215,7 +215,7 @@ static void update_mem_info(struct f2fs_sb_info *sbi)
 	si->base_mem += sizeof(struct f2fs_nm_info);
 	si->base_mem += __bitmap_size(sbi, NAT_BITMAP);
 	si->base_mem += (NM_I(sbi)->nat_bits_blocks << F2FS_BLKSIZE_BITS);
-	si->base_mem += NM_I(sbi)->nat_blocks * NAT_ENTRY_BITMAP_SIZE;
+	si->base_mem += NM_I(sbi)->nat_blocks * NAT_ENTRY_BITMAP_SIZE_ALIGNED;
 	si->base_mem += NM_I(sbi)->nat_blocks / 8;
 	si->base_mem += NM_I(sbi)->nat_blocks * sizeof(unsigned short);
 
include/linux/f2fs_fs.h +0 -0
index aa5db8b..4fa7e5e 100644
@@ -304,10 +304,7 @@ struct f2fs_node {
  * For NAT entries

include/linux/f2fs_fs.h struct f2fs_node { · line 310

Quoted 10 lines
include/linux/f2fs_fs.h +1 -4
  */
 #define NAT_ENTRY_PER_BLOCK (PAGE_SIZE / sizeof(struct f2fs_nat_entry))
-#define NAT_ENTRY_BITMAP_SIZE	((NAT_ENTRY_PER_BLOCK + 7) / 8)
-#define NAT_ENTRY_BITMAP_SIZE_ALIGNED				\
-	((NAT_ENTRY_BITMAP_SIZE + BITS_PER_LONG - 1) /		\
-	BITS_PER_LONG * BITS_PER_LONG)
+#define NAT_ENTRY_BITMAP_SIZE_ALIGNED	f2fs_bitmap_size(NAT_ENTRY_PER_BLOCK)
 
 
 struct f2fs_nat_entry {

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot