Patch "ocfs2: fix data corruption after failed write" has been added to the 6.1-stable tree
gregkh--- via Ocfs2-devel
AppliedThis is a note to let you know that I've just added the patch titled
ocfs2: fix data corruption after failed write
to the 6.1-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:
ocfs2-fix-data-corruption-after-failed-write.patch
and it can be found in the queue-6.1 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
From 90410bcf873cf05f54a32183afff0161f44f9715 Mon Sep 17 00:00:00 2001
From: Jan Kara via Ocfs2-devel <[email protected]>
Date: Thu, 2 Mar 2023 16:38:43 +0100
Subject: ocfs2: fix data corruption after failed write
From: Jan Kara via Ocfs2-devel <[email protected]>
commit 90410bcf873cf05f54a32183afff0161f44f9715 upstream.
When buffered write fails to copy data into underlying page cache page, ocfs2_write_end_nolock() just zeroes out and dirties the page. This can leave dirty page beyond EOF and if page writeback tries to write this page before write succeeds and expands i_size, page gets into inconsistent state where page dirty bit is clear but buffer dirty bits stay set resulting in page data never getting written and so data copied to the page is lost. Fix the problem by invalidating page beyond EOF after failed write.
--- fs/ocfs2/aops.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
fs/ocfs2/aops.c +17 -2
@@ -1977,11 +1977,26 @@ int ocfs2_write_end_nolock(struct addres }if (unlikely (copied < len) && wc->w_target_page) { +loff_t new_isize; +if (!PageUptodate (wc->w_target_page)) copied =0 ; -ocfs2_zero_new_buffers (wc->w_target_page, start+copied, - start+len); + new_isize =max_t (loff_t,i_size_read (inode), pos + copied); +if (new_isize >page_offset (wc->w_target_page)) +ocfs2_zero_new_buffers (wc->w_target_page, start+copied, + start+len); +else { +/* +* When page is fully beyond new isize (data copy +* failed), do not bother zeroing the page. Invalidate +* it instead so that writeback does not get confused +* put page & buffer dirty bits into inconsistent +* state. +*/ +block_invalidate_folio (page_folio (wc->w_target_page), +0 ,PAGE_SIZE ); + } }if (wc->w_target_page)flush_dcache_page (wc->w_target_page);
Patches currently in stable-queue which might be from [email protected] are
queue-6.1/ocfs2-fix-data-corruption-after-failed-write.patch
_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel