f2fs: fix to convert inline inode in ->setattr
authorChao Yu <chao2.yu@samsung.com>
Tue, 1 Dec 2015 03:36:16 +0000 (11:36 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 4 Dec 2015 21:14:44 +0000 (13:14 -0800)
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.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/file.c

index 96e4e048a8a1aa6c31bdbff54a4e2e237f2f1d0b..a018ed327713ba3dfdf241ab34e9029e43e37a36 100644 (file)
@@ -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;
                }
        }