Skip to content

Commit e356c5d

Browse files
Brian Fosterbrauner
authored andcommitted
iomap: resample iter->pos after iomap_write_begin() calls
In preparation for removing the pos parameter, push the local pos assignment down after calls to iomap_write_begin(). Signed-off-by: Brian Foster <[email protected]> Link: https://lore.kernel.org/[email protected] Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 406331a commit e356c5d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

fs/iomap/buffered-io.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -920,11 +920,11 @@ static int iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)
920920
size_t bytes; /* Bytes to write to folio */
921921
size_t copied; /* Bytes copied from user */
922922
u64 written; /* Bytes have been written */
923-
loff_t pos = iter->pos;
923+
loff_t pos;
924924

925925
bytes = iov_iter_count(i);
926926
retry:
927-
offset = pos & (chunk - 1);
927+
offset = iter->pos & (chunk - 1);
928928
bytes = min(chunk - offset, bytes);
929929
status = balance_dirty_pages_ratelimited_flags(mapping,
930930
bdp_flags);
@@ -949,13 +949,14 @@ static int iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)
949949
break;
950950
}
951951

952-
status = iomap_write_begin(iter, pos, bytes, &folio);
952+
status = iomap_write_begin(iter, iter->pos, bytes, &folio);
953953
if (unlikely(status)) {
954-
iomap_write_failed(iter->inode, pos, bytes);
954+
iomap_write_failed(iter->inode, iter->pos, bytes);
955955
break;
956956
}
957957
if (iter->iomap.flags & IOMAP_F_STALE)
958958
break;
959+
pos = iter->pos;
959960

960961
offset = offset_in_folio(folio, pos);
961962
if (bytes > folio_size(folio) - offset)
@@ -1276,15 +1277,16 @@ static int iomap_unshare_iter(struct iomap_iter *iter)
12761277
do {
12771278
struct folio *folio;
12781279
size_t offset;
1279-
loff_t pos = iter->pos;
1280+
loff_t pos;
12801281
bool ret;
12811282

12821283
bytes = min_t(u64, SIZE_MAX, bytes);
1283-
status = iomap_write_begin(iter, pos, bytes, &folio);
1284+
status = iomap_write_begin(iter, iter->pos, bytes, &folio);
12841285
if (unlikely(status))
12851286
return status;
12861287
if (iomap->flags & IOMAP_F_STALE)
12871288
break;
1289+
pos = iter->pos;
12881290

12891291
offset = offset_in_folio(folio, pos);
12901292
if (bytes > folio_size(folio) - offset)
@@ -1351,15 +1353,16 @@ static int iomap_zero_iter(struct iomap_iter *iter, bool *did_zero)
13511353
do {
13521354
struct folio *folio;
13531355
size_t offset;
1354-
loff_t pos = iter->pos;
1356+
loff_t pos;
13551357
bool ret;
13561358

13571359
bytes = min_t(u64, SIZE_MAX, bytes);
1358-
status = iomap_write_begin(iter, pos, bytes, &folio);
1360+
status = iomap_write_begin(iter, iter->pos, bytes, &folio);
13591361
if (status)
13601362
return status;
13611363
if (iter->iomap.flags & IOMAP_F_STALE)
13621364
break;
1365+
pos = iter->pos;
13631366

13641367
/* warn about zeroing folios beyond eof that won't write back */
13651368
WARN_ON_ONCE(folio_pos(folio) > iter->inode->i_size);

0 commit comments

Comments
 (0)