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

iomap: switch iomap_file_buffered_write to use iomap_iter

Switch iomap_file_buffered_write 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 f6d48000
...@@ -726,13 +726,14 @@ static size_t iomap_write_end(struct inode *inode, loff_t pos, size_t len, ...@@ -726,13 +726,14 @@ static size_t iomap_write_end(struct inode *inode, loff_t pos, size_t len,
return ret; return ret;
} }
static loff_t static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)
iomap_write_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
struct iomap *iomap, struct iomap *srcmap)
{ {
struct iov_iter *i = data; struct iomap *srcmap = iomap_iter_srcmap(iter);
long status = 0; struct iomap *iomap = &iter->iomap;
loff_t length = iomap_length(iter);
loff_t pos = iter->pos;
ssize_t written = 0; ssize_t written = 0;
long status = 0;
do { do {
struct page *page; struct page *page;
...@@ -758,18 +759,18 @@ iomap_write_actor(struct inode *inode, loff_t pos, loff_t length, void *data, ...@@ -758,18 +759,18 @@ iomap_write_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
break; break;
} }
status = iomap_write_begin(inode, pos, bytes, 0, &page, iomap, status = iomap_write_begin(iter->inode, pos, bytes, 0, &page,
srcmap); iomap, srcmap);
if (unlikely(status)) if (unlikely(status))
break; break;
if (mapping_writably_mapped(inode->i_mapping)) if (mapping_writably_mapped(iter->inode->i_mapping))
flush_dcache_page(page); flush_dcache_page(page);
copied = copy_page_from_iter_atomic(page, offset, bytes, i); copied = copy_page_from_iter_atomic(page, offset, bytes, i);
status = iomap_write_end(inode, pos, bytes, copied, page, iomap, status = iomap_write_end(iter->inode, pos, bytes, copied, page,
srcmap); iomap, srcmap);
if (unlikely(copied != status)) if (unlikely(copied != status))
iov_iter_revert(i, copied - status); iov_iter_revert(i, copied - status);
...@@ -790,29 +791,29 @@ iomap_write_actor(struct inode *inode, loff_t pos, loff_t length, void *data, ...@@ -790,29 +791,29 @@ iomap_write_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
written += status; written += status;
length -= status; length -= status;
balance_dirty_pages_ratelimited(inode->i_mapping); balance_dirty_pages_ratelimited(iter->inode->i_mapping);
} while (iov_iter_count(i) && length); } while (iov_iter_count(i) && length);
return written ? written : status; return written ? written : status;
} }
ssize_t ssize_t
iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *iter, iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i,
const struct iomap_ops *ops) const struct iomap_ops *ops)
{ {
struct inode *inode = iocb->ki_filp->f_mapping->host; struct iomap_iter iter = {
loff_t pos = iocb->ki_pos, ret = 0, written = 0; .inode = iocb->ki_filp->f_mapping->host,
.pos = iocb->ki_pos,
while (iov_iter_count(iter)) { .len = iov_iter_count(i),
ret = iomap_apply(inode, pos, iov_iter_count(iter), .flags = IOMAP_WRITE,
IOMAP_WRITE, ops, iter, iomap_write_actor); };
if (ret <= 0) int ret;
break;
pos += ret;
written += ret;
}
return written ? written : ret; while ((ret = iomap_iter(&iter, ops)) > 0)
iter.processed = iomap_write_iter(&iter, i);
if (iter.pos == iocb->ki_pos)
return ret;
return iter.pos - iocb->ki_pos;
} }
EXPORT_SYMBOL_GPL(iomap_file_buffered_write); EXPORT_SYMBOL_GPL(iomap_file_buffered_write);
......
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