Skip to contentSkip to conversation

f2fs: fix to convert inline inode in ->setattr

PATCH In review Chao Yu 2 participants 3 messages Dec 1, 2015 – Dec 4, 2015 F2FS file system

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 f2fs: fix to convert inline inode in ->setattr

In commit 3c4541452748 ("f2fs: do not trim preallocated blocks when truncating after i_size"), in order to follow the regulation: "truncate(x) where x > i_size will not trim all blocks past i_size." like other file systems, in ->setattr we invoked truncate_setsize instead of f2fs_truncate to avoid unneeded block trimming in such case, but forgot to call f2fs_convert_inline_inode keep consistency of inline data conversion rule.

This patch fixes to convert inline data if necessary.

---
 fs/f2fs/file.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/f2fs/file.c +8 -0
index 96e4e04..a018ed3 100644
@@ -686,6 +686,14 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
 			 * larger than i_size.
 			 */
 			truncate_setsize(inode, attr->ia_size);
+
+			/* should convert inline inode here */
+			if (f2fs_has_inline_data(inode) &&
+					!f2fs_may_inline_data(inode)) {
+				err = f2fs_convert_inline_inode(inode);
+				if (err)
+					return err;
+			}
 			inode->i_mtime = inode->i_ctime = CURRENT_TIME;
 		}
 	}
Signature · 1 line
2.6.3
maintainer
#1 lore raw

Hi Chao,

Quoted 20 lines · Chao Yu

In commit 3c4541452748 ("f2fs: do not trim preallocated blocks when truncating after i_size"), in order to follow the regulation: "truncate(x) where x > i_size will not trim all blocks past i_size." like other file systems, in ->setattr we invoked truncate_setsize instead of f2fs_truncate to avoid unneeded block trimming in such case, but forgot to call f2fs_convert_inline_inode keep consistency of inline data conversion rule.

This patch fixes to convert inline data if necessary.

---
 fs/f2fs/file.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/f2fs/file.c +0 -0
index 96e4e04..a018ed3 100644
@@ -686,6 +686,14 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
 			 * larger than i_size.

fs/f2fs/file.c int f2fs_setattr(struct dentry *dentry, struct iattr *attr) · line 696

Quoted 10 lines
fs/f2fs/file.c +8 -0
 			 */
 			truncate_setsize(inode, attr->ia_size);
+
+			/* should convert inline inode here */
+			if (f2fs_has_inline_data(inode) &&
+					!f2fs_may_inline_data(inode)) {
+				err = f2fs_convert_inline_inode(inode);
+				if (err)
+					return err;
+			}

Without this, f2fs handles correctly inline_data when user tries to write something later, right?

One corner case is:
if the partiton is filled up to 100% with data + inline_data, we cannot truncate one of inline_data after merging this patch.
Cause it failed to convert it.

Thanks,

Quoted 6 lines
fs/f2fs/file.c +0 -0
 			inode->i_mtime = inode->i_ctime = CURRENT_TIME;
 		}
 	}
Signature · 1 line
2.6.3
maintainer
#2 lore raw
Quoted 37 lines · Jaegeuk Kim

Hi Chao,

Quoted 20 lines · Chao Yu

In commit 3c4541452748 ("f2fs: do not trim preallocated blocks when truncating after i_size"), in order to follow the regulation: "truncate(x) where x > i_size will not trim all blocks past i_size." like other file systems, in ->setattr we invoked truncate_setsize instead of f2fs_truncate to avoid unneeded block trimming in such case, but forgot to call f2fs_convert_inline_inode keep consistency of inline data conversion rule.

This patch fixes to convert inline data if necessary.

---
 fs/f2fs/file.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/f2fs/file.c +0 -0
index 96e4e04..a018ed3 100644
@@ -686,6 +686,14 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
 			 * larger than i_size.

fs/f2fs/file.c int f2fs_setattr(struct dentry *dentry, struct iattr *attr) · line 696

Quoted 10 lines
fs/f2fs/file.c +8 -0
 			 */
 			truncate_setsize(inode, attr->ia_size);
+
+			/* should convert inline inode here */
+			if (f2fs_has_inline_data(inode) &&
+					!f2fs_may_inline_data(inode)) {
+				err = f2fs_convert_inline_inode(inode);
+				if (err)
+					return err;
+			}

Without this, f2fs handles correctly inline_data when user tries to write something later, right?

Quoted 4 lines

One corner case is:
if the partiton is filled up to 100% with data + inline_data, we cannot truncate one of inline_data after merging this patch.
Cause it failed to convert it.

Oh, it turns out this is due to the error handling -ENOSPC of f2fs_truncate. For now, it seems there is no easy workaround this.
Please ignore my concern. ;)

Thanks,

Quoted 20 lines

Thanks,

Quoted 6 lines
fs/f2fs/file.c +0 -0
 			inode->i_mtime = inode->i_ctime = CURRENT_TIME;
 		}
 	}
Signature · 1 line
2.6.3

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK. Use one codebase in this all-in-one HTML5 development environment. Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel