Skip to content

Commit a5f31a5

Browse files
author
Darrick J. Wong
committed
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: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
1 parent 35d30c9 commit a5f31a5

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

fs/iomap/buffered-io.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,6 @@ static loff_t iomap_unshare_iter(struct iomap_iter *iter)
12631263
const struct iomap *srcmap = iomap_iter_srcmap(iter);
12641264
loff_t pos = iter->pos;
12651265
loff_t length = iomap_length(iter);
1266-
long status = 0;
12671266
loff_t written = 0;
12681267

12691268
/* 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)
12741273
return length;
12751274

12761275
do {
1277-
unsigned long offset = offset_in_page(pos);
1278-
unsigned long bytes = min_t(loff_t, PAGE_SIZE - offset, length);
12791276
struct folio *folio;
1277+
int status;
1278+
size_t offset;
1279+
size_t bytes = min_t(u64, SIZE_MAX, length);
12801280

12811281
status = iomap_write_begin(iter, pos, bytes, &folio);
12821282
if (unlikely(status))
12831283
return status;
1284-
if (iter->iomap.flags & IOMAP_F_STALE)
1284+
if (iomap->flags & IOMAP_F_STALE)
12851285
break;
12861286

1287-
status = iomap_write_end(iter, pos, bytes, bytes, folio);
1288-
if (WARN_ON_ONCE(status == 0))
1287+
offset = offset_in_folio(folio, pos);
1288+
if (bytes > folio_size(folio) - offset)
1289+
bytes = folio_size(folio) - offset;
1290+
1291+
bytes = iomap_write_end(iter, pos, bytes, bytes, folio);
1292+
if (WARN_ON_ONCE(bytes == 0))
12891293
return -EIO;
12901294

12911295
cond_resched();
12921296

1293-
pos += status;
1294-
written += status;
1295-
length -= status;
1297+
pos += bytes;
1298+
written += bytes;
1299+
length -= bytes;
12961300

12971301
balance_dirty_pages_ratelimited(iter->inode->i_mapping);
1298-
} while (length);
1302+
} while (length > 0);
12991303

13001304
return written;
13011305
}

0 commit comments

Comments
 (0)