]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Mar 2023 13:54:10 +0000 (15:54 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Mar 2023 13:54:10 +0000 (15:54 +0200)
added patches:
ocfs2-fix-data-corruption-after-failed-write.patch

queue-4.19/ocfs2-fix-data-corruption-after-failed-write.patch [new file with mode: 0644]
queue-4.19/series

diff --git a/queue-4.19/ocfs2-fix-data-corruption-after-failed-write.patch b/queue-4.19/ocfs2-fix-data-corruption-after-failed-write.patch
new file mode 100644 (file)
index 0000000..f940bb4
--- /dev/null
@@ -0,0 +1,67 @@
+From 90410bcf873cf05f54a32183afff0161f44f9715 Mon Sep 17 00:00:00 2001
+From: Jan Kara via Ocfs2-devel <ocfs2-devel@oss.oracle.com>
+Date: Thu, 2 Mar 2023 16:38:43 +0100
+Subject: ocfs2: fix data corruption after failed write
+
+From: Jan Kara via Ocfs2-devel <ocfs2-devel@oss.oracle.com>
+
+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.
+
+Link: https://lkml.kernel.org/r/20230302153843.18499-1-jack@suse.cz
+Fixes: 6dbf7bb55598 ("fs: Don't invalidate page buffers in block_write_full_page()")
+Signed-off-by: Jan Kara <jack@suse.cz>
+Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
+Cc: Mark Fasheh <mark@fasheh.com>
+Cc: Joel Becker <jlbec@evilplan.org>
+Cc: Junxiao Bi <junxiao.bi@oracle.com>
+Cc: Changwei Ge <gechangwei@live.cn>
+Cc: Gang He <ghe@suse.com>
+Cc: Jun Piao <piaojun@huawei.com>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+[ replace block_invalidate_folio to block_invalidatepage ]
+Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/ocfs2/aops.c |   18 ++++++++++++++++--
+ 1 file changed, 16 insertions(+), 2 deletions(-)
+
+--- a/fs/ocfs2/aops.c
++++ b/fs/ocfs2/aops.c
+@@ -2003,11 +2003,25 @@ 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_invalidatepage(wc->w_target_page, 0, PAGE_SIZE);
++              }
+       }
+       if (wc->w_target_page)
+               flush_dcache_page(wc->w_target_page);
index 2de953beee58f05edf565add72471729f2c5b335..09f40ad501f890d35a9add4157c9bf18dd4d2e7d 100644 (file)
@@ -47,3 +47,4 @@ dm-crypt-add-cond_resched-to-dmcrypt_write.patch
 sched-fair-sanitize-vruntime-of-entity-being-placed.patch
 sched-fair-sanitize-vruntime-of-entity-being-migrated.patch
 tun-avoid-double-free-in-tun_free_netdev.patch
+ocfs2-fix-data-corruption-after-failed-write.patch