f2fs: compress: allow write compress released file after truncate to zero
Subsystems (2)
PATCH v4 1/1 f2fs: compress: allow write compress released file after truncate to zero
For compressed file, after release compress blocks, don't allow write direct, but we should allow write direct after truncate to zero.
--- Documentation/filesystems/f2fs.rst | 7 +++++-- fs/f2fs/file.c | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-)
Documentation/filesystems/f2fs.rst +5 -2
@@ -865,8 +865,11 @@ Compression implementation directly in order to guarantee potential data updates later to the space. Instead, the main goal is to reduce data writes to flash disk as much as possible, resulting in extending disk life time as well as relaxing IO - congestion. Alternatively, we've added ioctl interface to reclaim compressed - space and show it to user after putting the immutable bit. + congestion. Alternatively, we've added ioctl(F2FS_IOC_RELEASE_COMPRESS_BLOCKS) + interface to reclaim compressed space and show it to user after putting the + immutable bit. After call ioctl release compreesed space, don't allow write + file directly, unless call ioctl(F2FS_IOC_RESERVE_COMPRESS_BLOCKS) to reserve + compreesed space or file truncated be zero. Compress metadata layout::
fs/f2fs/file.c +8 -0
@@ -753,6 +753,14 @@ int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock)return err;#ifdef CONFIG_F2FS_FS_COMPRESSION +/* +* For compressed file, after release compress blocks, don't allow write +* direct, but we should allow write direct after truncate to zero. +*/ +if (f2fs_compressed_file (inode) && !free_from + &&is_inode_flag_set (inode,FI_COMPRESS_RELEASED )) +clear_inode_flag (inode,FI_COMPRESS_RELEASED ); +if (from != free_from) { err =f2fs_truncate_partial_cluster (inode, from, lock);if (err)
Signature · 8 lines
2.29.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 14 lines · Fengnan Chang
For compressed file, after release compress blocks, don't allow write direct, but we should allow write direct after truncate to zero.
Signed-off-by Fengnan Chang <[email protected]>--- Documentation/filesystems/f2fs.rst | 7 +++++-- fs/f2fs/file.c | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-)Documentation/filesystems/f2fs.rst +0
-0
Documentation/filesystems/f2fs.rst Compression implementation · line 870
Quoted 8 lines
Documentation/filesystems/f2fs.rst +3
-2@@ -865,8 +865,11 @@ Compression implementation directly in order to guarantee potential data updates later to the space. Instead, the main goal is to reduce data writes to flash disk as much as possible, resulting in extending disk life time as well as relaxing IO - congestion. Alternatively, we've added ioctl interface to reclaim compressed - space and show it to user after putting the immutable bit. + congestion. Alternatively, we've added ioctl(F2FS_IOC_RELEASE_COMPRESS_BLOCKS) + interface to reclaim compressed space and show it to user after putting the + immutable bit. After call ioctl release compreesed space, don't allow write
immutable bit, after release, it doesn't allow writing/mmaping on the file, until reserving compressed space via ioctl(F2FS_IOC_RESERVE_COMPRESS_BLOCKS) or truncating filesize to zero.
Otherwise, it looks good to me.
Thanks,
Quoted 15 lines
Documentation/filesystems/f2fs.rst +2
-0+ file directly, unless call ioctl(F2FS_IOC_RESERVE_COMPRESS_BLOCKS) to reserve + compreesed space or file truncated be zero. Compress metadata layout::fs/f2fs/file.c +1
-0@@ -753,6 +753,14 @@ int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock)return err;#ifdef CONFIG_F2FS_FS_COMPRESSION +/*
fs/f2fs/file.c int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock) · line 766
Quoted 10 lines
fs/f2fs/file.c +7
-0+* For compressed file, after release compress blocks, don't allow write +* direct, but we should allow write direct after truncate to zero. +*/ +if (f2fs_compressed_file (inode) && !free_from + &&is_inode_flag_set (inode,FI_COMPRESS_RELEASED )) +clear_inode_flag (inode,FI_COMPRESS_RELEASED ); +if (from != free_from) { err =f2fs_truncate_partial_cluster (inode, from, lock);if (err)
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel