Skip to content

Commit e1f453d

Browse files
zhangyi089brauner
authored andcommitted
iomap: do some small logical cleanup in buffered write
Since iomap_write_end() can never return a partial write length, the comparison between written, copied and bytes becomes useless, just merge them with the unwritten branch. Signed-off-by: Zhang Yi <yi.zhang@huawei.com> Link: https://lore.kernel.org/r/20240320110548.2200662-10-yi.zhang@huaweicloud.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 815f4b6 commit e1f453d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

fs/iomap/buffered-io.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -975,11 +975,6 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)
975975

976976
if (old_size < pos)
977977
pagecache_isize_extended(iter->inode, old_size, pos);
978-
if (written < bytes)
979-
iomap_write_failed(iter->inode, pos + written,
980-
bytes - written);
981-
if (unlikely(copied != written))
982-
iov_iter_revert(i, copied - written);
983978

984979
cond_resched();
985980
if (unlikely(written == 0)) {
@@ -989,6 +984,9 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)
989984
* halfway through, might be a race with munmap,
990985
* might be severe memory pressure.
991986
*/
987+
iomap_write_failed(iter->inode, pos, bytes);
988+
iov_iter_revert(i, copied);
989+
992990
if (chunk > PAGE_SIZE)
993991
chunk /= 2;
994992
if (copied) {

0 commit comments

Comments
 (0)