aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2015-03-17 20:16:35 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2015-04-10 18:08:46 -0400
commit3c6c2bebef79999b1827041696dc1881e637e3af (patch)
tree32391cbf119529871a6663ed62d5ab0b2e94a09e /fs/f2fs
parent83e21db6939dd6ff50a81d54aaef4b44847aefff (diff)
f2fs: avoid punch_hole overhead when releasing volatile data
This patch is to avoid some punch_hole overhead when releasing volatile data. If volatile data was not written yet, we just can make the first page as zero. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/data.c2
-rw-r--r--fs/f2fs/f2fs.h6
-rw-r--r--fs/f2fs/file.c6
-rw-r--r--fs/f2fs/inode.c10
4 files changed, 24 insertions, 0 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index f0a18a005bda..486113db97b1 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1291,6 +1291,8 @@ int do_write_data_page(struct page *page, struct f2fs_io_info *fio)
1291 write_data_page(page, &dn, fio); 1291 write_data_page(page, &dn, fio);
1292 f2fs_update_extent_cache(&dn); 1292 f2fs_update_extent_cache(&dn);
1293 set_inode_flag(F2FS_I(inode), FI_APPEND_WRITE); 1293 set_inode_flag(F2FS_I(inode), FI_APPEND_WRITE);
1294 if (page->index == 0)
1295 set_inode_flag(F2FS_I(inode), FI_FIRST_BLOCK_WRITTEN);
1294 } 1296 }
1295out_writepage: 1297out_writepage:
1296 f2fs_put_dnode(&dn); 1298 f2fs_put_dnode(&dn);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index dbe114463a18..9e378179ff93 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1232,6 +1232,7 @@ enum {
1232 FI_NEED_IPU, /* used for ipu per file */ 1232 FI_NEED_IPU, /* used for ipu per file */
1233 FI_ATOMIC_FILE, /* indicate atomic file */ 1233 FI_ATOMIC_FILE, /* indicate atomic file */
1234 FI_VOLATILE_FILE, /* indicate volatile file */ 1234 FI_VOLATILE_FILE, /* indicate volatile file */
1235 FI_FIRST_BLOCK_WRITTEN, /* indicate #0 data block was written */
1235 FI_DROP_CACHE, /* drop dirty page cache */ 1236 FI_DROP_CACHE, /* drop dirty page cache */
1236 FI_DATA_EXIST, /* indicate data exists */ 1237 FI_DATA_EXIST, /* indicate data exists */
1237}; 1238};
@@ -1340,6 +1341,11 @@ static inline bool f2fs_is_volatile_file(struct inode *inode)
1340 return is_inode_flag_set(F2FS_I(inode), FI_VOLATILE_FILE); 1341 return is_inode_flag_set(F2FS_I(inode), FI_VOLATILE_FILE);
1341} 1342}
1342 1343
1344static inline bool f2fs_is_first_block_written(struct inode *inode)
1345{
1346 return is_inode_flag_set(F2FS_I(inode), FI_FIRST_BLOCK_WRITTEN);
1347}
1348
1343static inline bool f2fs_is_drop_cache(struct inode *inode) 1349static inline bool f2fs_is_drop_cache(struct inode *inode)
1344{ 1350{
1345 return is_inode_flag_set(F2FS_I(inode), FI_DROP_CACHE); 1351 return is_inode_flag_set(F2FS_I(inode), FI_DROP_CACHE);
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 36dc7581a28b..39a07a59b134 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -437,6 +437,9 @@ int truncate_data_blocks_range(struct dnode_of_data *dn, int count)
437 dn->data_blkaddr = NULL_ADDR; 437 dn->data_blkaddr = NULL_ADDR;
438 f2fs_update_extent_cache(dn); 438 f2fs_update_extent_cache(dn);
439 invalidate_blocks(sbi, blkaddr); 439 invalidate_blocks(sbi, blkaddr);
440 if (dn->ofs_in_node == 0 && IS_INODE(dn->node_page))
441 clear_inode_flag(F2FS_I(dn->inode),
442 FI_FIRST_BLOCK_WRITTEN);
440 nr_free++; 443 nr_free++;
441 } 444 }
442 if (nr_free) { 445 if (nr_free) {
@@ -1005,6 +1008,9 @@ static int f2fs_ioc_release_volatile_write(struct file *filp)
1005 if (!f2fs_is_volatile_file(inode)) 1008 if (!f2fs_is_volatile_file(inode))
1006 return 0; 1009 return 0;
1007 1010
1011 if (!f2fs_is_first_block_written(inode))
1012 return truncate_partial_data_page(inode, 0, true);
1013
1008 punch_hole(inode, 0, F2FS_BLKSIZE); 1014 punch_hole(inode, 0, F2FS_BLKSIZE);
1009 return 0; 1015 return 0;
1010} 1016}
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index b5087443be41..bb5800969bcc 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -51,6 +51,13 @@ static void __get_inode_rdev(struct inode *inode, struct f2fs_inode *ri)
51 } 51 }
52} 52}
53 53
54static bool __written_first_block(struct f2fs_inode *ri)
55{
56 if (ri->i_addr[0] != NEW_ADDR && ri->i_addr[0] != NULL_ADDR)
57 return true;
58 return false;
59}
60
54static void __set_inode_rdev(struct inode *inode, struct f2fs_inode *ri) 61static void __set_inode_rdev(struct inode *inode, struct f2fs_inode *ri)
55{ 62{
56 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { 63 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
@@ -143,6 +150,9 @@ static int do_read_inode(struct inode *inode)
143 /* get rdev by using inline_info */ 150 /* get rdev by using inline_info */
144 __get_inode_rdev(inode, ri); 151 __get_inode_rdev(inode, ri);
145 152
153 if (__written_first_block(ri))
154 set_inode_flag(F2FS_I(inode), FI_FIRST_BLOCK_WRITTEN);
155
146 f2fs_put_page(node_page, 1); 156 f2fs_put_page(node_page, 1);
147 157
148 stat_inc_inline_inode(inode); 158 stat_inc_inline_inode(inode);