Commit 253564ba authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

iomap: switch iomap_page_mkwrite to use iomap_iter

Switch iomap_page_mkwrite to use iomap_iter.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent 2aa3048e
...@@ -961,15 +961,15 @@ iomap_truncate_page(struct inode *inode, loff_t pos, bool *did_zero, ...@@ -961,15 +961,15 @@ iomap_truncate_page(struct inode *inode, loff_t pos, bool *did_zero,
} }
EXPORT_SYMBOL_GPL(iomap_truncate_page); EXPORT_SYMBOL_GPL(iomap_truncate_page);
static loff_t static loff_t iomap_page_mkwrite_iter(struct iomap_iter *iter,
iomap_page_mkwrite_actor(struct inode *inode, loff_t pos, loff_t length, struct page *page)
void *data, struct iomap *iomap, struct iomap *srcmap)
{ {
struct page *page = data; loff_t length = iomap_length(iter);
int ret; int ret;
if (iomap->flags & IOMAP_F_BUFFER_HEAD) { if (iter->iomap.flags & IOMAP_F_BUFFER_HEAD) {
ret = __block_write_begin_int(page, pos, length, NULL, iomap); ret = __block_write_begin_int(page, iter->pos, length, NULL,
&iter->iomap);
if (ret) if (ret)
return ret; return ret;
block_commit_write(page, 0, length); block_commit_write(page, 0, length);
...@@ -983,29 +983,24 @@ iomap_page_mkwrite_actor(struct inode *inode, loff_t pos, loff_t length, ...@@ -983,29 +983,24 @@ iomap_page_mkwrite_actor(struct inode *inode, loff_t pos, loff_t length,
vm_fault_t iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops) vm_fault_t iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops)
{ {
struct iomap_iter iter = {
.inode = file_inode(vmf->vma->vm_file),
.flags = IOMAP_WRITE | IOMAP_FAULT,
};
struct page *page = vmf->page; struct page *page = vmf->page;
struct inode *inode = file_inode(vmf->vma->vm_file);
unsigned long length;
loff_t offset;
ssize_t ret; ssize_t ret;
lock_page(page); lock_page(page);
ret = page_mkwrite_check_truncate(page, inode); ret = page_mkwrite_check_truncate(page, iter.inode);
if (ret < 0) if (ret < 0)
goto out_unlock; goto out_unlock;
length = ret; iter.pos = page_offset(page);
iter.len = ret;
offset = page_offset(page); while ((ret = iomap_iter(&iter, ops)) > 0)
while (length > 0) { iter.processed = iomap_page_mkwrite_iter(&iter, page);
ret = iomap_apply(inode, offset, length,
IOMAP_WRITE | IOMAP_FAULT, ops, page,
iomap_page_mkwrite_actor);
if (unlikely(ret <= 0))
goto out_unlock;
offset += ret;
length -= ret;
}
if (ret < 0)
goto out_unlock;
wait_for_stable_page(page); wait_for_stable_page(page);
return VM_FAULT_LOCKED; return VM_FAULT_LOCKED;
out_unlock: out_unlock:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment