diff options
author | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-10-31 01:57:01 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-10-31 03:01:03 -0400 |
commit | cfe58f9dcd9afe181894e2257e3f8aa3fee840c5 (patch) | |
tree | 1acd83b88bb0cb1aed28ffe3ae6091f69bd0f091 /fs/f2fs | |
parent | 44c60bf2b9f2808e127fa4cd3b11b50a46cf5817 (diff) |
f2fs: avoid to wait all the node blocks during fsync
Previously, f2fs_sync_file() waits for all the node blocks to be written.
But, we don't need to do that, but wait only the inode-related node blocks.
This patch adds wait_on_node_pages_writeback() in which waits inode-related
node blocks that are on writeback.
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/f2fs.h | 1 | ||||
-rw-r--r-- | fs/f2fs/file.c | 5 | ||||
-rw-r--r-- | fs/f2fs/node.c | 40 |
3 files changed, 44 insertions, 2 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 6aaefdbaaac0..625eb4befad4 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -1026,6 +1026,7 @@ void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *); | |||
1026 | int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int); | 1026 | int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int); |
1027 | int truncate_inode_blocks(struct inode *, pgoff_t); | 1027 | int truncate_inode_blocks(struct inode *, pgoff_t); |
1028 | int truncate_xattr_node(struct inode *, struct page *); | 1028 | int truncate_xattr_node(struct inode *, struct page *); |
1029 | int wait_on_node_pages_writeback(struct f2fs_sb_info *, nid_t); | ||
1029 | int remove_inode_page(struct inode *); | 1030 | int remove_inode_page(struct inode *); |
1030 | struct page *new_inode_page(struct inode *, const struct qstr *); | 1031 | struct page *new_inode_page(struct inode *, const struct qstr *); |
1031 | struct page *new_node_page(struct dnode_of_data *, unsigned int, struct page *); | 1032 | struct page *new_node_page(struct dnode_of_data *, unsigned int, struct page *); |
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 58ed19aaa4c6..7d714f4972d5 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c | |||
@@ -189,8 +189,9 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) | |||
189 | if (ret) | 189 | if (ret) |
190 | goto out; | 190 | goto out; |
191 | } | 191 | } |
192 | filemap_fdatawait_range(sbi->node_inode->i_mapping, | 192 | ret = wait_on_node_pages_writeback(sbi, inode->i_ino); |
193 | 0, LONG_MAX); | 193 | if (ret) |
194 | goto out; | ||
194 | ret = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL); | 195 | ret = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL); |
195 | } | 196 | } |
196 | out: | 197 | out: |
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 8e331d5b9fcd..b527ed4c0225 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c | |||
@@ -1148,6 +1148,46 @@ continue_unlock: | |||
1148 | return nwritten; | 1148 | return nwritten; |
1149 | } | 1149 | } |
1150 | 1150 | ||
1151 | int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino) | ||
1152 | { | ||
1153 | struct address_space *mapping = sbi->node_inode->i_mapping; | ||
1154 | pgoff_t index = 0, end = LONG_MAX; | ||
1155 | struct pagevec pvec; | ||
1156 | int nr_pages; | ||
1157 | int ret2 = 0, ret = 0; | ||
1158 | |||
1159 | pagevec_init(&pvec, 0); | ||
1160 | while ((index <= end) && | ||
1161 | (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, | ||
1162 | PAGECACHE_TAG_WRITEBACK, | ||
1163 | min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1)) != 0) { | ||
1164 | unsigned i; | ||
1165 | |||
1166 | for (i = 0; i < nr_pages; i++) { | ||
1167 | struct page *page = pvec.pages[i]; | ||
1168 | |||
1169 | /* until radix tree lookup accepts end_index */ | ||
1170 | if (page->index > end) | ||
1171 | continue; | ||
1172 | |||
1173 | if (ino && ino_of_node(page) == ino) | ||
1174 | wait_on_page_writeback(page); | ||
1175 | if (TestClearPageError(page)) | ||
1176 | ret = -EIO; | ||
1177 | } | ||
1178 | pagevec_release(&pvec); | ||
1179 | cond_resched(); | ||
1180 | } | ||
1181 | |||
1182 | if (test_and_clear_bit(AS_ENOSPC, &mapping->flags)) | ||
1183 | ret2 = -ENOSPC; | ||
1184 | if (test_and_clear_bit(AS_EIO, &mapping->flags)) | ||
1185 | ret2 = -EIO; | ||
1186 | if (!ret) | ||
1187 | ret = ret2; | ||
1188 | return ret; | ||
1189 | } | ||
1190 | |||
1151 | static int f2fs_write_node_page(struct page *page, | 1191 | static int f2fs_write_node_page(struct page *page, |
1152 | struct writeback_control *wbc) | 1192 | struct writeback_control *wbc) |
1153 | { | 1193 | { |