diff options
author | Mole Shang <[email protected]> | 2024-02-16 10:20:27 +0800 |
---|---|---|
committer | Mole Shang <[email protected]> | 2024-02-16 10:20:27 +0800 |
commit | a98c56a811142e5ede3332a7a444cca45f628769 (patch) | |
tree | c93ff7090da7b6ef911932be283818c2f6a03784 /kernel/fs.c | |
parent | 0d65be5d1d880afafbf08c2adb605cf9f72216e2 (diff) | |
parent | 99015f3a985b2fd051606636743a2a2969b216e8 (diff) | |
download | xv6-labs-a98c56a811142e5ede3332a7a444cca45f628769.tar.gz xv6-labs-a98c56a811142e5ede3332a7a444cca45f628769.tar.bz2 xv6-labs-a98c56a811142e5ede3332a7a444cca45f628769.zip |
Merge branch 'lock' into thread
Conflicts:
.gitignore
Makefile
conf/lab.mk
Diffstat (limited to 'kernel/fs.c')
-rw-r--r-- | kernel/fs.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/kernel/fs.c b/kernel/fs.c index c6bab15..6c4079e 100644 --- a/kernel/fs.c +++ b/kernel/fs.c @@ -295,11 +295,11 @@ ilock(struct inode *ip) struct buf *bp; struct dinode *dip; - if(ip == 0 || ip->ref < 1) + if(ip == 0 || atomic_read4(&ip->ref) < 1) panic("ilock"); acquiresleep(&ip->lock); - + if(ip->valid == 0){ bp = bread(ip->dev, IBLOCK(ip->inum, sb)); dip = (struct dinode*)bp->data + ip->inum%IPB; @@ -320,7 +320,7 @@ ilock(struct inode *ip) void iunlock(struct inode *ip) { - if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) + if(ip == 0 || !holdingsleep(&ip->lock) || atomic_read4(&ip->ref) < 1) panic("iunlock"); releasesleep(&ip->lock); @@ -416,7 +416,6 @@ bmap(struct inode *ip, uint bn) brelse(bp); return addr; } - panic("bmap: out of range"); } @@ -447,7 +446,7 @@ itrunc(struct inode *ip) bfree(ip->dev, ip->addrs[NDIRECT]); ip->addrs[NDIRECT] = 0; } - + ip->size = 0; iupdate(ip); } |