diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2021-12-21 03:03:46 +0300 |
---|---|---|
committer | Matthew Wilcox (Oracle) <willy@infradead.org> | 2021-12-21 21:51:08 +0300 |
commit | 4d7bd0eb72e5831ddb1288786a96448b48440825 (patch) | |
tree | f29de0e0016bbb01de333246b26250d3971efae2 /fs/iomap/buffered-io.c | |
parent | 6795801366da0cd3d99e27c37f020a8f16714886 (diff) | |
download | linux-4d7bd0eb72e5831ddb1288786a96448b48440825.tar.xz |
iomap: Inline __iomap_zero_iter into its caller
To make the merge easier, replicate the inlining of __iomap_zero_iter()
into iomap_zero_iter() that is currently in the nvdimm tree.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/iomap/buffered-io.c')
-rw-r--r-- | fs/iomap/buffered-io.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index ba80bedd9590..c6b3a148e898 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -895,27 +895,6 @@ iomap_file_unshare(struct inode *inode, loff_t pos, loff_t len, } EXPORT_SYMBOL_GPL(iomap_file_unshare); -static s64 __iomap_zero_iter(struct iomap_iter *iter, loff_t pos, u64 length) -{ - struct folio *folio; - int status; - size_t offset; - size_t bytes = min_t(u64, SIZE_MAX, length); - - status = iomap_write_begin(iter, pos, bytes, &folio); - if (status) - return status; - - offset = offset_in_folio(folio, pos); - if (bytes > folio_size(folio) - offset) - bytes = folio_size(folio) - offset; - - folio_zero_range(folio, offset, bytes); - folio_mark_accessed(folio); - - return iomap_write_end(iter, pos, bytes, bytes, folio); -} - static loff_t iomap_zero_iter(struct iomap_iter *iter, bool *did_zero) { struct iomap *iomap = &iter->iomap; @@ -929,14 +908,34 @@ static loff_t iomap_zero_iter(struct iomap_iter *iter, bool *did_zero) return length; do { - s64 bytes; + struct folio *folio; + int status; + size_t offset; + size_t bytes = min_t(u64, SIZE_MAX, length); + + if (IS_DAX(iter->inode)) { + s64 tmp = dax_iomap_zero(pos, bytes, iomap); + if (tmp < 0) + return tmp; + bytes = tmp; + goto good; + } - if (IS_DAX(iter->inode)) - bytes = dax_iomap_zero(pos, length, iomap); - else - bytes = __iomap_zero_iter(iter, pos, length); - if (bytes < 0) - return bytes; + status = iomap_write_begin(iter, pos, bytes, &folio); + if (status) + return status; + + offset = offset_in_folio(folio, pos); + if (bytes > folio_size(folio) - offset) + bytes = folio_size(folio) - offset; + + folio_zero_range(folio, offset, bytes); + folio_mark_accessed(folio); + + bytes = iomap_write_end(iter, pos, bytes, bytes, folio); +good: + if (WARN_ON_ONCE(bytes == 0)) + return -EIO; pos += bytes; length -= bytes; |