diff options
author | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-04-26 11:55:17 +0900 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-04-29 11:19:32 +0900 |
commit | afcb7ca01f47b0481e0b248d1542d0934fa70767 (patch) | |
tree | 2834b57b958d2b444d40aa8144ac60ee739507ac /fs/f2fs/data.c | |
parent | 55008d845d233396ed374473da4613cee691aa03 (diff) |
f2fs: check truncation of mapping after lock_page
We call lock_page when we need to update a page after readpage.
Between grab and lock page, the page can be truncated by other thread.
So, we should check the page after lock_page whether it was truncated or not.
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs/data.c')
-rw-r--r-- | fs/f2fs/data.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index eba7e84d1ffd..2db9380f5dda 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -240,7 +240,7 @@ struct page *get_lock_data_page(struct inode *inode, pgoff_t index) if (dn.data_blkaddr == NULL_ADDR) return ERR_PTR(-ENOENT); - +repeat: page = grab_cache_page(mapping, index); if (!page) return ERR_PTR(-ENOMEM); @@ -260,6 +260,10 @@ struct page *get_lock_data_page(struct inode *inode, pgoff_t index) f2fs_put_page(page, 1); return ERR_PTR(-EIO); } + if (page->mapping != mapping) { + f2fs_put_page(page, 1); + goto repeat; + } return page; } @@ -291,7 +295,7 @@ struct page *get_new_data_page(struct inode *inode, pgoff_t index, } } f2fs_put_dnode(&dn); - +repeat: page = grab_cache_page(mapping, index); if (!page) return ERR_PTR(-ENOMEM); @@ -311,6 +315,10 @@ struct page *get_new_data_page(struct inode *inode, pgoff_t index, f2fs_put_page(page, 1); return ERR_PTR(-EIO); } + if (page->mapping != mapping) { + f2fs_put_page(page, 1); + goto repeat; + } } if (new_i_size && @@ -611,7 +619,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, *fsdata = NULL; f2fs_balance_fs(sbi); - +repeat: page = grab_cache_page_write_begin(mapping, index, flags); if (!page) return -ENOMEM; @@ -656,6 +664,10 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, f2fs_put_page(page, 1); return -EIO; } + if (page->mapping != mapping) { + f2fs_put_page(page, 1); + goto repeat; + } } out: SetPageUptodate(page); |