Skip to contentSkip to conversation

f2fs: skip punching hole in special condition

PATCH In review Chao Yu 1 participant 1 message Sep 15, 2014 F2FS file system

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 3/5 f2fs: skip punching hole in special condition

Now punching hole in directory is not supported in f2fs, so let's limit file type in punch_hole().

In addition, in punch_hole if offset is exceed file size, we should skip punching hole.

---
 fs/f2fs/file.c | 7 +++++++
 1 file changed, 7 insertions(+)
fs/f2fs/file.c +7 -0
index 7b34101..ecf94e1 100644
@@ -645,6 +645,13 @@ static int punch_hole(struct inode *inode, loff_t offset, loff_t len)
 	loff_t off_start, off_end;
 	int ret = 0;
 
+	if (!S_ISREG(inode->i_mode))
+		return -EOPNOTSUPP;
+
+	/* skip punching hole beyond i_size */
+	if (offset >= inode->i_size)
+		return ret;
+
 	ret = f2fs_convert_inline_data(inode, MAX_INLINE_DATA + 1, NULL);
 	if (ret)
 		return ret;
Signature · 1 line
2.0.1.474.g72c7794