[PATCH 5/8] reiserfs: Convert do_journal_end() to use kmap_local_folio()

"Matthew Wilcox (Oracle)" <[email protected]>
Newsgroups gmane.linux.file-systems,gmane.comp.file-systems.reiserfs.general
Message-ID <[email protected]>
Remove uses of kmap() and b_page.  Also move the set_buffer_uptodate()
call to after the memcpy() so that the memory barrier in
set_buffer_uptodate() actually ensures that the old data can't be visible.

Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
---
 fs/reiserfs/journal.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index 9ce4ec296b74..faf2f09d82e1 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -4200,21 +4200,19 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, int flags)
 		/* copy all the real blocks into log area.  dirty log blocks */
 		if (buffer_journaled(cn->bh)) {
 			struct buffer_head *tmp_bh;
+			size_t offset = offset_in_folio(cn->bh->b_folio,
+							cn->bh->b_data);
 			char *addr;
-			struct page *page;
 			tmp_bh =
 			    journal_getblk(sb,
 					   SB_ONDISK_JOURNAL_1st_BLOCK(sb) +
 					   ((cur_write_start +
 					     jindex) %
 					    SB_ONDISK_JOURNAL_SIZE(sb)));
+			addr = kmap_local_folio(cn->bh->b_folio, offset);
+			memcpy(tmp_bh->b_data, addr, cn->bh->b_size);
+			kunmap_local(addr);
 			set_buffer_uptodate(tmp_bh);
-			page = cn->bh->b_page;
-			addr = kmap(page);
-			memcpy(tmp_bh->b_data,
-			       addr + offset_in_page(cn->bh->b_data),
-			       cn->bh->b_size);
-			kunmap(page);
 			mark_buffer_dirty(tmp_bh);
 			jindex++;
 			set_buffer_journal_dirty(cn->bh);
-- 
2.35.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.