iomap: always return status from iomap_write_iter
Subsystems (2)
PATCH 1/1 iomap: always return status from iomap_write_iter
iomap_write_iter() returns either an error code or 0 if partial progress has been made. The error sanitization was required in the past because the return value was used by iomap_iter() to determine how much progress was made, and thus what to pass to ->iomap_end() and how much to advance the iter.
Now that iter handlers advance the iter incrementally and progress is separate from return status, this is no longer needed. iomap_iter() infers partial progress directly from the iter state and similarly, iomap_file_buffered_write() uses iter.pos to determine whether to return a short write or an error code.
This also eliminates a minor quirk in the write iteration where if an error interrupts a partial write, we'd have to loop back into iomap_write_iter() once more and run into the error a second time before iomap terminates the operation and returns the error. With the error code returned directly and separate from write progress, we can complete the operation and return from iomap_iter() immediately.
--- fs/iomap/buffered-io.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/iomap/buffered-io.c +1 -3
@@ -1156,7 +1156,6 @@ static bool iomap_write_end(struct iomap_iter *iter, size_t len, size_t copied,static int iomap_write_iter (struct iomap_iter *iter,struct iov_iter *i,const struct iomap_write_ops *write_ops) { -ssize_t total_written =0 ;int status =0 ;struct address_space *mapping = iter->inode->i_mapping;size_t chunk =mapping_max_folio_size (mapping);
@@ -1252,12 +1251,11 @@ static int iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i, goto retry; } }else { - total_written += written;iomap_iter_advance (iter, written); } }while (iov_iter_count (i) &&iomap_length (iter)); -return total_written ?0 : status; +return status; }ssize_t
Signature · 1 line
2.54.0
Quoted 12 lines · Brian Foster
iomap_write_iter()returns either an error code or 0 if partial progress has been made. The error sanitization was required in the past because the return value was used byiomap_iter()to determine how much progress was made, and thus what to pass to ->iomap_end() and how much to advance the iter.Now that iter handlers advance the iter incrementally and progress is separate from return status, this is no longer needed.
iomap_iter()infers partial progress directly from the iter state and similarly,iomap_file_buffered_write()uses iter.pos to determine whether to return a short write or an error code.
Quoted 7 lines
This also eliminates a minor quirk in the write iteration where if an error interrupts a partial write, we'd have to loop back into
iomap_write_iter()once more and run into the error a second time before iomap terminates the operation and returns the error. With the error code returned directly and separate from write progress, we can complete the operation and return fromiomap_iter()immediately.
Looks good:
Quoted 1 line · Brian Foster
iomap: always return status from
iomap_write_iter
Applied to the vfs-7.3.misc branch of the vfs/vfs.git tree. Patches in the vfs-7.3.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs-7.3.misc
[1/1] iomap: always return status from iomap_write_iter
https://git.kernel.org/vfs/vfs/c/39987163d6dc