Skip to contentSkip to conversation

f2fs: inline: fix minor bugs in f2fs_recover_inline_data

PATCH In review Jack Qiu 4 participants 12 messages Dec 7, 2020 – Dec 9, 2020 F2FS file system

lore
Share & tools
lore

Jack Qiu

author
#0 lore raw

v3 cover f2fs: inline: fix minor bugs in f2fs_recover_inline_data

Jack Qiu (3):
f2fs: inline: correct comment in f2fs_recover_inline_data
f2fs: inline: remove redundant FI_DATA_EXIST set
f2fs: inline: fix wrong inline inode stat

 fs/f2fs/inline.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--
2.17.1

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author
#1 lore raw

PATCH v3 1/3 f2fs: inline: correct comment in f2fs_recover_inline_data

In 3rd scene, it should remove data blocks instead of inline_data.

---
 fs/f2fs/inline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/inline.c +1 -1
index 70384e31788d..0399531efcd3 100644
@@ -266,7 +266,7 @@ int f2fs_recover_inline_data(struct inode *inode, struct page *npage)
 	 * [prev.] [next] of inline_data flag
 	 *    o       o  -> recover inline_data
 	 *    o       x  -> remove inline_data, and then recover data blocks
-	 *    x       o  -> remove inline_data, and then recover inline_data
+	 *    x       o  -> remove data blocks, and then recover inline_data
 	 *    x       x  -> recover data blocks
 	 */
 	if (IS_INODE(npage))

--
2.17.1

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author
#2 lore raw

PATCH v3 2/3 f2fs: inline: remove redundant FI_DATA_EXIST set

In reply to Jack Qiu

FI_DATA_EXIST has been set in recover_inline_flags, no need set in f2fs_recover_inline_data again. Just remove it.

---
 fs/f2fs/inline.c | 1 -
 1 file changed, 1 deletion(-)
fs/f2fs/inline.c +0 -1
index 0399531efcd3..0a8f7eefca7d 100644
@@ -286,7 +286,6 @@ int f2fs_recover_inline_data(struct inode *inode, struct page *npage)
 		memcpy(dst_addr, src_addr, MAX_INLINE_DATA(inode));
 
 		set_inode_flag(inode, FI_INLINE_DATA);
-		set_inode_flag(inode, FI_DATA_EXIST);
 
 		set_page_dirty(ipage);
 		f2fs_put_page(ipage, 1);

--
2.17.1

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

maintainer Reviewed-by on v3 2/3
#3 lore raw

Re: [f2fs-dev] [PATCH v3 2/3] f2fs: inline: remove redundant FI_DATA_EXIST set

Quoted 4 lines · Jack Qiu

FI_DATA_EXIST has been set in recover_inline_flags, no need set in f2fs_recover_inline_data again. Just remove it.

Thanks,

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

maintainer
#4 lore raw

Re: [f2fs-dev] [PATCH v3 2/3] f2fs: inline: remove redundant FI_DATA_EXIST set

In reply to Jack Qiu
Quoted 13 lines · Jack Qiu

FI_DATA_EXIST has been set in recover_inline_flags, no need set in f2fs_recover_inline_data again. Just remove it.

---
 fs/f2fs/inline.c | 1 -
 1 file changed, 1 deletion(-)
fs/f2fs/inline.c +0 -0
index 0399531efcd3..0a8f7eefca7d 100644

fs/f2fs/inline.c int f2fs_recover_inline_data(struct inode *inode, struct page *npage) · line 289

Quoted 4 lines
fs/f2fs/inline.c +0 -1
@@ -286,7 +286,6 @@ int f2fs_recover_inline_data(struct inode *inode, struct page *npage)
 		memcpy(dst_addr, src_addr, MAX_INLINE_DATA(inode));
 
 		set_inode_flag(inode, FI_INLINE_DATA);
-		set_inode_flag(inode, FI_DATA_EXIST);

Wait, recover_inline_flags() sets this based on on-disk flag, but this tries to recover it back.

Quoted 8 lines
fs/f2fs/inline.c +0 -1
 		set_page_dirty(ipage);
 		f2fs_put_page(ipage, 1);
--

2.17.1

Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#5 lore raw

Re: [f2fs-dev] [PATCH v3 2/3] f2fs: inline: remove redundant FI_DATA_EXIST set

Quoted 16 lines · Jaegeuk Kim
Quoted 15 lines · Jack Qiu

FI_DATA_EXIST has been set in recover_inline_flags, no need set in f2fs_recover_inline_data again. Just remove it.

---
  fs/f2fs/inline.c | 1 -
  1 file changed, 1 deletion(-)
fs/f2fs/inline.c +0 -0
index 0399531efcd3..0a8f7eefca7d 100644
@@ -286,7 +286,6 @@ int f2fs_recover_inline_data(struct inode *inode, struct page *npage)
  		memcpy(dst_addr, src_addr, MAX_INLINE_DATA(inode));
 
Quoted 5 lines

fs/f2fs/inline.c int f2fs_recover_inline_data(struct inode *inode, struct page *npage) · line 289

Quoted 2 lines
fs/f2fs/inline.c +0 -1
  		set_inode_flag(inode, FI_INLINE_DATA);
-		set_inode_flag(inode, FI_DATA_EXIST);

Wait, recover_inline_flags() sets this based on on-disk flag, but this tries to recover it back.

Should this flag only be recovered with the way like __recover_inline_status()? otherwise, the data_exist status may be not be consistent with real condition.

Thanks,

Quoted 15 lines
Quoted 9 lines
fs/f2fs/inline.c +0 -1
  		set_page_dirty(ipage);
  		f2fs_put_page(ipage, 1);
--

2.17.1

Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Quoted 6 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

maintainer
#6 lore raw

Re: [f2fs-dev] [PATCH v3 2/3] f2fs: inline: remove redundant FI_DATA_EXIST set

Quoted 17 lines · Chao Yu
Quoted 16 lines · Jaegeuk Kim
Quoted 15 lines · Jack Qiu

FI_DATA_EXIST has been set in recover_inline_flags, no need set in f2fs_recover_inline_data again. Just remove it.

---
  fs/f2fs/inline.c | 1 -
  1 file changed, 1 deletion(-)
fs/f2fs/inline.c +0 -0
index 0399531efcd3..0a8f7eefca7d 100644
@@ -286,7 +286,6 @@ int f2fs_recover_inline_data(struct inode *inode, struct page *npage)
  		memcpy(dst_addr, src_addr, MAX_INLINE_DATA(inode));
 
Quoted 8 lines
Quoted 5 lines

fs/f2fs/inline.c int f2fs_recover_inline_data(struct inode *inode, struct page *npage) · line 289

Quoted 2 lines
fs/f2fs/inline.c +0 -1
  		set_inode_flag(inode, FI_INLINE_DATA);
-		set_inode_flag(inode, FI_DATA_EXIST);

Wait, recover_inline_flags() sets this based on on-disk flag, but this tries to recover it back.

Should this flag only be recovered with the way like __recover_inline_status()? otherwise, the data_exist status may be not be consistent with real condition.

Well, we cannot say consistency on this, since user can write zero data. This can avoid __recover_inline_state() regardless of there-in data which is zero or not.

Quoted 24 lines

Thanks,

Quoted 21 lines
Quoted 9 lines
fs/f2fs/inline.c +0 -1
  		set_page_dirty(ipage);
  		f2fs_put_page(ipage, 1);
--

2.17.1

Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#7 lore raw

Re: [f2fs-dev] [PATCH v3 2/3] f2fs: inline: remove redundant FI_DATA_EXIST set

Quoted 24 lines · Jaegeuk Kim
Quoted 23 lines · Chao Yu
Quoted 21 lines · Jaegeuk Kim
Quoted 13 lines · Jack Qiu

FI_DATA_EXIST has been set in recover_inline_flags, no need set in f2fs_recover_inline_data again. Just remove it.

---
   fs/f2fs/inline.c | 1 -
   1 file changed, 1 deletion(-)
fs/f2fs/inline.c +0 -0
index 0399531efcd3..0a8f7eefca7d 100644

fs/f2fs/inline.c int f2fs_recover_inline_data(struct inode *inode, struct page *npage) · line 289

Quoted 4 lines
fs/f2fs/inline.c +0 -1
@@ -286,7 +286,6 @@ int f2fs_recover_inline_data(struct inode *inode, struct page *npage)
   		memcpy(dst_addr, src_addr, MAX_INLINE_DATA(inode));
 
   		set_inode_flag(inode, FI_INLINE_DATA);
-		set_inode_flag(inode, FI_DATA_EXIST);

Wait, recover_inline_flags() sets this based on on-disk flag, but this tries to recover it back.

Quoted 4 lines
Quoted 2 lines

Should this flag only be recovered with the way like __recover_inline_status()? otherwise, the data_exist status may be not be consistent with real condition.

Well, we cannot say consistency on this, since user can write zero data. This

I can see that FI_DATA_EXIST flag only decide that whether f2fs_convert_inline_page() will copy inline data into first page, if user write all zero data in inline area, there is no need to do the copy, as first page contains all zero already.

So, IMO, the flag indicates more like a FI_NON_ZERO_DATA_EXIST status? that would be consistent with our implementation in __recover_inline_status().

Thanks,

Quoted 21 lines

can avoid __recover_inline_state() regardless of there-in data which is zero or not.

Quoted 18 lines

Thanks,

Quoted 15 lines
Quoted 13 lines
fs/f2fs/inline.c +0 -1
   		set_page_dirty(ipage);
   		f2fs_put_page(ipage, 1);
--

2.17.1

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.

.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

maintainer
#8 lore raw

Re: [f2fs-dev] [PATCH v3 2/3] f2fs: inline: remove redundant FI_DATA_EXIST set

Quoted 28 lines · Chao Yu
Quoted 27 lines · Jaegeuk Kim
Quoted 25 lines · Chao Yu
Quoted 16 lines · Jaegeuk Kim
Quoted 15 lines · Jack Qiu

FI_DATA_EXIST has been set in recover_inline_flags, no need set in f2fs_recover_inline_data again. Just remove it.

---
   fs/f2fs/inline.c | 1 -
   1 file changed, 1 deletion(-)
fs/f2fs/inline.c +0 -0
index 0399531efcd3..0a8f7eefca7d 100644
@@ -286,7 +286,6 @@ int f2fs_recover_inline_data(struct inode *inode, struct page *npage)
   		memcpy(dst_addr, src_addr, MAX_INLINE_DATA(inode));
 
Quoted 5 lines

fs/f2fs/inline.c int f2fs_recover_inline_data(struct inode *inode, struct page *npage) · line 289

Quoted 2 lines
fs/f2fs/inline.c +0 -1
   		set_inode_flag(inode, FI_INLINE_DATA);
-		set_inode_flag(inode, FI_DATA_EXIST);

Wait, recover_inline_flags() sets this based on on-disk flag, but this tries to recover it back.

Should this flag only be recovered with the way like __recover_inline_status()? otherwise, the data_exist status may be not be consistent with real condition.

Quoted 8 lines
Quoted 1 line

Well, we cannot say consistency on this, since user can write zero data. This

I can see that FI_DATA_EXIST flag only decide that whether f2fs_convert_inline_page() will copy inline data into first page, if user write all zero data in inline area, there is no need to do the copy, as first page contains all zero already.

So, IMO, the flag indicates more like a FI_NON_ZERO_DATA_EXIST status? that would be consistent with our implementation in __recover_inline_status().

IIRC, original intention is FI_DATA_EXIST, and non-zero case was added to avoid potential inconsistency case. So, it's not intened for FI_NON_ZERO_DATA_EXIST. Still I don't see any problem on this, but looking at the iteration overhead on
do_read_inode() -> __recover_inlint_status().

Quoted 32 lines

Thanks,

Quoted 29 lines

can avoid __recover_inline_state() regardless of there-in data which is zero or not.

Quoted 24 lines

Thanks,

Quoted 21 lines
Quoted 9 lines
fs/f2fs/inline.c +0 -1
   		set_page_dirty(ipage);
   		f2fs_put_page(ipage, 1);
--

2.17.1

Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.

.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#9 lore raw

Re: [f2fs-dev] [PATCH v3 2/3] f2fs: inline: remove redundant FI_DATA_EXIST set

Quoted 35 lines · Jaegeuk Kim
Quoted 34 lines · Chao Yu
Quoted 24 lines · Jaegeuk Kim
Quoted 23 lines · Chao Yu
Quoted 21 lines · Jaegeuk Kim
Quoted 13 lines · Jack Qiu

FI_DATA_EXIST has been set in recover_inline_flags, no need set in f2fs_recover_inline_data again. Just remove it.

---
    fs/f2fs/inline.c | 1 -
    1 file changed, 1 deletion(-)
fs/f2fs/inline.c +0 -0
index 0399531efcd3..0a8f7eefca7d 100644

fs/f2fs/inline.c int f2fs_recover_inline_data(struct inode *inode, struct page *npage) · line 289

Quoted 4 lines
fs/f2fs/inline.c +0 -1
@@ -286,7 +286,6 @@ int f2fs_recover_inline_data(struct inode *inode, struct page *npage)
    		memcpy(dst_addr, src_addr, MAX_INLINE_DATA(inode));
 
    		set_inode_flag(inode, FI_INLINE_DATA);
-		set_inode_flag(inode, FI_DATA_EXIST);

Wait, recover_inline_flags() sets this based on on-disk flag, but this tries to recover it back.

Quoted 4 lines
Quoted 2 lines

Should this flag only be recovered with the way like __recover_inline_status()? otherwise, the data_exist status may be not be consistent with real condition.

Well, we cannot say consistency on this, since user can write zero data. This

I can see that FI_DATA_EXIST flag only decide that whether f2fs_convert_inline_page() will copy inline data into first page, if user write all zero data in inline area, there is no need to do the copy, as first page contains all zero already.

Quoted 5 lines
Quoted 2 lines

So, IMO, the flag indicates more like a FI_NON_ZERO_DATA_EXIST status? that would be consistent with our implementation in __recover_inline_status().

IIRC, original intention is FI_DATA_EXIST, and non-zero case was added to avoid potential inconsistency case. So, it's not intened for FI_NON_ZERO_DATA_EXIST.

Why we can encounter such inconsistency? is there any bug before adding that patch?

Quoted 2 lines

Still I don't see any problem on this, but looking at the iteration overhead on

    do_read_inode() -> __recover_inlint_status().

Yup, it's trivial, I'm fine to keep it as it is.

Thanks,

Quoted 31 lines
Quoted 31 lines

Thanks,

Quoted 27 lines

can avoid __recover_inline_state() regardless of there-in data which is zero or not.

Quoted 24 lines

Thanks,

Quoted 21 lines
Quoted 9 lines
fs/f2fs/inline.c +0 -1
    		set_page_dirty(ipage);
    		f2fs_put_page(ipage, 1);
--

2.17.1

Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.

Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

.

.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

maintainer
#10 lore raw

Re: [f2fs-dev] [PATCH v3 2/3] f2fs: inline: remove redundant FI_DATA_EXIST set

Quoted 36 lines · Chao Yu
Quoted 35 lines · Jaegeuk Kim
Quoted 34 lines · Chao Yu
Quoted 24 lines · Jaegeuk Kim
Quoted 23 lines · Chao Yu
Quoted 21 lines · Jaegeuk Kim
Quoted 13 lines · Jack Qiu

FI_DATA_EXIST has been set in recover_inline_flags, no need set in f2fs_recover_inline_data again. Just remove it.

---
    fs/f2fs/inline.c | 1 -
    1 file changed, 1 deletion(-)
fs/f2fs/inline.c +0 -0
index 0399531efcd3..0a8f7eefca7d 100644

fs/f2fs/inline.c int f2fs_recover_inline_data(struct inode *inode, struct page *npage) · line 289

Quoted 4 lines
fs/f2fs/inline.c +0 -1
@@ -286,7 +286,6 @@ int f2fs_recover_inline_data(struct inode *inode, struct page *npage)
    		memcpy(dst_addr, src_addr, MAX_INLINE_DATA(inode));
 
    		set_inode_flag(inode, FI_INLINE_DATA);
-		set_inode_flag(inode, FI_DATA_EXIST);

Wait, recover_inline_flags() sets this based on on-disk flag, but this tries to recover it back.

Quoted 4 lines
Quoted 2 lines

Should this flag only be recovered with the way like __recover_inline_status()? otherwise, the data_exist status may be not be consistent with real condition.

Well, we cannot say consistency on this, since user can write zero data. This

I can see that FI_DATA_EXIST flag only decide that whether f2fs_convert_inline_page() will copy inline data into first page, if user write all zero data in inline area, there is no need to do the copy, as first page contains all zero already.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

So, IMO, the flag indicates more like a FI_NON_ZERO_DATA_EXIST status? that would be consistent with our implementation in __recover_inline_status().

IIRC, original intention is FI_DATA_EXIST, and non-zero case was added to avoid potential inconsistency case. So, it's not intened for FI_NON_ZERO_DATA_EXIST.

Why we can encounter such inconsistency? is there any bug before adding that patch?

I can't remember exactly on it.

Quoted 43 lines
Quoted 3 lines

Still I don't see any problem on this, but looking at the iteration overhead on

    do_read_inode() -> __recover_inlint_status().

Yup, it's trivial, I'm fine to keep it as it is.

Thanks,

Quoted 35 lines
Quoted 33 lines

Thanks,

Quoted 29 lines

can avoid __recover_inline_state() regardless of there-in data which is zero or not.

Quoted 24 lines

Thanks,

Quoted 21 lines
Quoted 9 lines
fs/f2fs/inline.c +0 -1
    		set_page_dirty(ipage);
    		f2fs_put_page(ipage, 1);
--

2.17.1

Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.

.

.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author
#11 lore raw

PATCH v3 3/3 f2fs: inline: fix wrong inline inode stat

In reply to Jack Qiu

Miss to stat inline inode in f2fs_recover_inline_data.

---
 fs/f2fs/inline.c | 2 ++
 1 file changed, 2 insertions(+)
fs/f2fs/inline.c +2 -0
index 0a8f7eefca7d..c37747f7028c 100644
@@ -297,6 +297,7 @@ int f2fs_recover_inline_data(struct inode *inode, struct page *npage)
 		if (IS_ERR(ipage))
 			return PTR_ERR(ipage);
 		f2fs_truncate_inline_inode(inode, ipage, 0);
+		stat_dec_inline_inode(inode);
 		clear_inode_flag(inode, FI_INLINE_DATA);
 		f2fs_put_page(ipage, 1);
 	} else if (ri && (ri->i_inline & F2FS_INLINE_DATA)) {
@@ -305,6 +306,7 @@ int f2fs_recover_inline_data(struct inode *inode, struct page *npage)
 		ret = f2fs_truncate_blocks(inode, 0, false);
 		if (ret)
 			return ret;
+		stat_inc_inline_inode(inode);
 		goto process_inline;
 	}
 	return 0;

--
2.17.1

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel