Skip to contentSkip to conversation

f2fs: add a segment and section num check in sanity_check_raw_super

PATCH Superseded Yunlei He 2 participants 6 messages Dec 26, 2015 – Dec 31, 2015 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH 1/1 f2fs: add a segment and section num check in sanity_check_raw_super

This patch add a mismatch check between segment and section in sanity_check_raw_super.

---
 fs/f2fs/super.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/f2fs/super.c +11 -0
index c3070c1..b51a690 100644
@@ -1036,6 +1036,17 @@ static int sanity_check_raw_super(struct super_block *sb,
 		return 1;
 	}
 
+	/* check seg # corresponding to sec # */
+	if (le32_to_cpu(raw_super->segment_count)
+			* le32_to_cpu(raw_super->segs_per_sec)
+				!= le32_to_cpu(raw_super->section_count)) {
+		f2fs_msg(sb, KERN_INFO,
+			"Mismatch seg num (%u) and sec num (%u) \n",
+			le32_to_cpu(raw_super->segment_count),
+			le32_to_cpu(raw_super->section_count));
+		return 1;
+	}
+
 	/* Currently, support 512/1024/2048/4096 bytes sector size */
 	if (le32_to_cpu(raw_super->log_sectorsize) >
 				F2FS_MAX_LOG_SECTOR_SIZE ||
Signature · 4 lines
1.9.1


------------------------------------------------------------------------------
author
#1 lore raw
Quoted 13 lines · Yunlei He

This patch add a mismatch check between segment and section in sanity_check_raw_super.

---
  fs/f2fs/super.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
fs/f2fs/super.c +0 -0
index c3070c1..b51a690 100644

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1041

Quoted 6 lines
fs/f2fs/super.c +3 -0
@@ -1036,6 +1036,17 @@ static int sanity_check_raw_super(struct super_block *sb,
  		return 1;
  	}
 
+	/* check seg # corresponding to sec # */
+	if (le32_to_cpu(raw_super->segment_count)
+			* le32_to_cpu(raw_super->segs_per_sec)

I am sorry that here is :

			/ le32_to_cpu(raw_super->segs_per_sec)

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1052

Quoted 12 lines
fs/f2fs/super.c +8 -0
+				!= le32_to_cpu(raw_super->section_count)) {
+		f2fs_msg(sb, KERN_INFO,
+			"Mismatch seg num (%u) and sec num (%u) \n",
+			le32_to_cpu(raw_super->segment_count),
+			le32_to_cpu(raw_super->section_count));
+		return 1;
+	}
+
  	/* Currently, support 512/1024/2048/4096 bytes sector size */
  	if (le32_to_cpu(raw_super->log_sectorsize) >
  				F2FS_MAX_LOG_SECTOR_SIZE ||

------------------------------------------------------------------------------

maintainer
#2 lore raw

Hi Yunlei,

Quoted 17 lines · He YunLei
Quoted 16 lines · Yunlei He

This patch add a mismatch check between segment and section in sanity_check_raw_super.

---
 fs/f2fs/super.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/f2fs/super.c +0 -0
index c3070c1..b51a690 100644
@@ -1036,6 +1036,17 @@ static int sanity_check_raw_super(struct super_block *sb,
 		return 1;
 	}
 
Quoted 2 lines

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1040

Quoted 2 lines
fs/f2fs/super.c +2 -0
+	/* check seg # corresponding to sec # */
+	if (le32_to_cpu(raw_super->segment_count)
			raw_super->segment_count_main ?

Thanks,

Quoted 4 lines

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1041

Quoted 1 line
fs/f2fs/super.c +1 -0
+			* le32_to_cpu(raw_super->segs_per_sec)

I am sorry that here is :

			/ le32_to_cpu(raw_super->segs_per_sec)
Quoted 12 lines

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1052

Quoted 12 lines
fs/f2fs/super.c +8 -0
+				!= le32_to_cpu(raw_super->section_count)) {
+		f2fs_msg(sb, KERN_INFO,
+			"Mismatch seg num (%u) and sec num (%u) \n",
+			le32_to_cpu(raw_super->segment_count),
+			le32_to_cpu(raw_super->section_count));
+		return 1;
+	}
+
 	/* Currently, support 512/1024/2048/4096 bytes sector size */
 	if (le32_to_cpu(raw_super->log_sectorsize) >
 				F2FS_MAX_LOG_SECTOR_SIZE ||

------------------------------------------------------------------------------

author
#3 lore raw
Quoted 20 lines · Jaegeuk Kim

Hi Yunlei,

Quoted 17 lines · He YunLei
Quoted 16 lines · Yunlei He

This patch add a mismatch check between segment and section in sanity_check_raw_super.

---
  fs/f2fs/super.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
fs/f2fs/super.c +0 -0
index c3070c1..b51a690 100644
@@ -1036,6 +1036,17 @@ static int sanity_check_raw_super(struct super_block *sb,
  		return 1;
  	}
 
Quoted 6 lines
Quoted 2 lines

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1040

Quoted 2 lines
fs/f2fs/super.c +2 -0
+	/* check seg # corresponding to sec # */
+	if (le32_to_cpu(raw_super->segment_count)
			raw_super->segment_count_main ?

Thanks,

yes, you are right, mistake also in f2fs_msg.

Quoted 9 lines
Quoted 9 lines

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1041

Quoted 2 lines
fs/f2fs/super.c +1 -0
+			* le32_to_cpu(raw_super->segs_per_sec)

I am sorry that here is :

			/ le32_to_cpu(raw_super->segs_per_sec)

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1045

Quoted 4 lines
fs/f2fs/super.c +4 -0
+				!= le32_to_cpu(raw_super->section_count)) {
+		f2fs_msg(sb, KERN_INFO,
+			"Mismatch seg num (%u) and sec num (%u) \n",
+			le32_to_cpu(raw_super->segment_count),

here is also need change:

			le32_to_cpu(raw_super->segment_count_main),

Thanks,

Quoted 11 lines
Quoted 8 lines

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1052

Quoted 8 lines
fs/f2fs/super.c +4 -0
+			le32_to_cpu(raw_super->section_count));
+		return 1;
+	}
+
  	/* Currently, support 512/1024/2048/4096 bytes sector size */
  	if (le32_to_cpu(raw_super->log_sectorsize) >
  				F2FS_MAX_LOG_SECTOR_SIZE ||

.

------------------------------------------------------------------------------

maintainer
#4 lore raw

Hi Yunlei,

Could you send a v2 for this?

Thanks,

Quoted 35 lines · He YunLei
Quoted 20 lines · Jaegeuk Kim

Hi Yunlei,

Quoted 17 lines · He YunLei
Quoted 16 lines · Yunlei He

This patch add a mismatch check between segment and section in sanity_check_raw_super.

---
 fs/f2fs/super.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
fs/f2fs/super.c +0 -0
index c3070c1..b51a690 100644
@@ -1036,6 +1036,17 @@ static int sanity_check_raw_super(struct super_block *sb,
 		return 1;
 	}
 
Quoted 6 lines
Quoted 2 lines

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1040

Quoted 2 lines
fs/f2fs/super.c +2 -0
+	/* check seg # corresponding to sec # */
+	if (le32_to_cpu(raw_super->segment_count)
			raw_super->segment_count_main ?

Thanks,

yes, you are right, mistake also in f2fs_msg.

Quoted 5 lines
Quoted 5 lines

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1041

Quoted 2 lines
fs/f2fs/super.c +1 -0
+			* le32_to_cpu(raw_super->segs_per_sec)

I am sorry that here is :

			/ le32_to_cpu(raw_super->segs_per_sec)
Quoted 18 lines
Quoted 4 lines
Quoted 4 lines

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1045

Quoted 4 lines
fs/f2fs/super.c +4 -0
+				!= le32_to_cpu(raw_super->section_count)) {
+		f2fs_msg(sb, KERN_INFO,
+			"Mismatch seg num (%u) and sec num (%u) \n",
+			le32_to_cpu(raw_super->segment_count),

here is also need change:

			le32_to_cpu(raw_super->segment_count_main),

Thanks,

Quoted 11 lines
Quoted 8 lines

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1052

Quoted 8 lines
fs/f2fs/super.c +4 -0
+			le32_to_cpu(raw_super->section_count));
+		return 1;
+	}
+
 	/* Currently, support 512/1024/2048/4096 bytes sector size */
 	if (le32_to_cpu(raw_super->log_sectorsize) >
 				F2FS_MAX_LOG_SECTOR_SIZE ||

.

------------------------------------------------------------------------------

author
#5 lore raw
Quoted 5 lines · Jaegeuk Kim

Hi Yunlei,

Could you send a v2 for this?

Thanks,

Hi Kim,

OK! I have sent it.

Thanks,

Quoted 56 lines · He YunLei
Quoted 35 lines · Jaegeuk Kim
Quoted 20 lines

Hi Yunlei,

Quoted 17 lines · He YunLei
Quoted 16 lines · Yunlei He

This patch add a mismatch check between segment and section in sanity_check_raw_super.

---
  fs/f2fs/super.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
fs/f2fs/super.c +0 -0
index c3070c1..b51a690 100644
@@ -1036,6 +1036,17 @@ static int sanity_check_raw_super(struct super_block *sb,
  		return 1;
  	}
 
Quoted 6 lines
Quoted 2 lines

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1040

Quoted 2 lines
fs/f2fs/super.c +2 -0
+	/* check seg # corresponding to sec # */
+	if (le32_to_cpu(raw_super->segment_count)
			raw_super->segment_count_main ?

Thanks,

yes, you are right, mistake also in f2fs_msg.

Quoted 5 lines
Quoted 5 lines

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1041

Quoted 2 lines
fs/f2fs/super.c +1 -0
+			* le32_to_cpu(raw_super->segs_per_sec)

I am sorry that here is :

			/ le32_to_cpu(raw_super->segs_per_sec)
Quoted 18 lines
Quoted 4 lines
Quoted 4 lines

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1045

Quoted 4 lines
fs/f2fs/super.c +4 -0
+				!= le32_to_cpu(raw_super->section_count)) {
+		f2fs_msg(sb, KERN_INFO,
+			"Mismatch seg num (%u) and sec num (%u) \n",
+			le32_to_cpu(raw_super->segment_count),

here is also need change:

			le32_to_cpu(raw_super->segment_count_main),

Thanks,

Quoted 11 lines
Quoted 8 lines

fs/f2fs/super.c static int sanity_check_raw_super(struct super_block *sb, · line 1052

Quoted 8 lines
fs/f2fs/super.c +4 -0
+			le32_to_cpu(raw_super->section_count));
+		return 1;
+	}
+
  	/* Currently, support 512/1024/2048/4096 bytes sector size */
  	if (le32_to_cpu(raw_super->log_sectorsize) >
  				F2FS_MAX_LOG_SECTOR_SIZE ||

.

Quoted 2 lines

.

------------------------------------------------------------------------------