linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: Fix mmap write protection for data=journal mode
@ 2020-10-27 13:27 Jan Kara
  2020-10-27 16:10 ` Mauricio Faria de Oliveira
  2020-10-28  3:56 ` Theodore Y. Ts'o
  0 siblings, 2 replies; 8+ messages in thread
From: Jan Kara @ 2020-10-27 13:27 UTC (permalink / raw)
  To: Ted Tso; +Cc: linux-ext4, Mauricio Faria de Oliveira, Jan Kara

Commit afb585a97f81 "ext4: data=journal: write-protect pages on
j_submit_inode_data_buffers()") added calls ext4_jbd2_inode_add_write()
to track inode ranges whose mappings need to get write-protected during
transaction commits. However the added calls use wrong start of a range
(0 instead of page offset) and so write protection is not necessarily
effective. Use correct range start to fix the problem.

Fixes: afb585a97f81 ("ext4: data=journal: write-protect pages on j_submit_inode_data_buffers()")
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/inode.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Mauricio, I think this could be the reason for occasional test failures you
were still seeing. Can you try whether this patch fixes those for you? Thanks!

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 03c2253005f0..f4a599c6dcde 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1918,7 +1918,7 @@ static int __ext4_journalled_writepage(struct page *page,
 	}
 	if (ret == 0)
 		ret = err;
-	err = ext4_jbd2_inode_add_write(handle, inode, 0, len);
+	err = ext4_jbd2_inode_add_write(handle, inode, page_offset(page), len);
 	if (ret == 0)
 		ret = err;
 	EXT4_I(inode)->i_datasync_tid = handle->h_transaction->t_tid;
@@ -6157,7 +6157,8 @@ vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf)
 			if (ext4_walk_page_buffers(handle, page_buffers(page),
 					0, len, NULL, write_end_fn))
 				goto out_error;
-			if (ext4_jbd2_inode_add_write(handle, inode, 0, len))
+			if (ext4_jbd2_inode_add_write(handle, inode,
+						      page_offset(page), len))
 				goto out_error;
 			ext4_set_inode_state(inode, EXT4_STATE_JDATA);
 		} else {
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-11-24  0:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-27 13:27 [PATCH] ext4: Fix mmap write protection for data=journal mode Jan Kara
2020-10-27 16:10 ` Mauricio Faria de Oliveira
2020-11-20 15:27   ` Mauricio Faria de Oliveira
2020-11-20 18:10     ` Theodore Y. Ts'o
2020-11-23 23:52       ` Mauricio Faria de Oliveira
2020-11-23  9:34     ` Jan Kara
2020-11-24  0:03       ` Mauricio Faria de Oliveira
2020-10-28  3:56 ` Theodore Y. Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).