diff options
author | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2014-04-29 04:28:32 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2014-05-06 21:21:58 -0400 |
commit | 54b591dfda1f5ab0bc2a9ce1bee5364110168777 (patch) | |
tree | 7f7f2ad061083fad401fcbc96728817e3cbe790e | |
parent | 8aa6f1c5bd7043734fff1961a4795da9cc5d0f50 (diff) |
f2fs: split grab_cache_page and wait_on_page_writeback for node pages
This patch splits grab_cache_page_write_begin into grab_cache_page and
wait_on_page_writeback for node pages.
This patch intends to enhance the latency to get node pages by alleviating
unnecessary wait_on_page_writeback.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
-rw-r--r-- | fs/f2fs/dir.c | 2 | ||||
-rw-r--r-- | fs/f2fs/inline.c | 6 | ||||
-rw-r--r-- | fs/f2fs/node.c | 8 | ||||
-rw-r--r-- | fs/f2fs/node.h | 2 | ||||
-rw-r--r-- | fs/f2fs/xattr.c | 3 |
5 files changed, 16 insertions, 5 deletions
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 3581c2bde21b..c3f148555c37 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c | |||
@@ -268,6 +268,8 @@ static void init_dent_inode(const struct qstr *name, struct page *ipage) | |||
268 | { | 268 | { |
269 | struct f2fs_inode *ri; | 269 | struct f2fs_inode *ri; |
270 | 270 | ||
271 | f2fs_wait_on_page_writeback(ipage, NODE); | ||
272 | |||
271 | /* copy name info. to this inode page */ | 273 | /* copy name info. to this inode page */ |
272 | ri = F2FS_INODE(ipage); | 274 | ri = F2FS_INODE(ipage); |
273 | ri->i_namelen = cpu_to_le32(name->len); | 275 | ri->i_namelen = cpu_to_le32(name->len); |
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c index d215dbb09f07..8bf34f052f67 100644 --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c | |||
@@ -156,6 +156,7 @@ int f2fs_write_inline_data(struct inode *inode, | |||
156 | return err; | 156 | return err; |
157 | ipage = dn.inode_page; | 157 | ipage = dn.inode_page; |
158 | 158 | ||
159 | f2fs_wait_on_page_writeback(ipage, NODE); | ||
159 | zero_user_segment(ipage, INLINE_DATA_OFFSET, | 160 | zero_user_segment(ipage, INLINE_DATA_OFFSET, |
160 | INLINE_DATA_OFFSET + MAX_INLINE_DATA); | 161 | INLINE_DATA_OFFSET + MAX_INLINE_DATA); |
161 | src_addr = kmap(page); | 162 | src_addr = kmap(page); |
@@ -188,6 +189,8 @@ void truncate_inline_data(struct inode *inode, u64 from) | |||
188 | if (IS_ERR(ipage)) | 189 | if (IS_ERR(ipage)) |
189 | return; | 190 | return; |
190 | 191 | ||
192 | f2fs_wait_on_page_writeback(ipage, NODE); | ||
193 | |||
191 | zero_user_segment(ipage, INLINE_DATA_OFFSET + from, | 194 | zero_user_segment(ipage, INLINE_DATA_OFFSET + from, |
192 | INLINE_DATA_OFFSET + MAX_INLINE_DATA); | 195 | INLINE_DATA_OFFSET + MAX_INLINE_DATA); |
193 | set_page_dirty(ipage); | 196 | set_page_dirty(ipage); |
@@ -218,6 +221,8 @@ process_inline: | |||
218 | ipage = get_node_page(sbi, inode->i_ino); | 221 | ipage = get_node_page(sbi, inode->i_ino); |
219 | f2fs_bug_on(IS_ERR(ipage)); | 222 | f2fs_bug_on(IS_ERR(ipage)); |
220 | 223 | ||
224 | f2fs_wait_on_page_writeback(ipage, NODE); | ||
225 | |||
221 | src_addr = inline_data_addr(npage); | 226 | src_addr = inline_data_addr(npage); |
222 | dst_addr = inline_data_addr(ipage); | 227 | dst_addr = inline_data_addr(ipage); |
223 | memcpy(dst_addr, src_addr, MAX_INLINE_DATA); | 228 | memcpy(dst_addr, src_addr, MAX_INLINE_DATA); |
@@ -229,6 +234,7 @@ process_inline: | |||
229 | if (f2fs_has_inline_data(inode)) { | 234 | if (f2fs_has_inline_data(inode)) { |
230 | ipage = get_node_page(sbi, inode->i_ino); | 235 | ipage = get_node_page(sbi, inode->i_ino); |
231 | f2fs_bug_on(IS_ERR(ipage)); | 236 | f2fs_bug_on(IS_ERR(ipage)); |
237 | f2fs_wait_on_page_writeback(ipage, NODE); | ||
232 | zero_user_segment(ipage, INLINE_DATA_OFFSET, | 238 | zero_user_segment(ipage, INLINE_DATA_OFFSET, |
233 | INLINE_DATA_OFFSET + MAX_INLINE_DATA); | 239 | INLINE_DATA_OFFSET + MAX_INLINE_DATA); |
234 | clear_inode_flag(F2FS_I(inode), FI_INLINE_DATA); | 240 | clear_inode_flag(F2FS_I(inode), FI_INLINE_DATA); |
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 2803ef6cf533..059aaf5dda2b 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c | |||
@@ -853,8 +853,7 @@ struct page *new_node_page(struct dnode_of_data *dn, | |||
853 | if (unlikely(is_inode_flag_set(F2FS_I(dn->inode), FI_NO_ALLOC))) | 853 | if (unlikely(is_inode_flag_set(F2FS_I(dn->inode), FI_NO_ALLOC))) |
854 | return ERR_PTR(-EPERM); | 854 | return ERR_PTR(-EPERM); |
855 | 855 | ||
856 | page = grab_cache_page_write_begin(NODE_MAPPING(sbi), | 856 | page = grab_cache_page(NODE_MAPPING(sbi), dn->nid); |
857 | dn->nid, AOP_FLAG_NOFS); | ||
858 | if (!page) | 857 | if (!page) |
859 | return ERR_PTR(-ENOMEM); | 858 | return ERR_PTR(-ENOMEM); |
860 | 859 | ||
@@ -871,6 +870,7 @@ struct page *new_node_page(struct dnode_of_data *dn, | |||
871 | new_ni.ino = dn->inode->i_ino; | 870 | new_ni.ino = dn->inode->i_ino; |
872 | set_node_addr(sbi, &new_ni, NEW_ADDR, false); | 871 | set_node_addr(sbi, &new_ni, NEW_ADDR, false); |
873 | 872 | ||
873 | f2fs_wait_on_page_writeback(page, NODE); | ||
874 | fill_node_footer(page, dn->nid, dn->inode->i_ino, ofs, true); | 874 | fill_node_footer(page, dn->nid, dn->inode->i_ino, ofs, true); |
875 | set_cold_node(dn->inode, page); | 875 | set_cold_node(dn->inode, page); |
876 | SetPageUptodate(page); | 876 | SetPageUptodate(page); |
@@ -950,8 +950,7 @@ struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid) | |||
950 | struct page *page; | 950 | struct page *page; |
951 | int err; | 951 | int err; |
952 | repeat: | 952 | repeat: |
953 | page = grab_cache_page_write_begin(NODE_MAPPING(sbi), | 953 | page = grab_cache_page(NODE_MAPPING(sbi), nid); |
954 | nid, AOP_FLAG_NOFS); | ||
955 | if (!page) | 954 | if (!page) |
956 | return ERR_PTR(-ENOMEM); | 955 | return ERR_PTR(-ENOMEM); |
957 | 956 | ||
@@ -1562,6 +1561,7 @@ static void recover_inline_xattr(struct inode *inode, struct page *page) | |||
1562 | src_addr = inline_xattr_addr(page); | 1561 | src_addr = inline_xattr_addr(page); |
1563 | inline_size = inline_xattr_size(inode); | 1562 | inline_size = inline_xattr_size(inode); |
1564 | 1563 | ||
1564 | f2fs_wait_on_page_writeback(ipage, NODE); | ||
1565 | memcpy(dst_addr, src_addr, inline_size); | 1565 | memcpy(dst_addr, src_addr, inline_size); |
1566 | 1566 | ||
1567 | update_inode(inode, ipage); | 1567 | update_inode(inode, ipage); |
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h index a076c88bdca5..4ee29d506f8c 100644 --- a/fs/f2fs/node.h +++ b/fs/f2fs/node.h | |||
@@ -272,7 +272,7 @@ static inline void set_nid(struct page *p, int off, nid_t nid, bool i) | |||
272 | { | 272 | { |
273 | struct f2fs_node *rn = F2FS_NODE(p); | 273 | struct f2fs_node *rn = F2FS_NODE(p); |
274 | 274 | ||
275 | wait_on_page_writeback(p); | 275 | f2fs_wait_on_page_writeback(p, NODE); |
276 | 276 | ||
277 | if (i) | 277 | if (i) |
278 | rn->i.i_nid[off - NODE_DIR1_BLOCK] = cpu_to_le32(nid); | 278 | rn->i.i_nid[off - NODE_DIR1_BLOCK] = cpu_to_le32(nid); |
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c index 6073f9f88416..1f546b4b6b61 100644 --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c | |||
@@ -349,6 +349,7 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize, | |||
349 | 349 | ||
350 | if (ipage) { | 350 | if (ipage) { |
351 | inline_addr = inline_xattr_addr(ipage); | 351 | inline_addr = inline_xattr_addr(ipage); |
352 | f2fs_wait_on_page_writeback(ipage, NODE); | ||
352 | } else { | 353 | } else { |
353 | page = get_node_page(sbi, inode->i_ino); | 354 | page = get_node_page(sbi, inode->i_ino); |
354 | if (IS_ERR(page)) { | 355 | if (IS_ERR(page)) { |
@@ -356,6 +357,7 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize, | |||
356 | return PTR_ERR(page); | 357 | return PTR_ERR(page); |
357 | } | 358 | } |
358 | inline_addr = inline_xattr_addr(page); | 359 | inline_addr = inline_xattr_addr(page); |
360 | f2fs_wait_on_page_writeback(page, NODE); | ||
359 | } | 361 | } |
360 | memcpy(inline_addr, txattr_addr, inline_size); | 362 | memcpy(inline_addr, txattr_addr, inline_size); |
361 | f2fs_put_page(page, 1); | 363 | f2fs_put_page(page, 1); |
@@ -376,6 +378,7 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize, | |||
376 | return PTR_ERR(xpage); | 378 | return PTR_ERR(xpage); |
377 | } | 379 | } |
378 | f2fs_bug_on(new_nid); | 380 | f2fs_bug_on(new_nid); |
381 | f2fs_wait_on_page_writeback(xpage, NODE); | ||
379 | } else { | 382 | } else { |
380 | struct dnode_of_data dn; | 383 | struct dnode_of_data dn; |
381 | set_new_dnode(&dn, inode, NULL, NULL, new_nid); | 384 | set_new_dnode(&dn, inode, NULL, NULL, new_nid); |