Skip to content

Commit

Permalink
iomap: do some small logical cleanup in buffered write
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Zhang Yi authored and Christian Brauner committed Apr 25, 2024
1 parent 815f4b6 commit e1f453d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions fs/iomap/buffered-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -975,11 +975,6 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)

if (old_size < pos)
pagecache_isize_extended(iter->inode, old_size, pos);
if (written < bytes)
iomap_write_failed(iter->inode, pos + written,
bytes - written);
if (unlikely(copied != written))
iov_iter_revert(i, copied - written);

cond_resched();
if (unlikely(written == 0)) {
Expand All @@ -989,6 +984,9 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)
* halfway through, might be a race with munmap,
* might be severe memory pressure.
*/
iomap_write_failed(iter->inode, pos, bytes);
iov_iter_revert(i, copied);

if (chunk > PAGE_SIZE)
chunk /= 2;
if (copied) {
Expand Down

0 comments on commit e1f453d

Please sign in to comment.