Commit 4a4fc043 authored by Fengnan Chang's avatar Fengnan Chang Committed by Jaegeuk Kim
Browse files

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.

Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarFengnan Chang <changfengnan@vivo.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 1927ccdb
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -865,8 +865,11 @@ Compression implementation
  directly in order to guarantee potential data updates later to the space.
  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
  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
  possible, resulting in extending disk life time as well as relaxing IO
  congestion. Alternatively, we've added ioctl interface to reclaim compressed
  congestion. Alternatively, we've added ioctl(F2FS_IOC_RELEASE_COMPRESS_BLOCKS)
  space and show it to user after putting the immutable bit.
  interface to reclaim compressed space and show it to user after putting the
  immutable bit. 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.


Compress metadata layout::
Compress metadata layout::


+8 −0
Original line number Original line Diff line number Diff line
@@ -753,6 +753,14 @@ int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock)
		return err;
		return err;


#ifdef CONFIG_F2FS_FS_COMPRESSION
#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) {
	if (from != free_from) {
		err = f2fs_truncate_partial_cluster(inode, from, lock);
		err = f2fs_truncate_partial_cluster(inode, from, lock);
		if (err)
		if (err)