Skip to contentSkip to conversation

reiser4: prevent system lockups

PATCH New Edward Shishkin 1 participant 1 message Feb 5, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 reiser4: prevent system lockups

Hi all,

Starting from Linux-4.15, VFS introduces optimizations, which are incompatible with Reiser4 (as well as with any FS possessing an advanced transaction manager). Here is the problematic commit:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=aa65c29ce1b6e1990cd2c7d8004bbea7ff3aff38

The attached patch fixes the problem. This patch is against Linux-5.4+reiser4. Please, apply.

Later I'll prepare backports for all the mentioned kernels and will put them on Sourceforge. If someone urgently needs a backport, then let me know.

Thanks,
Edward.

fs/reiser4/page_cache.c +2 -1
diff -urN linux-5.4.6/fs/reiser4/page_cache.c linux-5.4.6.patched/fs/reiser4/page_cache.c
@@ -549,7 +549,8 @@
 	 */
 	.releasepage = reiser4_releasepage,
 	.direct_IO = NULL,
-	.migratepage = reiser4_migratepage
+	.migratepage = reiser4_migratepage,
+	.batch_lock_tabu = 1
 };
 
 /* called just before page is released (no longer used by reiser4). Callers:
fs/reiser4/plugin/object.c +2 -1
diff -urN linux-5.4.6/fs/reiser4/plugin/object.c linux-5.4.6.patched/fs/reiser4/plugin/object.c
@@ -150,7 +150,8 @@
 	.bmap = reiser4_bmap_dispatch,
 	.invalidatepage = reiser4_invalidatepage,
 	.releasepage = reiser4_releasepage,
-	.migratepage = reiser4_migratepage
+	.migratepage = reiser4_migratepage,
+	.batch_lock_tabu = 1
 };
 
 /* VFS methods for symlink files */
include/linux/fs.h +1 -0
diff -urN linux-5.4.6/include/linux/fs.h linux-5.4.6.patched/include/linux/fs.h
@@ -409,6 +409,7 @@
 	int (*swap_activate)(struct swap_info_struct *sis, struct file *file,
 				sector_t *span);
 	void (*swap_deactivate)(struct file *file);
+	int batch_lock_tabu;
 };
 
 extern const struct address_space_operations empty_aops;
mm/truncate.c +7 -0
diff -urN linux-5.4.6/mm/truncate.c linux-5.4.6.patched/mm/truncate.c
@@ -360,6 +360,13 @@
 				continue;
 			}
 			pagevec_add(&locked_pvec, page);
+			if (mapping->a_ops->batch_lock_tabu)
+				/*
+				 * the file system doesn't allow to hold
+				 * many pages locked, while calling
+				 * ->invalidatepage() for one of them
+				 */
+				break;
 		}
 		for (i = 0; i < pagevec_count(&locked_pvec); i++)
 			truncate_cleanup_page(mapping, locked_pvec.pages[i]);