Commit a5f31a50 authored by Darrick J. Wong's avatar Darrick J. Wong

iomap: convert iomap_unshare_iter to use large folios

Convert iomap_unshare_iter to create large folios if possible, since the
write and zeroing paths already do that.  I think this got missed in the
conversion of the write paths that landed in 6.6-rc1.

Cc: ritesh.list@gmail.com, willy@infradead.org
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarRitesh Harjani (IBM) <ritesh.list@gmail.com>
parent 35d30c9c
...@@ -1263,7 +1263,6 @@ static loff_t iomap_unshare_iter(struct iomap_iter *iter) ...@@ -1263,7 +1263,6 @@ static loff_t iomap_unshare_iter(struct iomap_iter *iter)
const struct iomap *srcmap = iomap_iter_srcmap(iter); const struct iomap *srcmap = iomap_iter_srcmap(iter);
loff_t pos = iter->pos; loff_t pos = iter->pos;
loff_t length = iomap_length(iter); loff_t length = iomap_length(iter);
long status = 0;
loff_t written = 0; loff_t written = 0;
/* don't bother with blocks that are not shared to start with */ /* don't bother with blocks that are not shared to start with */
...@@ -1274,28 +1273,33 @@ static loff_t iomap_unshare_iter(struct iomap_iter *iter) ...@@ -1274,28 +1273,33 @@ static loff_t iomap_unshare_iter(struct iomap_iter *iter)
return length; return length;
do { do {
unsigned long offset = offset_in_page(pos);
unsigned long bytes = min_t(loff_t, PAGE_SIZE - offset, length);
struct folio *folio; 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); status = iomap_write_begin(iter, pos, bytes, &folio);
if (unlikely(status)) if (unlikely(status))
return status; return status;
if (iter->iomap.flags & IOMAP_F_STALE) if (iomap->flags & IOMAP_F_STALE)
break; break;
status = iomap_write_end(iter, pos, bytes, bytes, folio); offset = offset_in_folio(folio, pos);
if (WARN_ON_ONCE(status == 0)) if (bytes > folio_size(folio) - offset)
bytes = folio_size(folio) - offset;
bytes = iomap_write_end(iter, pos, bytes, bytes, folio);
if (WARN_ON_ONCE(bytes == 0))
return -EIO; return -EIO;
cond_resched(); cond_resched();
pos += status; pos += bytes;
written += status; written += bytes;
length -= status; length -= bytes;
balance_dirty_pages_ratelimited(iter->inode->i_mapping); balance_dirty_pages_ratelimited(iter->inode->i_mapping);
} while (length); } while (length > 0);
return written; return written;
} }
......
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