]> Devi Nivas Git - cs3210-lab1.git/commitdiff
frans' fixes to iput()
authorRobert Morris <rtm@csail.mit.edu>
Tue, 8 Aug 2017 17:26:57 +0000 (13:26 -0400)
committerRobert Morris <rtm@csail.mit.edu>
Tue, 8 Aug 2017 17:26:57 +0000 (13:26 -0400)
fs.c

diff --git a/fs.c b/fs.c
index a0634e485eb32b10a361a40e940ab3e78e66d53d..4232f6a474548767e811cda4f86bcc21f2893251 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -322,12 +322,14 @@ iput(struct inode *ip)
   acquire(&icache.lock);
   if(ip->ref == 1 && (ip->flags & I_VALID) && ip->nlink == 0){
     // inode has no links and no other references: truncate and free.
+    acquiresleep(&ip->lock);
     release(&icache.lock);
     itrunc(ip);
     ip->type = 0;
     iupdate(ip);
     acquire(&icache.lock);
     ip->flags = 0;
+    releasesleep(&ip->lock);
   }
   ip->ref--;
   release(&icache.lock);