Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 961cecbe authored by Sunil Mushran's avatar Sunil Mushran Committed by Mark Fasheh
Browse files

[PATCH] ocfs2: Fix oops when racing files truncates with writes into an mmap region



This patch fixes an oops that is reproduced when one races writes to a mmap-ed
region with another process truncating the file.

Signed-off-by: default avatarSunil Mushran <sunil.mushran@oracle.com>
Signed-off-by: default avatarMark Fasheh <mfasheh@suse.com>
parent 539d8264
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -1073,14 +1073,17 @@ static void ocfs2_write_failure(struct inode *inode,
	for(i = 0; i < wc->w_num_pages; i++) {
		tmppage = wc->w_pages[i];

		if (page_has_buffers(tmppage)) {
			if (ocfs2_should_order_data(inode))
			walk_page_buffers(wc->w_handle, page_buffers(tmppage),
				walk_page_buffers(wc->w_handle,
						  page_buffers(tmppage),
						  from, to, NULL,
						  ocfs2_journal_dirty_data);

			block_commit_write(tmppage, from, to);
		}
	}
}

static int ocfs2_prepare_page_for_write(struct inode *inode, u64 *p_blkno,
					struct ocfs2_write_ctxt *wc,
@@ -1901,13 +1904,15 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
			to = PAGE_CACHE_SIZE;
		}

		if (page_has_buffers(tmppage)) {
			if (ocfs2_should_order_data(inode))
			walk_page_buffers(wc->w_handle, page_buffers(tmppage),
				walk_page_buffers(wc->w_handle,
						  page_buffers(tmppage),
						  from, to, NULL,
						  ocfs2_journal_dirty_data);

			block_commit_write(tmppage, from, to);
		}
	}

out_write_size:
	pos += copied;