Skip to content

Commit e60837d

Browse files
Brian Fosterbrauner
authored andcommitted
iomap: advance the iter directly on unshare range
Modify unshare range to advance the iter directly. Replace the local pos and length calculations with direct advances and loop based on iter state instead. Signed-off-by: Brian Foster <bfoster@redhat.com> Link: https://lore.kernel.org/r/20250207143253.314068-10-bfoster@redhat.com Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 1a1a3b5 commit e60837d

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

fs/iomap/buffered-io.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,20 +1263,19 @@ EXPORT_SYMBOL_GPL(iomap_write_delalloc_release);
12631263
static loff_t iomap_unshare_iter(struct iomap_iter *iter)
12641264
{
12651265
struct iomap *iomap = &iter->iomap;
1266-
loff_t pos = iter->pos;
1267-
loff_t length = iomap_length(iter);
1268-
loff_t written = 0;
1266+
u64 bytes = iomap_length(iter);
1267+
int status;
12691268

12701269
if (!iomap_want_unshare_iter(iter))
1271-
return length;
1270+
return iomap_iter_advance(iter, &bytes);
12721271

12731272
do {
12741273
struct folio *folio;
1275-
int status;
12761274
size_t offset;
1277-
size_t bytes = min_t(u64, SIZE_MAX, length);
1275+
loff_t pos = iter->pos;
12781276
bool ret;
12791277

1278+
bytes = min_t(u64, SIZE_MAX, bytes);
12801279
status = iomap_write_begin(iter, pos, bytes, &folio);
12811280
if (unlikely(status))
12821281
return status;
@@ -1294,14 +1293,14 @@ static loff_t iomap_unshare_iter(struct iomap_iter *iter)
12941293

12951294
cond_resched();
12961295

1297-
pos += bytes;
1298-
written += bytes;
1299-
length -= bytes;
1300-
13011296
balance_dirty_pages_ratelimited(iter->inode->i_mapping);
1302-
} while (length > 0);
13031297

1304-
return written;
1298+
status = iomap_iter_advance(iter, &bytes);
1299+
if (status)
1300+
break;
1301+
} while (bytes > 0);
1302+
1303+
return status;
13051304
}
13061305

13071306
int

0 commit comments

Comments
 (0)