Mercurial > hg > Members > menikon > CbC_xv6
changeset 244:a101eb88b1cd
~add lockinode CodeGear
author | menikon |
---|---|
date | Fri, 31 Jan 2020 17:51:39 +0900 |
parents | c5c4f9e233ad |
children | 5ea0b8b12aaf |
files | src/impl/fs_impl.cbc src/impl/fs_impl.h src/impl/fs_impl_private.cbc |
diffstat | 3 files changed, 30 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/impl/fs_impl.cbc Fri Jan 31 16:36:15 2020 +0900 +++ b/src/impl/fs_impl.cbc Fri Jan 31 17:51:39 2020 +0900 @@ -35,6 +35,7 @@ fs->iupdate = C_iupdatefs_impl; fs->idup = C_idupfs_impl; fs->ilock = C_ilockfs_impl; + fs_impl->lockinode = C_lockinode; fs->iunlock = C_iunlockfs_impl; fs->iput = C_iputfs_impl; fs->iunlockput = C_iunlockputfs_impl; @@ -74,22 +75,44 @@ } __code iallocfs_impl(struct fs_impl* fs, uint dev, short type, __code next(...)) { - goto allocinode(fs, dev, type, next(...)); + goto allocinode(fs, dev, sb, next(...)); } __code iupdatefs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) { + struct buf *bp; + struct dinode *dip; + + bp = bread(ip->dev, IBLOCK(ip->inum)); + + dip = (struct dinode*) bp->data + ip->inum % IPB; + dip->type = ip->type; + dip->major = ip->major; + dip->minor = ip->minor; + dip->nlink = ip->nlink; + dip->size = ip->size; + + memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); + log_write(bp); + brelse(bp); + + goto next(...); } __code idupfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) { - goto next(...); + acquire(&icache.lock); + ip->ref++; + release(&icache.lock); + + goto next(ip, ...); + } __code ilockfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) { - goto next(...); + goto lockinode(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 16:36:15 2020 +0900 +++ b/src/impl/fs_impl.h Fri Jan 31 17:51:39 2020 +0900 @@ -12,5 +12,6 @@ __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 next(...); } fs_impl;