shithub: gefs

Download patch

ref: 2f90299a01a9da436855041e69df7e15b83bb411
parent: f422794136d1b252998b0a31b6856de2717d7386
author: Ori Bernstein <[email protected]>
date: Wed Oct 4 10:34:35 EDT 2023

cache: fix lock ordering issue

--- a/cache.c
+++ b/cache.c
@@ -137,18 +137,18 @@
 
 	bkt = &fs->bcache[h % fs->cmax];
 
+	qlock(&fs->lrulk);
 	lock(bkt);
 	for(b = bkt->b; b != nil; b = b->hnext){
 		if(b->bp.addr == off){
  			holdblk(b);
-			qlock(&fs->lrulk);
 			lrudel(b);
-			qunlock(&fs->lrulk);
 			b->lasthold = getcallerpc(&off);
 			break;
 		}
 	}
 	unlock(bkt);
+	qunlock(&fs->lrulk);
 
 	return b;
 }