@@ -647,9 +647,6 @@ static int truncate_partial_data_page(struct inode *inode, u64 from,
647647 return 0 ;
648648 }
649649
650- if (f2fs_compressed_file (inode ))
651- return 0 ;
652-
653650 page = f2fs_get_lock_data_page (inode , index , true);
654651 if (IS_ERR (page ))
655652 return PTR_ERR (page ) == - ENOENT ? 0 : PTR_ERR (page );
@@ -665,7 +662,7 @@ static int truncate_partial_data_page(struct inode *inode, u64 from,
665662 return 0 ;
666663}
667664
668- static int do_truncate_blocks (struct inode * inode , u64 from , bool lock )
665+ int f2fs_do_truncate_blocks (struct inode * inode , u64 from , bool lock )
669666{
670667 struct f2fs_sb_info * sbi = F2FS_I_SB (inode );
671668 struct dnode_of_data dn ;
@@ -733,7 +730,9 @@ static int do_truncate_blocks(struct inode *inode, u64 from, bool lock)
733730int f2fs_truncate_blocks (struct inode * inode , u64 from , bool lock )
734731{
735732 u64 free_from = from ;
733+ int err ;
736734
735+ #ifdef CONFIG_F2FS_FS_COMPRESSION
737736 /*
738737 * for compressed file, only support cluster size
739738 * aligned truncation.
@@ -748,8 +747,18 @@ int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock)
748747 free_from ++ ;
749748 free_from <<= cluster_shift ;
750749 }
750+ #endif
751+
752+ err = f2fs_do_truncate_blocks (inode , free_from , lock );
753+ if (err )
754+ return err ;
755+
756+ #ifdef CONFIG_F2FS_FS_COMPRESSION
757+ if (from != free_from )
758+ err = f2fs_truncate_partial_cluster (inode , from , lock );
759+ #endif
751760
752- return do_truncate_blocks ( inode , free_from , lock ) ;
761+ return err ;
753762}
754763
755764int f2fs_truncate (struct inode * inode )
0 commit comments