From d50326c7c15fb1e2e90d3c1524a4fd2d9c7cbd7e Mon Sep 17 00:00:00 2001 From: Nickolai Zeldovich Date: Sat, 14 Apr 2001 18:34:32 +0000 Subject: [PATCH] solaris-ufs-call-updates-20010414 updates per message from Frank Batschulat regarding problems with how afs hooked the solaris ufs code --- src/afs/SOLARIS/osi_file.c | 4 +++ src/afs/SOLARIS/osi_inode.c | 61 +++++++++++++++++++++++++++++------- src/afs/SOLARIS/osi_vfsops.c | 6 ++-- 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/src/afs/SOLARIS/osi_file.c b/src/afs/SOLARIS/osi_file.c index fd9d1248f..0366f6f4b 100644 --- a/src/afs/SOLARIS/osi_file.c +++ b/src/afs/SOLARIS/osi_file.c @@ -263,7 +263,11 @@ struct vnode *avp; { if (afs_CacheFSType == AFS_SUN_UFS_CACHE) { struct inode *ip = VTOI(avp); + rw_enter(&ip->i_contents, RW_READER); + mutex_enter(&ip->i_tlock); ip->i_flag &= ~IACC; + mutex_exit(&ip->i_tlock); + rw_exit(&ip->i_contents); } } diff --git a/src/afs/SOLARIS/osi_inode.c b/src/afs/SOLARIS/osi_inode.c index 42bdc89dc..42ecb7f8c 100644 --- a/src/afs/SOLARIS/osi_inode.c +++ b/src/afs/SOLARIS/osi_inode.c @@ -19,7 +19,14 @@ #include "../afs/osi_inode.h" #include "../afs/afs_stats.h" /* statistics stuff */ -extern int (*ufs_iputp)(), (*ufs_iallocp)(), (*ufs_iupdatp)(), (*ufs_igetp)(); +extern int (*ufs_iallocp)(), (*ufs_iupdatp)(), (*ufs_igetp)(), + (*ufs_itimes_nolockp)(); + +#define AFS_ITIMES(ip) { \ + mutex_enter(&(ip)->i_tlock); \ + (*ufs_itimes_nolockp)(ip); \ + mutex_exit(&(ip)->i_tlock); \ +} getinode(vfsp, dev, inode, ipp, credp,perror) struct vfs *vfsp; @@ -34,6 +41,7 @@ getinode(vfsp, dev, inode, ipp, credp,perror) struct vnode *vp; struct fs *fs; struct inode *pip; + struct ufsvfs *ufsvfsp; AFS_STATCNT(getinode); @@ -48,7 +56,13 @@ getinode(vfsp, dev, inode, ipp, credp,perror) ) { return (ENODEV); } - if (code = (*ufs_igetp)(vfsp, inode, &ip, credp)) { + ufsvfsp = (struct ufsvfs *)vfsp->vfs_data; + + rw_enter(&ufsvfsp->vfs_dqrwlock, RW_READER); + code = (*ufs_igetp)(vfsp, inode, &ip, credp); + rw_exit(&ufsvfsp->vfs_dqrwlock); + + if (code) { *perror = BAD_IGET; return code; } @@ -81,14 +95,16 @@ igetinode(vfsp, dev, inode, ipp, credp,perror) if (ip->i_mode == 0) { /* Not an allocated inode */ + AFS_ITIMES(ip); rw_exit(&ip->i_contents); - (*ufs_iputp)(ip); + VN_RELE(ITOV(ip)); return (ENOENT); } if (ip->i_nlink == 0 || (ip->i_mode&IFMT) != IFREG) { + AFS_ITIMES(ip); rw_exit(&ip->i_contents); - (*ufs_iputp)(ip); + VN_RELE(ITOV(ip)); return (ENOENT); } @@ -122,6 +138,7 @@ afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, rvp, credp) struct inode *ip, *newip; register int code; dev_t newdev; + struct ufsvfs *ufsvfsp; AFS_STATCNT(afs_syscall_icreate); @@ -142,11 +159,22 @@ afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, rvp, credp) if (code) { return (code); } - if (code = (*ufs_iallocp)(ip, near_inode, 0, &newip, credp)) { - (*ufs_iputp)(ip); + + ufsvfsp = ip->i_ufsvfs; + rw_enter(&ip->i_rwlock, RW_WRITER); + rw_enter(&ufsvfsp->vfs_dqrwlock, RW_READER); + rw_enter(&ip->i_contents, RW_WRITER); + code = (*ufs_iallocp)(ip, near_inode, 0, &newip, credp); + rw_exit(&ufsvfsp->vfs_dqrwlock); + rw_exit(&ip->i_rwlock); + + AFS_ITIMES(ip); + rw_exit(&ip->i_contents); + VN_RELE(ITOV(ip)); + + if (code) { return (code); } - (*ufs_iputp)(ip); rw_enter(&newip->i_contents, RW_WRITER); mutex_enter(&newip->i_tlock); newip->i_flag |= IACC|IUPD|ICHG; @@ -184,8 +212,9 @@ afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, rvp, credp) */ if (CrSync) (*ufs_iupdatp)(newip, 1); + AFS_ITIMES(newip); rw_exit(&newip->i_contents); - (*ufs_iputp)(newip); + VN_RELE(ITOV(newip)); return (code); } @@ -224,7 +253,10 @@ afs_syscall_iopen(dev, inode, usrmod, rvp, credp) } code = falloc((struct vnode *)NULL, FWRITE|FREAD, &fp, &fd); if (code) { - (*ufs_iputp)(ip); + rw_enter(&ip->i_contents, RW_READER); + AFS_ITIMES(ip); + rw_exit(&ip->i_contents); + VN_RELE(ITOV(ip)); return (code); } @@ -284,9 +316,13 @@ afs_syscall_iincdec(dev, inode, inode_p1, amount, rvp, credp) if (code) { return (code); } - if (!IS_VICEMAGIC(ip)) + if (!IS_VICEMAGIC(ip)) { code = EPERM; - else { + rw_enter(&ip->i_contents, RW_READER); + AFS_ITIMES(ip); + rw_exit(&ip->i_contents); + VN_RELE(ITOV(ip)); + } else { rw_enter(&ip->i_contents, RW_WRITER); ip->i_nlink += amount; if (ip->i_nlink == 0) { @@ -300,9 +336,10 @@ afs_syscall_iincdec(dev, inode, inode_p1, amount, rvp, credp) /* We may want to force the inode to the disk in case of crashes, other references, etc. */ if (IncSync) (*ufs_iupdatp)(ip, 1); + AFS_ITIMES(ip); rw_exit(&ip->i_contents); + VN_RELE(ITOV(ip)); } - (*ufs_iputp)(ip); return (code); } diff --git a/src/afs/SOLARIS/osi_vfsops.c b/src/afs/SOLARIS/osi_vfsops.c index 40d72507b..a16dea180 100644 --- a/src/afs/SOLARIS/osi_vfsops.c +++ b/src/afs/SOLARIS/osi_vfsops.c @@ -231,10 +231,10 @@ struct vfsops Afs_vfsops = { /* * afsinit - intialize VFS */ -void (*ufs_iputp)(); int (*ufs_iallocp)(); void (*ufs_iupdatp)(); int (*ufs_igetp)(); +void (*ufs_itimes_nolockp)(); struct streamtab *udp_infop = 0; struct ill_s *ill_g_headp = 0; @@ -302,14 +302,14 @@ afsinit(struct vfssw *vfsswp, int fstype) nfs_checkauth = (int (*)()) modlookup("nfssrv", "checkauth"); if ( !nfs_checkauth ) afs_warn("nfs_checkauth not initialised"); #endif - ufs_iputp = (int (*)()) modlookup("ufs", "ufs_iput"); ufs_iallocp = (int (*)()) modlookup("ufs", "ufs_ialloc"); ufs_iupdatp = (int (*)()) modlookup("ufs", "ufs_iupdat"); ufs_igetp = (int (*)()) modlookup("ufs", "ufs_iget"); + ufs_itimes_nolockp = (void (*)()) modlookup("ufs", "ufs_itimes_nolock"); udp_infop = (struct streamtab *) modlookup("udp", "udpinfo"); ill_g_headp = (struct ill_s *) modlookup("ip", "ill_g_head"); - if ( !ufs_iputp || !ufs_iallocp || !ufs_iupdatp || + if ( !ufs_iallocp || !ufs_iupdatp || !ufs_itimes_nolockp || !ufs_igetp || !udp_infop || !ill_g_headp ) afs_warn("AFS to UFS mapping cannot be fully initialised\n"); -- 2.39.5