Skip to content

Commit 3f59c75

Browse files
zhangyi089opsiff
authored andcommitted
iomap: do some small logical cleanup in buffered write
mainline inclusion from mainline-v6.10-rc1 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I9DN5Z CVE: NA -------------------------------- 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> (cherry picked from commit e1f453d) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent b0b2142 commit 3f59c75

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

fs/iomap/buffered-io.c

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

974974
if (old_size < pos)
975975
pagecache_isize_extended(iter->inode, old_size, pos);
976-
if (written < bytes)
977-
iomap_write_failed(iter->inode, pos + written,
978-
bytes - written);
979-
if (unlikely(copied != written))
980-
iov_iter_revert(i, copied - written);
981976

982977
cond_resched();
983978
if (unlikely(written == 0)) {
@@ -987,6 +982,9 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)
987982
* halfway through, might be a race with munmap,
988983
* might be severe memory pressure.
989984
*/
985+
iomap_write_failed(iter->inode, pos, bytes);
986+
iov_iter_revert(i, copied);
987+
990988
if (chunk > PAGE_SIZE)
991989
chunk /= 2;
992990
if (copied) {

0 commit comments

Comments
 (0)