f2fs: introduce F2FS_IOC_RELEASE_COMPRESS_BLOCKS
PATCH v3 1/1 f2fs: introduce F2FS_IOC_RELEASE_COMPRESS_BLOCKS
There are still reserved blocks on compressed inode, this patch introduce a new ioctl to help release reserved blocks back to filesystem, so that userspace can reuse those freed space.
Signed-off-by Chao Yu <[email protected]>
---
v3:
- do sanity check on blkaddr in prior to block release.
- fix to call put_user if @ret is not negative.
- set SBI_NEED_FSCK if we release reserved blocks partially.
fs/f2fs/f2fs.h | 6 ++ fs/f2fs/file.c | 154 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 159 insertions(+), 1 deletion(-)
fs/f2fs/f2fs.h +6 -0
@@ -427,6 +427,8 @@ static inline bool __has_cursum_space(struct f2fs_journal *journal,#define F2FS_IOC_PRECACHE_EXTENTS _IO(F2FS_IOCTL_MAGIC, 15)#define F2FS_IOC_RESIZE_FS _IOW(F2FS_IOCTL_MAGIC, 16, __u64)#define F2FS_IOC_GET_COMPRESS_BLOCKS _IOR(F2FS_IOCTL_MAGIC, 17, __u64) +#define F2FS_IOC_RELEASE_COMPRESS_BLOCKS \ + _IOR(F2FS_IOCTL_MAGIC, 18, __u64)#define F2FS_IOC_GET_VOLUME_NAME FS_IOC_GETFSLABEL#define F2FS_IOC_SET_VOLUME_NAME FS_IOC_SETFSLABEL
@@ -3957,6 +3959,10 @@ static inline void f2fs_i_compr_blocks_update(struct inode *inode, {int diff =F2FS_I (inode)->i_cluster_size - blocks; +/* don't update i_compr_blocks if saved blocks were released */ +if (!add && !F2FS_I (inode)->i_compr_blocks) +return ; +if (add) {F2FS_I (inode)->i_compr_blocks += diff;stat_add_compr_blocks (inode, diff);
fs/f2fs/file.c +153 -1
184 lines not on this page · raw message
Signature · 8 lines
2.18.0.rc1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel