⬢ DragonFlyBSD Kernel Audit
DF-2643 / harness.diff
← back to finding ↓ download raw
--- sys/vfs/hammer2/hammer2_strategy.c
+++ sys/vfs/hammer2/hammer2_strategy.c
@@ -56,6 +56,19 @@
 #include "hammer2_lz4.h"
 
 #include "zlib/hammer2_zlib.h"
+#include <sys/sysctl.h>
+
+SYSCTL_DECL(_vfs_hammer2);
+
+/*
+ * DF2643 HARNESS ONLY (never for upstream): runtime knob that forces the
+ * write xop into the state the admin.c:556-563 race can produce -- the
+ * inode cluster chain NULLing between xop_start and the xop thread run.
+ */
+static int hammer2_df2643_harness;
+SYSCTL_INT(_vfs_hammer2, OID_AUTO, df2643_harness, CTLFLAG_RW,
+	   &hammer2_df2643_harness, 0,
+	   "DF-2643 test rig: NULL parent in xop_strategy_write");
 
 struct objcache *cache_buffer_read;
 struct objcache *cache_buffer_write;
@@ -621,6 +634,11 @@
 	 * Actual operation
 	 */
 	parent = hammer2_inode_chain(ip, clindex, HAMMER2_RESOLVE_ALWAYS);
+	if (hammer2_df2643_harness && parent) {
+		hammer2_chain_unlock(parent);
+		hammer2_chain_drop(parent);
+		parent = NULL;	/* DF2643 HARNESS: simulate the race */
+	}
 	hammer2_write_file_core(bio_data, ip, &parent,
 				lbase, IO_ASYNC, pblksize,
 				xop->head.mtid, &error);