mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-19 23:02:31 +00:00
ocfs2: Use filemap_write_and_wait_range() in ocfs2_cow_sync_writeback()
Remove the open-coding of filemap_fdatawait_range(). Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
This commit is contained in:
parent
e775dfb33d
commit
97a3a383c4
@ -3146,48 +3146,18 @@ int ocfs2_cow_sync_writeback(struct super_block *sb,
|
|||||||
struct inode *inode,
|
struct inode *inode,
|
||||||
u32 cpos, u32 num_clusters)
|
u32 cpos, u32 num_clusters)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret;
|
||||||
loff_t offset, end, map_end;
|
loff_t start, end;
|
||||||
pgoff_t page_index;
|
|
||||||
struct page *page;
|
|
||||||
|
|
||||||
if (ocfs2_should_order_data(inode))
|
if (ocfs2_should_order_data(inode))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
offset = ((loff_t)cpos) << OCFS2_SB(sb)->s_clustersize_bits;
|
start = ((loff_t)cpos) << OCFS2_SB(sb)->s_clustersize_bits;
|
||||||
end = offset + (num_clusters << OCFS2_SB(sb)->s_clustersize_bits);
|
end = start + (num_clusters << OCFS2_SB(sb)->s_clustersize_bits) - 1;
|
||||||
|
|
||||||
ret = filemap_fdatawrite_range(inode->i_mapping,
|
ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
|
||||||
offset, end - 1);
|
if (ret < 0)
|
||||||
if (ret < 0) {
|
|
||||||
mlog_errno(ret);
|
mlog_errno(ret);
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (offset < end) {
|
|
||||||
page_index = offset >> PAGE_SHIFT;
|
|
||||||
map_end = ((loff_t)page_index + 1) << PAGE_SHIFT;
|
|
||||||
if (map_end > end)
|
|
||||||
map_end = end;
|
|
||||||
|
|
||||||
page = find_or_create_page(inode->i_mapping,
|
|
||||||
page_index, GFP_NOFS);
|
|
||||||
BUG_ON(!page);
|
|
||||||
|
|
||||||
wait_on_page_writeback(page);
|
|
||||||
if (PageError(page)) {
|
|
||||||
ret = -EIO;
|
|
||||||
mlog_errno(ret);
|
|
||||||
} else
|
|
||||||
mark_page_accessed(page);
|
|
||||||
|
|
||||||
unlock_page(page);
|
|
||||||
put_page(page);
|
|
||||||
page = NULL;
|
|
||||||
offset = map_end;
|
|
||||||
if (ret)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user