Skip to contentSkip to conversation

f2fs: no need to flush NAT bits if no enough space

PATCH In review Weichao Guo 2 participants 4 messages Feb 5, 2018 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: no need to flush NAT bits if no enough space

NAT bits are saved at spare space in CP pack. Flushed NAT bits may be overwritten by the CP pack if there is no enough space for NAT bits. And NAT bits will be obsolesced at next mount time if crc|cp_ver not matched. So just skip to flush NAT bits in such needless cases.

---
 fs/f2fs/checkpoint.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/checkpoint.c +3 -1
index 0eaafb8..bdc03c9 100644
@@ -1248,7 +1248,9 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 	start_blk = __start_cp_next_addr(sbi);
 
 	/* write nat bits */
-	if (enabled_nat_bits(sbi, cpc)) {
+	if (enabled_nat_bits(sbi, cpc) &&
+			le32_to_cpu(ckpt->cp_pack_total_block_count) <=
+			sbi->blocks_per_seg - NM_I(sbi)->nat_bits_blocks) {
 		__u64 cp_ver = cur_cp_version(ckpt);
 		block_t blk;
 
Signature · 6 lines
2.10.1


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

NAT bits are saved at spare space in CP pack. Flushed NAT bits may be overwritten by the CP pack if there is no enough space for NAT bits. And NAT bits will be obsolesced at next mount time

Sorry, there is a typo here. 'obsolesced' should be obsolete.

Thanks,

Quoted 14 lines

if crc|cp_ver not matched. So just skip to flush NAT bits in such needless cases.

---
 fs/f2fs/checkpoint.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/checkpoint.c +0 -0
index 0eaafb8..bdc03c9 100644

fs/f2fs/checkpoint.c static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) · line 1256

Quoted 10 lines
fs/f2fs/checkpoint.c +3 -1
@@ -1248,7 +1248,9 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 	start_blk = __start_cp_next_addr(sbi);
 
 	/* write nat bits */
-	if (enabled_nat_bits(sbi, cpc)) {
+	if (enabled_nat_bits(sbi, cpc) &&
+			le32_to_cpu(ckpt->cp_pack_total_block_count) <=
+			sbi->blocks_per_seg - NM_I(sbi)->nat_bits_blocks) {
 		__u64 cp_ver = cur_cp_version(ckpt);
 		block_t blk;
 

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

#2 lore raw
In reply to Weichao Guo
Quoted 16 lines · Weichao Guo

NAT bits are saved at spare space in CP pack. Flushed NAT bits may be overwritten by the CP pack if there is no enough space for NAT bits. And NAT bits will be obsolesced at next mount time if crc|cp_ver not matched. So just skip to flush NAT bits in such needless cases.

---
 fs/f2fs/checkpoint.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/checkpoint.c +0 -0
index 0eaafb8..bdc03c9 100644

fs/f2fs/checkpoint.c static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) · line 1253

Quoted 7 lines
fs/f2fs/checkpoint.c +3 -1
@@ -1248,7 +1248,9 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 	start_blk = __start_cp_next_addr(sbi);
 
 	/* write nat bits */
-	if (enabled_nat_bits(sbi, cpc)) {
+	if (enabled_nat_bits(sbi, cpc) &&
+			le32_to_cpu(ckpt->cp_pack_total_block_count) <=
+			sbi->blocks_per_seg - NM_I(sbi)->nat_bits_blocks) {

Have checked this condition in update_ckpt_flags, right?

thanks,

fs/f2fs/checkpoint.c static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) · line 1256

Quoted 4 lines
fs/f2fs/checkpoint.c +0 -0
 		__u64 cp_ver = cur_cp_version(ckpt);
 		block_t blk;
 

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

author
#3 lore raw
Quoted 19 lines · Chao Yu
Quoted 18 lines · Weichao Guo

NAT bits are saved at spare space in CP pack. Flushed NAT bits may be overwritten by the CP pack if there is no enough space for NAT bits. And NAT bits will be obsolesced at next mount time if crc|cp_ver not matched. So just skip to flush NAT bits in such needless cases.

---
 fs/f2fs/checkpoint.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/checkpoint.c +0 -0
index 0eaafb8..bdc03c9 100644
@@ -1248,7 +1248,9 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 	start_blk = __start_cp_next_addr(sbi);
 
Quoted 7 lines

fs/f2fs/checkpoint.c static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) · line 1253

Quoted 5 lines
fs/f2fs/checkpoint.c +3 -1
 	/* write nat bits */
-	if (enabled_nat_bits(sbi, cpc)) {
+	if (enabled_nat_bits(sbi, cpc) &&
+			le32_to_cpu(ckpt->cp_pack_total_block_count) <=
+			sbi->blocks_per_seg - NM_I(sbi)->nat_bits_blocks) {

Have checked this condition in update_ckpt_flags, right?

Oh,yes. It's my mistake.

Thanks,

Quoted 11 lines

thanks,

fs/f2fs/checkpoint.c static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) · line 1256

Quoted 4 lines
fs/f2fs/checkpoint.c +0 -0
 		__u64 cp_ver = cur_cp_version(ckpt);
 		block_t blk;
 

.

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