[RFC PATCH 08/11] ext4: data=journal: prevent journalled writeback deadlock in ext4_convert_inline_data_to_extent()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch checks for and prevents the deadlock with a page in
journalled writeback in ext4_convert_inline_data_to_extent().

Finally, add wait_on_page_writeback() if data=journal mode.

Note: similar changes are not needed in ext4_da_convert_inline_data_to_extent()
as delayed allocation is not applicable to data journalling
(different struct address_space_operations).

Signed-off-by: Mauricio Faria de Oliveira <mfo@xxxxxxxxxxxxx>
---
 fs/ext4/inline.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 5fd275098d10..10665b066bb7 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -562,6 +562,8 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
 		handle = NULL;
 		goto out;
 	}
+	if (ext4_should_journal_data(inode))
+		wait_on_page_writeback(page);
 	unlock_page(page);
 
 retry_journal:
@@ -581,9 +583,19 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
 		put_page(page);
 		ext4_journal_stop(handle);
 		goto retry_grab;
+	} else if (ext4_should_journal_data(inode) &&
+		   ext4_check_journalled_writeback(handle, page)) {
+		/* Or transaction may block page writeback */
+		unlock_page(page);
+		put_page(page);
+		ext4_journal_stop(handle);
+		ext4_start_commit_datasync(inode);
+		goto retry_grab;
 	}
 	/* In case writeback began while the page was unlocked */
 	wait_for_stable_page(page);
+	if (ext4_should_journal_data(inode))
+		wait_on_page_writeback(page);
 
 	ext4_write_lock_xattr(inode, &no_expand);
 	sem_held = 1;
-- 
2.20.1




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux