Patch "direct_write_fallback(): on error revert the ->ki_pos update from buffered write" has been added to the 6.5-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    direct_write_fallback(): on error revert the ->ki_pos update from buffered write

to the 6.5-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     direct_write_fallback-on-error-revert-the-ki_pos-upd.patch
and it can be found in the queue-6.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit b252b947a1390f83081e6afc6277f91fb404dc80
Author: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
Date:   Wed Sep 13 18:28:15 2023 +0200

    direct_write_fallback(): on error revert the ->ki_pos update from buffered write
    
    [ Upstream commit 8287474aa5ffb41df52552c4ae4748e791d2faf2 ]
    
    If we fail filemap_write_and_wait_range() on the range the buffered write went
    into, we only report the "number of bytes which we direct-written", to quote
    the comment in there.  Which is fine, but buffered write has already advanced
    iocb->ki_pos, so we need to roll that back.  Otherwise we end up with e.g.
    write(2) advancing position by more than the amount it reports having written.
    
    Fixes: 182c25e9c157 "filemap: update ki_pos in generic_perform_write"
    Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
    Message-Id: <20230827214518.GU3390869@ZenIV>
    Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/libfs.c b/fs/libfs.c
index 5b851315eeed0..712c57828c0e4 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -1646,6 +1646,7 @@ ssize_t direct_write_fallback(struct kiocb *iocb, struct iov_iter *iter,
 		 * We don't know how much we wrote, so just return the number of
 		 * bytes which were direct-written
 		 */
+		iocb->ki_pos -= buffered_written;
 		if (direct_written)
 			return direct_written;
 		return err;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux