f2fs: don't set FI_COMPRESS_RELEASED if file is not compressed
PATCH 1/1 f2fs: don't set FI_COMPRESS_RELEASED if file is not compressed
In compress_mode=user, f2fs_release_compress_blocks()
does not verify whether it has been compressed and sets FI_COMPRESS_RELEASED directly. which will lead to
return -EINVAL after calling compress.
To fix it,let's do not set FI_COMPRESS_RELEASED if file is not compressed.
--- fs/f2fs/file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/f2fs/file.c +1 -2
@@ -3451,14 +3451,13 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) ret =filemap_write_and_wait_range (inode->i_mapping,0 ,LLONG_MAX );if (ret) goto out; - -set_inode_flag (inode,FI_COMPRESS_RELEASED ); inode->i_ctime =current_time (inode);f2fs_mark_inode_dirty_sync (inode, true);if (!atomic_read (&F2FS_I (inode)->i_compr_blocks)) goto out; +set_inode_flag (inode,FI_COMPRESS_RELEASED );f2fs_down_write (&F2FS_I (inode)->i_gc_rwsem[WRITE ]);filemap_invalidate_lock (inode->i_mapping);
Signature · 8 lines
2.38.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Jaegeuk Kim
maintainerQuoted 6 lines · On 12/08, zhoudan8 wrote:
In compress_mode=user,
f2fs_release_compress_blocks()
does not verify whether it has been compressed and setsFI_COMPRESS_RELEASEDdirectly. which will lead to
return-EINVALafter calling compress.
To fix it,let's do not setFI_COMPRESS_RELEASEDif file is not compressed.
Do you mean you want to avoid EINVAL on a file having FI_COMPRESS_RELEASED with zero i_compr_blokcs?
I think the current logic is giving the error on a released file already.
Quoted 28 lines
Signed-off-by zhoudan8 <[email protected]>--- fs/f2fs/file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/f2fs/file.c +1
-2@@ -3451,14 +3451,13 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) ret =filemap_write_and_wait_range (inode->i_mapping,0 ,LLONG_MAX );if (ret) goto out; - -set_inode_flag (inode,FI_COMPRESS_RELEASED ); inode->i_ctime =current_time (inode);f2fs_mark_inode_dirty_sync (inode, true);if (!atomic_read (&F2FS_I (inode)->i_compr_blocks)) goto out; +set_inode_flag (inode,FI_COMPRESS_RELEASED );f2fs_down_write (&F2FS_I (inode)->i_gc_rwsem[WRITE ]);filemap_invalidate_lock (inode->i_mapping);Signature · 1 line
2.38.1
Maybe I'm not describing it clearly enough, but I think there is something wrong with the logic here.The 'f2fs_release_compress_blocks' method does not determine if the file is compressed, but simply adds the FI_COMPRESS_RELEASED flag.
In particular, in the current Android system, when the application is installed, the release interface is called by default to release the storage marked as compressed, without checking whether the file is actually compressed. In this case, when compress_mode is set to user, calling the compress interface returns ENVAL and the file cannot be compressed.
So I think the implementation of release needs to be modified, and only set FI_COMPRESS_RELEASED when it's really compressed and the storage is released.
Quoted 41 lines · Jaegeuk Kim
Quoted 6 lines · On 12/08, zhoudan8 wrote:
In compress_mode=user,
f2fs_release_compress_blocks()
does not verify whether it has been compressed and setsFI_COMPRESS_RELEASEDdirectly. which will lead to
return-EINVALafter calling compress.
To fix it,let's do not setFI_COMPRESS_RELEASEDif file is not compressed.Do you mean you want to avoid EINVAL on a file having
FI_COMPRESS_RELEASEDwith zeroi_compr_blokcs?I think the current logic is giving the error on a released file already.
Quoted 28 lines
Signed-off-by zhoudan8 <[email protected]>--- fs/f2fs/file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/f2fs/file.c +1
-2@@ -3451,14 +3451,13 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) ret =filemap_write_and_wait_range (inode->i_mapping,0 ,LLONG_MAX );if (ret) goto out; - -set_inode_flag (inode,FI_COMPRESS_RELEASED ); inode->i_ctime =current_time (inode);f2fs_mark_inode_dirty_sync (inode, true);if (!atomic_read (&F2FS_I (inode)->i_compr_blocks)) goto out; +set_inode_flag (inode,FI_COMPRESS_RELEASED );f2fs_down_write (&F2FS_I (inode)->i_gc_rwsem[WRITE ]);filemap_invalidate_lock (inode->i_mapping);Signature · 1 line
2.38.1
Jaegeuk Kim
maintainerQuoted 4 lines · zhoudan
Maybe I'm not describing it clearly enough, but I think there is something wrong with the logic here.The '
f2fs_release_compress_blocks' method does not determine if the file is compressed, but simply adds theFI_COMPRESS_RELEASEDflag.
I firstly lost your point since f2fs_release_compress_blocks() checked f2fs_compressed_file().
Quoted 52 lines
In particular, in the current Android system, when the application is installed, the release interface is called by default to release the storage marked as compressed, without checking whether the file is actually compressed. In this case, when
compress_modeis set to user, calling the compress interface returns ENVAL and the file cannot be compressed.
So I think the implementation of release needs to be modified, and only setFI_COMPRESS_RELEASEDwhen it's really compressed and the storage is released.Quoted 41 lines · Jaegeuk Kim
Quoted 6 lines · On 12/08, zhoudan8 wrote:
In compress_mode=user,
f2fs_release_compress_blocks()
does not verify whether it has been compressed and setsFI_COMPRESS_RELEASEDdirectly. which will lead to
return-EINVALafter calling compress.
To fix it,let's do not setFI_COMPRESS_RELEASEDif file is not compressed.Do you mean you want to avoid EINVAL on a file having
FI_COMPRESS_RELEASEDwith zeroi_compr_blokcs?I think the current logic is giving the error on a released file already.
Quoted 28 lines
Signed-off-by zhoudan8 <[email protected]>--- fs/f2fs/file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/f2fs/file.c +1
-2@@ -3451,14 +3451,13 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) ret =filemap_write_and_wait_range (inode->i_mapping,0 ,LLONG_MAX );if (ret) goto out; - -set_inode_flag (inode,FI_COMPRESS_RELEASED ); inode->i_ctime =current_time (inode);f2fs_mark_inode_dirty_sync (inode, true);if (!atomic_read (&F2FS_I (inode)->i_compr_blocks)) goto out; +set_inode_flag (inode,FI_COMPRESS_RELEASED );f2fs_down_write (&F2FS_I (inode)->i_gc_rwsem[WRITE ]);filemap_invalidate_lock (inode->i_mapping);Signature · 1 line
2.38.1
However, 'f2fs_compressed_file()' only determines whether the file can be compressed, not whether the file has been compressed. As far as I know, when compress_mode is user, files marked FI_COMPRESSED_FILE will be compressed only after 'f2fs_ioc_compress_file()' is called.
Quoted 61 lines · Jaegeuk Kim
Quoted 4 lines · zhoudan
Maybe I'm not describing it clearly enough, but I think there is something wrong with the logic here.The '
f2fs_release_compress_blocks' method does not determine if the file is compressed, but simply adds theFI_COMPRESS_RELEASEDflag.I firstly lost your point since
f2fs_release_compress_blocks()checkedf2fs_compressed_file().Quoted 52 lines
In particular, in the current Android system, when the application is installed, the release interface is called by default to release the storage marked as compressed, without checking whether the file is actually compressed. In this case, when
compress_modeis set to user, calling the compress interface returns ENVAL and the file cannot be compressed.
So I think the implementation of release needs to be modified, and only setFI_COMPRESS_RELEASEDwhen it's really compressed and the storage is released.Quoted 41 lines · Jaegeuk Kim
Quoted 6 lines · On 12/08, zhoudan8 wrote:
In compress_mode=user,
f2fs_release_compress_blocks()
does not verify whether it has been compressed and setsFI_COMPRESS_RELEASEDdirectly. which will lead to
return-EINVALafter calling compress.
To fix it,let's do not setFI_COMPRESS_RELEASEDif file is not compressed.Do you mean you want to avoid EINVAL on a file having
FI_COMPRESS_RELEASEDwith zeroi_compr_blokcs?I think the current logic is giving the error on a released file already.
Quoted 28 lines
Signed-off-by zhoudan8 <[email protected]>--- fs/f2fs/file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/f2fs/file.c +1
-2@@ -3451,14 +3451,13 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) ret =filemap_write_and_wait_range (inode->i_mapping,0 ,LLONG_MAX );if (ret) goto out; - -set_inode_flag (inode,FI_COMPRESS_RELEASED ); inode->i_ctime =current_time (inode);f2fs_mark_inode_dirty_sync (inode, true);if (!atomic_read (&F2FS_I (inode)->i_compr_blocks)) goto out; +set_inode_flag (inode,FI_COMPRESS_RELEASED );f2fs_down_write (&F2FS_I (inode)->i_gc_rwsem[WRITE ]);filemap_invalidate_lock (inode->i_mapping);Signature · 1 line
2.38.1
Hi, about this patch, I haven't received any reply recently. Maybe you have some new ideas to solve this problem?
Quoted 67 lines · zhoudan <[email protected]> 于2022年12月13日周二 10:21写道:
However, '
f2fs_compressed_file()' only determines whether the file can be compressed, not whether the file has been compressed. As far as I know, whencompress_modeis user, files markedFI_COMPRESSED_FILEwill be compressed only after 'f2fs_ioc_compress_file()' is called.Quoted 61 lines · Jaegeuk Kim
Quoted 4 lines · zhoudan
Maybe I'm not describing it clearly enough, but I think there is something wrong with the logic here.The '
f2fs_release_compress_blocks' method does not determine if the file is compressed, but simply adds theFI_COMPRESS_RELEASEDflag.I firstly lost your point since
f2fs_release_compress_blocks()checkedf2fs_compressed_file().Quoted 52 lines
In particular, in the current Android system, when the application is installed, the release interface is called by default to release the storage marked as compressed, without checking whether the file is actually compressed. In this case, when
compress_modeis set to user, calling the compress interface returns ENVAL and the file cannot be compressed.
So I think the implementation of release needs to be modified, and only setFI_COMPRESS_RELEASEDwhen it's really compressed and the storage is released.Quoted 41 lines · Jaegeuk Kim
Quoted 6 lines · On 12/08, zhoudan8 wrote:
In compress_mode=user,
f2fs_release_compress_blocks()
does not verify whether it has been compressed and setsFI_COMPRESS_RELEASEDdirectly. which will lead to
return-EINVALafter calling compress.
To fix it,let's do not setFI_COMPRESS_RELEASEDif file is not compressed.Do you mean you want to avoid EINVAL on a file having
FI_COMPRESS_RELEASEDwith zeroi_compr_blokcs?I think the current logic is giving the error on a released file already.
Quoted 28 lines
Signed-off-by zhoudan8 <[email protected]>--- fs/f2fs/file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/f2fs/file.c +1
-3@@ -3451,14 +3451,13 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) ret =filemap_write_and_wait_range (inode->i_mapping,0 ,LLONG_MAX );if (ret) goto out; - -set_inode_flag (inode,FI_COMPRESS_RELEASED ); inode->i_ctime =current_time (inode);f2fs_mark_inode_dirty_sync (inode, true);if (!atomic_read (&F2FS_I (inode)->i_compr_blocks)) goto out; +set_inode_flag (inode,FI_COMPRESS_RELEASED );f2fs_down_write (&F2FS_I (inode)->i_gc_rwsem[WRITE ]);filemap_invalidate_lock (inode->i_mapping); --2.38.1
Jaegeuk Kim
maintainerQuoted 2 lines · zhou dan
Hi, about this patch, I haven't received any reply recently. Maybe you have some new ideas to solve this problem?
Could you please describe the exact flow that you're suffering from?
Quoted 70 lines
Quoted 67 lines · zhoudan <[email protected]> 于2022年12月13日周二 10:21写道:
However, '
f2fs_compressed_file()' only determines whether the file can be compressed, not whether the file has been compressed. As far as I know, whencompress_modeis user, files markedFI_COMPRESSED_FILEwill be compressed only after 'f2fs_ioc_compress_file()' is called.Quoted 61 lines · Jaegeuk Kim
Quoted 4 lines · zhoudan
Maybe I'm not describing it clearly enough, but I think there is something wrong with the logic here.The '
f2fs_release_compress_blocks' method does not determine if the file is compressed, but simply adds theFI_COMPRESS_RELEASEDflag.I firstly lost your point since
f2fs_release_compress_blocks()checkedf2fs_compressed_file().Quoted 52 lines
In particular, in the current Android system, when the application is installed, the release interface is called by default to release the storage marked as compressed, without checking whether the file is actually compressed. In this case, when
compress_modeis set to user, calling the compress interface returns ENVAL and the file cannot be compressed.
So I think the implementation of release needs to be modified, and only setFI_COMPRESS_RELEASEDwhen it's really compressed and the storage is released.Quoted 41 lines · Jaegeuk Kim
Quoted 6 lines · On 12/08, zhoudan8 wrote:
In compress_mode=user,
f2fs_release_compress_blocks()
does not verify whether it has been compressed and setsFI_COMPRESS_RELEASEDdirectly. which will lead to
return-EINVALafter calling compress.
To fix it,let's do not setFI_COMPRESS_RELEASEDif file is not compressed.Do you mean you want to avoid EINVAL on a file having
FI_COMPRESS_RELEASEDwith zeroi_compr_blokcs?I think the current logic is giving the error on a released file already.
Quoted 28 lines
Signed-off-by zhoudan8 <[email protected]>--- fs/f2fs/file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/f2fs/file.c +1
-3@@ -3451,14 +3451,13 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) ret =filemap_write_and_wait_range (inode->i_mapping,0 ,LLONG_MAX );if (ret) goto out; - -set_inode_flag (inode,FI_COMPRESS_RELEASED ); inode->i_ctime =current_time (inode);f2fs_mark_inode_dirty_sync (inode, true);if (!atomic_read (&F2FS_I (inode)->i_compr_blocks)) goto out; +set_inode_flag (inode,FI_COMPRESS_RELEASED );f2fs_down_write (&F2FS_I (inode)->i_gc_rwsem[WRITE ]);filemap_invalidate_lock (inode->i_mapping); --2.38.1
On Android S, after the app is installed, it will judge whether the file is allowed to be compressed and release it. In the case of compress_mode=user, the file is not compressed at this point, causing EVNAL to be returned on subsequent executions to release.
In the method 'isCompressionAllowed', there is also such a notice:"NOTE:
The return value does not mean if the given file, or any other file on the same file system, is actually compressed. It merely determines whether not files <em>may</em> be compressed."
Quoted 77 lines · Jaegeuk Kim
Quoted 2 lines · zhou dan
Hi, about this patch, I haven't received any reply recently. Maybe you have some new ideas to solve this problem?
Could you please describe the exact flow that you're suffering from?
Quoted 70 lines
Quoted 67 lines · zhoudan <[email protected]> 于2022年12月13日周二 10:21写道:
However, '
f2fs_compressed_file()' only determines whether the file can be compressed, not whether the file has been compressed. As far as I know, whencompress_modeis user, files markedFI_COMPRESSED_FILEwill be compressed only after 'f2fs_ioc_compress_file()' is called.Quoted 61 lines · Jaegeuk Kim
Quoted 4 lines · zhoudan
Maybe I'm not describing it clearly enough, but I think there is something wrong with the logic here.The '
f2fs_release_compress_blocks' method does not determine if the file is compressed, but simply adds theFI_COMPRESS_RELEASEDflag.I firstly lost your point since
f2fs_release_compress_blocks()checkedf2fs_compressed_file().Quoted 52 lines
In particular, in the current Android system, when the application is installed, the release interface is called by default to release the storage marked as compressed, without checking whether the file is actually compressed. In this case, when
compress_modeis set to user, calling the compress interface returns ENVAL and the file cannot be compressed.
So I think the implementation of release needs to be modified, and only setFI_COMPRESS_RELEASEDwhen it's really compressed and the storage is released.Quoted 41 lines · Jaegeuk Kim
Quoted 6 lines · On 12/08, zhoudan8 wrote:
In compress_mode=user,
f2fs_release_compress_blocks()
does not verify whether it has been compressed and setsFI_COMPRESS_RELEASEDdirectly. which will lead to
return-EINVALafter calling compress.
To fix it,let's do not setFI_COMPRESS_RELEASEDif file is not compressed.Do you mean you want to avoid EINVAL on a file having
FI_COMPRESS_RELEASEDwith zeroi_compr_blokcs?I think the current logic is giving the error on a released file already.
Quoted 28 lines
Signed-off-by zhoudan8 <[email protected]>--- fs/f2fs/file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/f2fs/file.c +1
-3@@ -3451,14 +3451,13 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) ret =filemap_write_and_wait_range (inode->i_mapping,0 ,LLONG_MAX );if (ret) goto out; - -set_inode_flag (inode,FI_COMPRESS_RELEASED ); inode->i_ctime =current_time (inode);f2fs_mark_inode_dirty_sync (inode, true);if (!atomic_read (&F2FS_I (inode)->i_compr_blocks)) goto out; +set_inode_flag (inode,FI_COMPRESS_RELEASED );f2fs_down_write (&F2FS_I (inode)->i_gc_rwsem[WRITE ]);filemap_invalidate_lock (inode->i_mapping); --2.38.1
Chao Yu
maintainerQuoted 8 lines · Jaegeuk Kim
Quoted 6 lines · On 12/08, zhoudan8 wrote:
In compress_mode=user,
f2fs_release_compress_blocks()
does not verify whether it has been compressed and setsFI_COMPRESS_RELEASEDdirectly. which will lead to
return-EINVALafter calling compress.
To fix it,let's do not setFI_COMPRESS_RELEASEDif file is not compressed.
Quoted 4 lines
Do you mean you want to avoid EINVAL on a file having
FI_COMPRESS_RELEASEDwith zeroi_compr_blokcs?I think the current logic is giving the error on a released file already.
IMO, if i_compr_blocks is zero, it's better to return -EINVAL in f2fs_release_compress_blocks(), as there will be no benefit after the conversion.
Thanks,
Quoted 23 lines
Quoted 23 lines
Signed-off-by zhoudan8 <[email protected]>--- fs/f2fs/file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/f2fs/file.c +0
-2@@ -3451,14 +3451,13 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) ret =filemap_write_and_wait_range (inode->i_mapping,0 ,LLONG_MAX );if (ret) goto out; - -set_inode_flag (inode,FI_COMPRESS_RELEASED ); inode->i_ctime =current_time (inode);f2fs_mark_inode_dirty_sync (inode, true);if (!atomic_read (&F2FS_I (inode)->i_compr_blocks)) goto out;
Quoted 6 lines
Quoted 6 lines
fs/f2fs/file.c +1
-0+set_inode_flag (inode,FI_COMPRESS_RELEASED );f2fs_down_write (&F2FS_I (inode)->i_gc_rwsem[WRITE ]);filemap_invalidate_lock (inode->i_mapping);Signature · 1 line
2.38.1
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel