f2fs: reduce unncessary locking pages during read
Subsystems (2)
PATCH 1/1 f2fs: reduce unncessary locking pages during read
This patch reduces redundant locking and unlocking pages during read operations. In f2fs_readpage, let's use wait_on_page_locked() instead of lock_page. And then, when we need to modify any data finally, let's lock the page so that we can avoid lock contention.
[readpage rule]
- The f2fs_readpage returns unlocked page, or released page too in error cases.
- Its caller should handle read error, -EIO, after locking the page, which indicates read completion.
- Its caller should check PageUptodate after grab_cache_page.
--- fs/f2fs/checkpoint.c | 12 ++++++----- fs/f2fs/data.c | 58 ++++++++++++++++++++++++++-------------------------- fs/f2fs/node.c | 58 +++++++++++++++++++++++++++++++--------------------- fs/f2fs/recovery.c | 31 +++++++++++++++++----------- 4 files changed, 90 insertions(+), 69 deletions(-)
fs/f2fs/checkpoint.c +7 -5
@@ -57,13 +57,15 @@ repeat:cond_resched (); goto repeat; } -if (f2fs_readpage (sbi, page, index,READ_SYNC )) { -f2fs_put_page (page,1 ); +if (PageUptodate (page)) + goto out; + +if (f2fs_readpage (sbi, page, index,READ_SYNC )) goto repeat; - } -mark_page_accessed (page); -/* We do not allow returning an errorneous page */ +lock_page (page); +out: +mark_page_accessed (page);return page; }
fs/f2fs/data.c +29 -29
122 lines not on this page · raw message
fs/f2fs/node.c +35 -23
123 lines not on this page · raw message
fs/f2fs/recovery.c +19 -12
@@ -112,11 +112,17 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)while (1 ) {struct fsync_inode_entry *entry; -if (f2fs_readpage (sbi, page, blkaddr,READ_SYNC )) +ClearPageUptodate (page); + err =f2fs_readpage (sbi, page, blkaddr,READ_SYNC ); +if (err) goto out; -if (cp_ver !=cpver_of_node (page)) - goto out; +lock_page (page); + +if (cp_ver !=cpver_of_node (page)) { + err = -EINVAL ; + goto unlock_out; + }if (!is_fsync_dnode (page)) goto next;
@@ -131,7 +137,7 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)if (IS_INODE (page) &&is_dent_dnode (page)) {if (recover_inode_page (sbi, page)) { err = -ENOMEM ; - goto out; + goto unlock_out; } }
@@ -139,14 +145,14 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head) entry =kmem_cache_alloc (fsync_entry_slab,GFP_NOFS );if (!entry) { err = -ENOMEM ; - goto out; + goto unlock_out; } entry->inode =f2fs_iget (sbi->sb,ino_of_node (page));if (IS_ERR (entry->inode)) { err =PTR_ERR (entry->inode);kmem_cache_free (fsync_entry_slab, entry); - goto out; + goto unlock_out; }list_add_tail (&entry->list, head);
@@ -155,15 +161,15 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)if (IS_INODE (page)) { err =recover_inode (entry->inode, page);if (err) - goto out; + goto unlock_out; } next:/* check next segment */ blkaddr =next_blkaddr_of_node (page); -ClearPageUptodate (page); } -out: +unlock_out:unlock_page (page); +out:__free_pages (page,0 );return err; }
@@ -316,11 +322,12 @@ static void recover_data(struct f2fs_sb_info *sbi,while (1 ) {struct fsync_inode_entry *entry; +ClearPageUptodate (page);if (f2fs_readpage (sbi, page, blkaddr,READ_SYNC )) goto out;if (cp_ver !=cpver_of_node (page)) - goto out; + goto unlock_out; entry =get_fsync_inode (head,ino_of_node (page));if (!entry)
@@ -336,10 +343,10 @@ static void recover_data(struct f2fs_sb_info *sbi, next:/* check next segment */ blkaddr =next_blkaddr_of_node (page); -ClearPageUptodate (page); } -out: +unlock_out:unlock_page (page); +out:__free_pages (page,0 );allocate_new_segments (sbi);
Signature · 1 line
1.8.1.3.566.gaa39828
fs/f2fs/data.c struct page *find_data_page(struct inode *inode, pgoff_t index) · line 207
Quoted 10 lines
fs/f2fs/data.c +3
-5- err =f2fs_readpage (sbi, page, dn.data_blkaddr,READ_SYNC ); -if (err) { -f2fs_put_page (page,1 ); -return ERR_PTR (err); +if (PageUptodate (page)) { +unlock_page (page); +return page; } -unlock_page (page);
Hi Jaegeuk.
fs/f2fs/data.c struct page *find_data_page(struct inode *inode, pgoff_t index) · line 210
Quoted 5 lines
fs/f2fs/data.c +5
-0+ + err =f2fs_readpage (sbi, page, dn.data_blkaddr,READ_SYNC ); +wait_on_page_locked (page); +if (!PageUptodate (page)) +return ERR_PTR (-EIO );
We don't need to release page before returning EIO ?
fs/f2fs/data.c struct page *get_lock_data_page(struct inode *inode, · line 249
Quoted 12 lines
fs/f2fs/data.c +1
-2return page; }@@ -241,9 +244,13 @@ struct page *get_lock_data_page(struct inode *inode, pgoff_t index) BUG_ON(dn.data_blkaddr == NULL_ADDR); err =f2fs_readpage (sbi, page, dn.data_blkaddr,READ_SYNC ); -if (err) { -f2fs_put_page (page,1 ); +if (err)return ERR_PTR (err);
Here is also same. We don't need to release page in case of err ?
Thanks.
Quoted 8 lines
fs/f2fs/data.c +5
-0+ +lock_page (page); +if (!PageUptodate (page)) { +f2fs_put_page (page,1 ); +return ERR_PTR (-EIO ); }return page;}
2013-03-19 (화), 13:54 +0900, Namjae Jeon:
Quoted 11 lines
fs/f2fs/data.c struct page *find_data_page(struct inode *inode, pgoff_t index) · line 207
Quoted 10 lines
fs/f2fs/data.c +3
-5- err =f2fs_readpage (sbi, page, dn.data_blkaddr,READ_SYNC ); -if (err) { -f2fs_put_page (page,1 ); -return ERR_PTR (err); +if (PageUptodate (page)) { +unlock_page (page); +return page; } -unlock_page (page);Hi Jaegeuk.
Quoted 6 lines
fs/f2fs/data.c struct page *find_data_page(struct inode *inode, pgoff_t index) · line 210
Quoted 5 lines
fs/f2fs/data.c +5
-0+ + err =f2fs_readpage (sbi, page, dn.data_blkaddr,READ_SYNC ); +wait_on_page_locked (page); +if (!PageUptodate (page)) +return ERR_PTR (-EIO );We don't need to release page before returning EIO ?
Good catch! :)
Quoted 8 lines
Quoted 8 lines
fs/f2fs/data.c +0
-0return page; }@@ -241,9 +244,13 @@ struct page *get_lock_data_page(struct inode *inode, pgoff_t index) BUG_ON(dn.data_blkaddr == NULL_ADDR);
Quoted 6 lines
fs/f2fs/data.c struct page *get_lock_data_page(struct inode *inode, pgoff_t index) · line 248
Quoted 5 lines
fs/f2fs/data.c +1
-2err =f2fs_readpage (sbi, page, dn.data_blkaddr,READ_SYNC ); -if (err) { -f2fs_put_page (page,1 ); +if (err)return ERR_PTR (err);Here is also same. We don't need to release page in case of err ?
It's different.
The f2fs_readpage() releases the page if error is occurred. Thanks,
Quoted 15 lines
Thanks.
Quoted 8 lines
fs/f2fs/data.c +5
-0+ +lock_page (page); +if (!PageUptodate (page)) { +f2fs_put_page (page,1 ); +return ERR_PTR (-EIO ); }return page;}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 2 lines
Jaegeuk Kim Samsung
Namjae Jeon
Reviewed-by2013/3/19, Jaegeuk Kim <[email protected]>:
Quoted 37 lines
2013-03-19 (화), 13:54 +0900, Namjae Jeon:
Quoted 11 lines
fs/f2fs/data.c struct page *find_data_page(struct inode *inode, pgoff_t index) · line 207
Quoted 10 lines
fs/f2fs/data.c +3
-5- err =f2fs_readpage (sbi, page, dn.data_blkaddr,READ_SYNC ); -if (err) { -f2fs_put_page (page,1 ); -return ERR_PTR (err); +if (PageUptodate (page)) { +unlock_page (page); +return page; } -unlock_page (page);Hi Jaegeuk.
Quoted 6 lines
fs/f2fs/data.c struct page *find_data_page(struct inode *inode, pgoff_t index) · line 210
Quoted 5 lines
fs/f2fs/data.c +5
-0+ + err =f2fs_readpage (sbi, page, dn.data_blkaddr,READ_SYNC ); +wait_on_page_locked (page); +if (!PageUptodate (page)) +return ERR_PTR (-EIO );We don't need to release page before returning EIO ?
Good catch! :)
Quoted 9 lines
Quoted 9 lines
fs/f2fs/data.c +0
-0return page; }@@ -241,9 +244,13 @@ struct page *get_lock_data_page(struct inode *inode, pgoff_t index)BUG_ON (dn.data_blkaddr ==NULL_ADDR );Quoted 6 lines
fs/f2fs/data.c struct page *get_lock_data_page(struct inode *inode, pgoff_t index) · line 248
Quoted 5 lines
fs/f2fs/data.c +1
-2err =f2fs_readpage (sbi, page, dn.data_blkaddr,READ_SYNC ); -if (err) { -f2fs_put_page (page,1 ); +if (err)return ERR_PTR (err);Here is also same. We don't need to release page in case of err ?
Quoted 3 lines
It's different.
Thef2fs_readpage()releases the page if error is occurred. Thanks,
Right~. you can add
Thanks.
Quoted 2 lines
Quoted 2 lines