changeset 306:5ea0b8b12aaf

tweak
author menikon
date Fri, 31 Jan 2020 18:48:54 +0900
parents a101eb88b1cd
children 4cf83e6ce534
files src/impl/fs_impl.cbc src/impl/fs_impl.h src/impl/fs_impl_private.cbc
diffstat 3 files changed, 26 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/impl/fs_impl.cbc	Fri Jan 31 17:51:39 2020 +0900
+++ b/src/impl/fs_impl.cbc	Fri Jan 31 18:48:54 2020 +0900
@@ -35,7 +35,8 @@
     fs->iupdate = C_iupdatefs_impl;
     fs->idup = C_idupfs_impl;
     fs->ilock = C_ilockfs_impl;
-    fs_impl->lockinode = C_lockinode;
+    fs_impl->lockinode1 = C_lockinode1;
+    fs_impl->lockinode_sleepcheck = C_lockinode_sleepcheck;
     fs->iunlock = C_iunlockfs_impl;
     fs->iput = C_iputfs_impl;
     fs->iunlockput = C_iunlockputfs_impl;
@@ -112,7 +113,7 @@
 
 __code ilockfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) {
 
-    goto lockinode(fs, ip, bp, dip, next(...));
+    goto lockinode1(fs, ip, bp, dip, next(...));
 }
 
 __code iunlockfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) {
--- a/src/impl/fs_impl.h	Fri Jan 31 17:51:39 2020 +0900
+++ b/src/impl/fs_impl.h	Fri Jan 31 18:48:54 2020 +0900
@@ -12,6 +12,7 @@
     __code allocinode_loop(struct fs_impl* fs_impl, int inum, uint dev, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(int iget_val, ...));
     __code allocinode_loopcheck(Type* fs_impl, int inum, uint dev, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(int iget_val, ...));
     __code allocinode_noloop(struct fs_impl* fs_impl, int inum, uint dev, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(int iget_val, ...));
-    __code lockinode(Type* fs_impl, struct inode *ip, struct buf *bp, struct dinode *dip, __code next(...));
+    __code lockinode1(Type* fs_impl, struct inode *ip, struct buf *bp, struct dinode *dip, __code next(...));
+    __code lockinode_sleepcheck(struct fs_impl* fs_impl, struct inode* ip, __code next(...));
     __code next(...);
 } fs_impl;
--- a/src/impl/fs_impl_private.cbc	Fri Jan 31 17:51:39 2020 +0900
+++ b/src/impl/fs_impl_private.cbc	Fri Jan 31 18:48:54 2020 +0900
@@ -99,6 +99,26 @@
 
 }
 
-__code lockinode(struct fs_impl* fs_impl, struct inode* ip, struct buf* bp, struct dinode* dip, __code next(...)){ //:skip
+__code lockinode1(struct fs_impl* fs_impl, struct inode* ip, struct buf* bp, struct dinode* dip, __code next(...)){ //:skip
+
+    if (ip == 0 || ip->ref < 1) {
+       
+    /*
+    panic("ilock");
+    goto panic();
+    */
+     }
+    acquire(&icache.lock);
+
+    goto lockinode_sleepcheck(fs_impl, ip, next(...));
+    
+}
+
+__code lockinode_sleepcheck(struct fs_impl* fs_impl, struct inode* ip, __code next(...)){
+    if(ip->flags & I_BUSY){
+        sleep(ip, &icache.lock);
+        goto lockinode_sleepcheck(fs_impl, ip, next(...));
+    }
     goto next(...);
 }
+