Skip to contentSkip to conversation

f2fs: use cur_map instead of ckpt_map

PATCH In review Yunlei He 3 participants 10 messages Apr 10, 2018 – Apr 20, 2018 F2FS file system

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH v2 1/1 f2fs: use cur_map instead of ckpt_map

In flush_sit_entries::add_discard_addrs path, cur_map and ckpt_map are the same, but in exist_trim_candidates::add_discard_addrs, cur_map is updated one, and newer than ckpt_map, so we need to use cur_map to check whether there are discard candidates.

v1->v2: one problem of check discard candidates reported by Chao, besides, update commit message.

---
 fs/f2fs/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +1 -1
index 5854cc4..f5d0499 100644
@@ -1559,7 +1559,7 @@ static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc,
 
 	/* SIT_VBLOCK_MAP_SIZE should be multiple of sizeof(unsigned long) */
 	for (i = 0; i < entries; i++)
-		dmap[i] = force ? ~ckpt_map[i] & ~discard_map[i] :
+		dmap[i] = force ? ~cur_map[i] & ~discard_map[i] :
 				(cur_map[i] ^ ckpt_map[i]) & ckpt_map[i];
 
 	while (force || SM_I(sbi)->dcc_info->nr_discards <=
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
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Yunlei He

In flush_sit_entries::add_discard_addrs path, cur_map and ckpt_map are the same, but in exist_trim_candidates::add_discard_addrs, cur_map is updated one, and newer than ckpt_map, so we need to use cur_map to check whether there are discard candidates.

v1->v2: one problem of check discard candidates reported by Chao, besides, update commit message.

Thanks,

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

maintainer
#2 lore raw
In reply to Yunlei He
Quoted 18 lines · Yunlei He

In flush_sit_entries::add_discard_addrs path, cur_map and ckpt_map are the same, but in exist_trim_candidates::add_discard_addrs, cur_map is updated one, and newer than ckpt_map, so we need to use cur_map to check whether there are discard candidates.

v1->v2: one problem of check discard candidates reported by Chao, besides, update commit message.

---
 fs/f2fs/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +0 -0
index 5854cc4..f5d0499 100644

fs/f2fs/segment.c static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc, · line 1562

Quoted 5 lines
fs/f2fs/segment.c +1 -1
@@ -1559,7 +1559,7 @@ static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc,
 
 	/* SIT_VBLOCK_MAP_SIZE should be multiple of sizeof(unsigned long) */
 	for (i = 0; i < entries; i++)
-		dmap[i] = force ? ~ckpt_map[i] & ~discard_map[i] :
+		dmap[i] = force ? ~cur_map[i] & ~discard_map[i] :

NAK. We're able to loose data for roll-forward recovery.

Quoted 5 lines
fs/f2fs/segment.c +0 -0
 				(cur_map[i] ^ ckpt_map[i]) & ckpt_map[i];
 
 	while (force || SM_I(sbi)->dcc_info->nr_discards <=
Signature · 1 line
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

#3 lore raw
Quoted 20 lines · Jaegeuk Kim
Quoted 19 lines · Yunlei He

In flush_sit_entries::add_discard_addrs path, cur_map and ckpt_map are the same, but in exist_trim_candidates::add_discard_addrs, cur_map is updated one, and newer than ckpt_map, so we need to use cur_map to check whether there are discard candidates.

v1->v2: one problem of check discard candidates reported by Chao, besides, update commit message.

---
 fs/f2fs/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +0 -0
index 5854cc4..f5d0499 100644
@@ -1559,7 +1559,7 @@ static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc,
 
Quoted 6 lines

fs/f2fs/segment.c static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc, · line 1562

Quoted 4 lines
fs/f2fs/segment.c +1 -1
 	/* SIT_VBLOCK_MAP_SIZE should be multiple of sizeof(unsigned long) */
 	for (i = 0; i < entries; i++)
-		dmap[i] = force ? ~ckpt_map[i] & ~discard_map[i] :
+		dmap[i] = force ? ~cur_map[i] & ~discard_map[i] :

NAK. We're able to loose data for roll-forward recovery.

Actually, in fstrim flow (force == 1), cur_map is complete the same as ckpt_map. Do you suffer data corruption during testing this patch?

Thanks,

Quoted 9 lines
Quoted 6 lines
fs/f2fs/segment.c +0 -0
 				(cur_map[i] ^ ckpt_map[i]) & ckpt_map[i];
 
 	while (force || SM_I(sbi)->dcc_info->nr_discards <=
Signature · 1 line
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

author
#4 lore raw
Quoted 36 lines

-----Original Message-----
From: Yuchao (T)
Sent: Friday, April 13, 2018 9:12 AM
To: Jaegeuk Kim; heyunlei
Cc: [email protected]; Wangbintian; Zhangdianfang (Euler)
Subject: Re: [f2fs-dev][PATCH v2] f2fs: use cur_map instead of ckpt_map

Quoted 26 lines · Jaegeuk Kim
Quoted 18 lines · Yunlei He

In flush_sit_entries::add_discard_addrs path, cur_map and ckpt_map are the same, but in exist_trim_candidates::add_discard_addrs, cur_map is updated one, and newer than ckpt_map, so we need to use cur_map to check whether there are discard candidates.

v1->v2: one problem of check discard candidates reported by Chao, besides, update commit message.

---
 fs/f2fs/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +0 -0
index 5854cc4..f5d0499 100644

fs/f2fs/segment.c static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc, · line 1562

Quoted 5 lines
fs/f2fs/segment.c +1 -1
@@ -1559,7 +1559,7 @@ static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc,
 
 	/* SIT_VBLOCK_MAP_SIZE should be multiple of sizeof(unsigned long) */
 	for (i = 0; i < entries; i++)
-		dmap[i] = force ? ~ckpt_map[i] & ~discard_map[i] :
+		dmap[i] = force ? ~cur_map[i] & ~discard_map[i] :

NAK. We're able to loose data for roll-forward recovery.

Ping

Thanks.

Quoted 15 lines

Actually, in fstrim flow (force == 1), cur_map is complete the same as ckpt_map. Do you suffer data corruption during testing this patch?

Thanks,

Quoted 9 lines
Quoted 6 lines
fs/f2fs/segment.c +0 -1
 				(cur_map[i] ^ ckpt_map[i]) & ckpt_map[i];
 
 	while (force || SM_I(sbi)->dcc_info->nr_discards <=
--

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

maintainer
#5 lore raw
Quoted 36 lines · heyunlei
Quoted 36 lines

-----Original Message-----
From: Yuchao (T)
Sent: Friday, April 13, 2018 9:12 AM
To: Jaegeuk Kim; heyunlei
Cc: [email protected]; Wangbintian; Zhangdianfang (Euler)
Subject: Re: [f2fs-dev][PATCH v2] f2fs: use cur_map instead of ckpt_map

Quoted 26 lines · Jaegeuk Kim
Quoted 18 lines · Yunlei He

In flush_sit_entries::add_discard_addrs path, cur_map and ckpt_map are the same, but in exist_trim_candidates::add_discard_addrs, cur_map is updated one, and newer than ckpt_map, so we need to use cur_map to check whether there are discard candidates.

v1->v2: one problem of check discard candidates reported by Chao, besides, update commit message.

---
 fs/f2fs/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +0 -0
index 5854cc4..f5d0499 100644

fs/f2fs/segment.c static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc, · line 1562

Quoted 5 lines
fs/f2fs/segment.c +1 -1
@@ -1559,7 +1559,7 @@ static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc,
 
 	/* SIT_VBLOCK_MAP_SIZE should be multiple of sizeof(unsigned long) */
 	for (i = 0; i < entries; i++)
-		dmap[i] = force ? ~ckpt_map[i] & ~discard_map[i] :
+		dmap[i] = force ? ~cur_map[i] & ~discard_map[i] :

NAK. We're able to loose data for roll-forward recovery.

Quoted 6 lines

Ping

Thanks.

Quoted 3 lines

Actually, in fstrim flow (force == 1), cur_map is complete the same as ckpt_map. Do you suffer data corruption during testing this patch?

So, we don't need this patch, IIUC.

Quoted 4 lines
Quoted 4 lines

Thanks,

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
fs/f2fs/segment.c +0 -1
 				(cur_map[i] ^ ckpt_map[i]) & ckpt_map[i];
 
 	while (force || SM_I(sbi)->dcc_info->nr_discards <=
--

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

#6 lore raw
Quoted 37 lines · Jaegeuk Kim
Quoted 36 lines · heyunlei
Quoted 36 lines

-----Original Message-----
From: Yuchao (T)
Sent: Friday, April 13, 2018 9:12 AM
To: Jaegeuk Kim; heyunlei
Cc: [email protected]; Wangbintian; Zhangdianfang (Euler)
Subject: Re: [f2fs-dev][PATCH v2] f2fs: use cur_map instead of ckpt_map

Quoted 26 lines · Jaegeuk Kim
Quoted 18 lines · Yunlei He

In flush_sit_entries::add_discard_addrs path, cur_map and ckpt_map are the same, but in exist_trim_candidates::add_discard_addrs, cur_map is updated one, and newer than ckpt_map, so we need to use cur_map to check whether there are discard candidates.

v1->v2: one problem of check discard candidates reported by Chao, besides, update commit message.

---
 fs/f2fs/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +0 -0
index 5854cc4..f5d0499 100644

fs/f2fs/segment.c static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc, · line 1562

Quoted 5 lines
fs/f2fs/segment.c +1 -1
@@ -1559,7 +1559,7 @@ static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc,
 
 	/* SIT_VBLOCK_MAP_SIZE should be multiple of sizeof(unsigned long) */
 	for (i = 0; i < entries; i++)
-		dmap[i] = force ? ~ckpt_map[i] & ~discard_map[i] :
+		dmap[i] = force ? ~cur_map[i] & ~discard_map[i] :

NAK. We're able to loose data for roll-forward recovery.

Quoted 8 lines
Quoted 6 lines

Ping

Thanks.

Quoted 3 lines

Actually, in fstrim flow (force == 1), cur_map is complete the same as ckpt_map. Do you suffer data corruption during testing this patch?

So, we don't need this patch, IIUC.

No, in precheck flow, we haven't flush cur_map to ckpt_map, so they are different.

- fstrim
- exist_trim_candidates
- add_discard_addrs

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Thanks,

Quoted 3 lines
Quoted 3 lines
fs/f2fs/segment.c +0 -0
 				(cur_map[i] ^ ckpt_map[i]) & ckpt_map[i];
 
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
fs/f2fs/segment.c +0 -1
 	while (force || SM_I(sbi)->dcc_info->nr_discards <=
--

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

maintainer
#7 lore raw
Quoted 40 lines · Chao Yu
Quoted 39 lines · Jaegeuk Kim
Quoted 38 lines · heyunlei
Quoted 36 lines

-----Original Message-----
From: Yuchao (T)
Sent: Friday, April 13, 2018 9:12 AM
To: Jaegeuk Kim; heyunlei
Cc: [email protected]; Wangbintian; Zhangdianfang (Euler)
Subject: Re: [f2fs-dev][PATCH v2] f2fs: use cur_map instead of ckpt_map

Quoted 26 lines · Jaegeuk Kim
Quoted 18 lines · Yunlei He

In flush_sit_entries::add_discard_addrs path, cur_map and ckpt_map are the same, but in exist_trim_candidates::add_discard_addrs, cur_map is updated one, and newer than ckpt_map, so we need to use cur_map to check whether there are discard candidates.

v1->v2: one problem of check discard candidates reported by Chao, besides, update commit message.

---
 fs/f2fs/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +0 -0
index 5854cc4..f5d0499 100644

fs/f2fs/segment.c static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc, · line 1562

Quoted 5 lines
fs/f2fs/segment.c +1 -1
@@ -1559,7 +1559,7 @@ static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc,
 
 	/* SIT_VBLOCK_MAP_SIZE should be multiple of sizeof(unsigned long) */
 	for (i = 0; i < entries; i++)
-		dmap[i] = force ? ~ckpt_map[i] & ~discard_map[i] :
+		dmap[i] = force ? ~cur_map[i] & ~discard_map[i] :

NAK. We're able to loose data for roll-forward recovery.

Ping

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Thanks.

Quoted 3 lines

Actually, in fstrim flow (force == 1), cur_map is complete the same as ckpt_map. Do you suffer data corruption during testing this patch?

So, we don't need this patch, IIUC.

No, in precheck flow, we haven't flush cur_map to ckpt_map, so they are different.

Then, what if power-cut happens between exist_trim_candidates() and do_checkpoint()?

Quoted 21 lines

- fstrim
- exist_trim_candidates
- add_discard_addrs

Quoted 16 lines
Quoted 5 lines
Quoted 5 lines

Thanks,

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
fs/f2fs/segment.c +0 -1
 				(cur_map[i] ^ ckpt_map[i]) & ckpt_map[i];
 
 	while (force || SM_I(sbi)->dcc_info->nr_discards <=
--

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

author
#8 lore raw
Quoted 55 lines

-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Friday, April 20, 2018 11:41 AM
To: Yuchao (T)
Cc: heyunlei; [email protected]; Wangbintian; Zhangdianfang (Euler)
Subject: Re: [f2fs-dev][PATCH v2] f2fs: use cur_map instead of ckpt_map

Quoted 45 lines · Chao Yu
Quoted 44 lines · Jaegeuk Kim
Quoted 42 lines · heyunlei
Quoted 36 lines

-----Original Message-----
From: Yuchao (T)
Sent: Friday, April 13, 2018 9:12 AM
To: Jaegeuk Kim; heyunlei
Cc: [email protected]; Wangbintian; Zhangdianfang (Euler)
Subject: Re: [f2fs-dev][PATCH v2] f2fs: use cur_map instead of ckpt_map

Quoted 26 lines · Jaegeuk Kim
Quoted 18 lines · Yunlei He

In flush_sit_entries::add_discard_addrs path, cur_map and ckpt_map are the same, but in exist_trim_candidates::add_discard_addrs, cur_map is updated one, and newer than ckpt_map, so we need to use cur_map to check whether there are discard candidates.

v1->v2: one problem of check discard candidates reported by Chao, besides, update commit message.

---
 fs/f2fs/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +0 -0
index 5854cc4..f5d0499 100644

fs/f2fs/segment.c static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc, · line 1562

Quoted 5 lines
fs/f2fs/segment.c +1 -1
@@ -1559,7 +1559,7 @@ static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc,
 
 	/* SIT_VBLOCK_MAP_SIZE should be multiple of sizeof(unsigned long) */
 	for (i = 0; i < entries; i++)
-		dmap[i] = force ? ~ckpt_map[i] & ~discard_map[i] :
+		dmap[i] = force ? ~cur_map[i] & ~discard_map[i] :

NAK. We're able to loose data for roll-forward recovery.

Ping

Thanks.

Quoted 3 lines

Actually, in fstrim flow (force == 1), cur_map is complete the same as ckpt_map. Do you suffer data corruption during testing this patch?

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

So, we don't need this patch, IIUC.

No, in precheck flow, we haven't flush cur_map to ckpt_map, so they are different.

Then, what if power-cut happens between exist_trim_candidates() and do_checkpoint()?

Discards issued after do_checkpoint:
i. new cp write ok, discard will not affect recovery
ii. new cp write failed(including power-cut), discards will be released, will not affet recovery too?

Anything I missing?

Thanks.

Quoted 17 lines
Quoted 17 lines

- fstrim
- exist_trim_candidates
- add_discard_addrs

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

Thanks,

Quoted 7 lines
Quoted 6 lines
fs/f2fs/segment.c +0 -1
 				(cur_map[i] ^ ckpt_map[i]) & ckpt_map[i];
 
 	while (force || SM_I(sbi)->dcc_info->nr_discards <=
--

1.9.1

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

.

.

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

#9 lore raw
In reply to Jaegeuk Kim
Quoted 46 lines · Jaegeuk Kim
Quoted 45 lines · Chao Yu
Quoted 44 lines · Jaegeuk Kim
Quoted 42 lines · heyunlei
Quoted 36 lines

-----Original Message-----
From: Yuchao (T)
Sent: Friday, April 13, 2018 9:12 AM
To: Jaegeuk Kim; heyunlei
Cc: [email protected]; Wangbintian; Zhangdianfang (Euler)
Subject: Re: [f2fs-dev][PATCH v2] f2fs: use cur_map instead of ckpt_map

Quoted 26 lines · Jaegeuk Kim
Quoted 18 lines · Yunlei He

In flush_sit_entries::add_discard_addrs path, cur_map and ckpt_map are the same, but in exist_trim_candidates::add_discard_addrs, cur_map is updated one, and newer than ckpt_map, so we need to use cur_map to check whether there are discard candidates.

v1->v2: one problem of check discard candidates reported by Chao, besides, update commit message.

---
 fs/f2fs/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +0 -0
index 5854cc4..f5d0499 100644

fs/f2fs/segment.c static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc, · line 1562

Quoted 5 lines
fs/f2fs/segment.c +1 -1
@@ -1559,7 +1559,7 @@ static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc,
 
 	/* SIT_VBLOCK_MAP_SIZE should be multiple of sizeof(unsigned long) */
 	for (i = 0; i < entries; i++)
-		dmap[i] = force ? ~ckpt_map[i] & ~discard_map[i] :
+		dmap[i] = force ? ~cur_map[i] & ~discard_map[i] :

NAK. We're able to loose data for roll-forward recovery.

Ping

Thanks.

Quoted 3 lines

Actually, in fstrim flow (force == 1), cur_map is complete the same as ckpt_map. Do you suffer data corruption during testing this patch?

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

So, we don't need this patch, IIUC.

No, in precheck flow, we haven't flush cur_map to ckpt_map, so they are different.

Then, what if power-cut happens between exist_trim_candidates() and do_checkpoint()?

For example:
1. write data block to block address #N
2. write checkpoint cur_map:1, ckpt_map:1
3. punch data block in block address #N cur_map:0, ckpt_map:1
4. call fstrim with range [0, X], X > N
5. exist_trim_candidates should check cur_map to decide whether we need a checkpoint and further discard? otherwise we will fail to trim suitable candidates?

I have one other question:

Discard should be issued after a checkpoint, right? except below codes:

		if (NM_I(sbi)->dirty_nat_cnt == 0 &&
				SIT_I(sbi)->dirty_sentries == 0 &&
				prefree_segments(sbi) == 0) {
			flush_sit_entries(sbi, cpc);
			clear_prefree_segments(sbi, cpc);
			unblock_operations(sbi);
			goto out;
		}

Why can we call flush_sit_entries & clear_prefree_segments without checkpoint?

Thanks,

Quoted 17 lines
Quoted 17 lines

- fstrim
- exist_trim_candidates
- add_discard_addrs

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

Thanks,

Quoted 7 lines
Quoted 6 lines
fs/f2fs/segment.c +0 -1
 				(cur_map[i] ^ ckpt_map[i]) & ckpt_map[i];
 
 	while (force || SM_I(sbi)->dcc_info->nr_discards <=
--

1.9.1

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

.

.

.

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