shithub: ext4srv

Download patch

ref: ed195283a7de1e8d0cfdf8fcc5aeb73a253f6ca7
parent: 053f9415a345a438773817534e80704a6b372355
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Nov 15 12:34:22 EST 2020

closeallparts: lock properly

--- a/part.c
+++ b/part.c
@@ -344,12 +344,11 @@
 	return nil;
 }
 
-void
-closepart(Part *p)
+static void
+_closepart(Part *p)
 {
 	int r;
 
-	qlock(&sv);
 	ext4_cache_write_back(p->mnt, 0);
 	if((r = ext4_journal_stop(p->mnt)) != 0 && r != ENOTSUP)
 		fprint(2, "closepart: journal %s: %s\n", p->mnt, errno2s(r));
@@ -366,6 +365,13 @@
 		sv.ps = p->next;
 	freegroups(&p->groups);
 	free(p);
+}
+
+void
+closepart(Part *p)
+{
+	qlock(&sv);
+	_closepart(p);
 	qunlock(&sv);
 }
 
@@ -372,6 +378,8 @@
 void
 closeallparts(void)
 {
+	qlock(&sv);
 	while(sv.ps != nil)
-		closepart(sv.ps);
+		_closepart(sv.ps);
+	qunlock(&sv);
 }