svn commit: r328046 - stable/11/sys/ufs/ffs

Konstantin Belousov kib at FreeBSD.org
Tue Jan 16 10:56:37 UTC 2018


Author: kib
Date: Tue Jan 16 10:56:35 2018
New Revision: 328046
URL: https://svnweb.freebsd.org/changeset/base/328046

Log:
  MFC r327722:
  When handling write completion, take SU lock around calls to
  handle_written_XXX() in case of processing the buffer with an error.

Modified:
  stable/11/sys/ufs/ffs/ffs_softdep.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/ufs/ffs/ffs_softdep.c
==============================================================================
--- stable/11/sys/ufs/ffs/ffs_softdep.c	Tue Jan 16 10:54:32 2018	(r328045)
+++ stable/11/sys/ufs/ffs/ffs_softdep.c	Tue Jan 16 10:56:35 2018	(r328046)
@@ -10974,12 +10974,17 @@ softdep_disk_write_complete(bp)
 	struct freeblks *freeblks;
 	struct buf *sbp;
 
+	if ((wk = LIST_FIRST(&bp->b_dep)) == NULL)
+		return;
+	ump = VFSTOUFS(wk->wk_mp);
+
 	/*
 	 * If an error occurred while doing the write, then the data
 	 * has not hit the disk and the dependencies cannot be processed.
 	 * But we do have to go through and roll forward any dependencies
 	 * that were rolled back before the disk write.
 	 */
+	ACQUIRE_LOCK(ump);
 	if ((bp->b_ioflags & BIO_ERROR) != 0 && (bp->b_flags & B_INVAL) == 0) {
 		LIST_FOREACH(wk, &bp->b_dep, wk_list) {
 			switch (wk->wk_type) {
@@ -11007,18 +11012,15 @@ softdep_disk_write_complete(bp)
 				continue;
 			}
 		}
+		FREE_LOCK(ump);
 		return;
 	}
-	if ((wk = LIST_FIRST(&bp->b_dep)) == NULL)
-		return;
-	ump = VFSTOUFS(wk->wk_mp);
 	LIST_INIT(&reattach);
 	/*
 	 * This lock must not be released anywhere in this code segment.
 	 */
 	sbp = NULL;
 	owk = NULL;
-	ACQUIRE_LOCK(ump);
 	while ((wk = LIST_FIRST(&bp->b_dep)) != NULL) {
 		WORKLIST_REMOVE(wk);
 		atomic_add_long(&dep_write[wk->wk_type], 1);


More information about the svn-src-all mailing list