diff options
author | phk <phk@FreeBSD.org> | 1997-10-17 12:36:19 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1997-10-17 12:36:19 +0000 |
commit | 14aa7b01ea93949392e6e18666f790095eac2ebf (patch) | |
tree | af234d30cce9d801c011d9f4154cc8c26d406c53 /sys | |
parent | 988fe95f9897d896424ea0328f166e0e740afeaa (diff) | |
download | FreeBSD-src-14aa7b01ea93949392e6e18666f790095eac2ebf.zip FreeBSD-src-14aa7b01ea93949392e6e18666f790095eac2ebf.tar.gz |
Make a set of VOP standard lock, unlock & islocked VOP operators, which
depend on the lock being located at vp->v_data. Saves 3x3 identical
vop procs, more as the other filesystems becomes lock aware.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/fs/cd9660/cd9660_node.h | 4 | ||||
-rw-r--r-- | sys/fs/cd9660/cd9660_vnops.c | 70 | ||||
-rw-r--r-- | sys/fs/msdosfs/denode.h | 4 | ||||
-rw-r--r-- | sys/fs/msdosfs/msdosfs_vnops.c | 49 | ||||
-rw-r--r-- | sys/gnu/ext2fs/inode.h | 4 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/inode.h | 4 | ||||
-rw-r--r-- | sys/isofs/cd9660/cd9660_node.h | 4 | ||||
-rw-r--r-- | sys/isofs/cd9660/cd9660_vnops.c | 70 | ||||
-rw-r--r-- | sys/kern/vfs_default.c | 45 | ||||
-rw-r--r-- | sys/msdosfs/denode.h | 4 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_vnops.c | 49 | ||||
-rw-r--r-- | sys/sys/vnode.h | 5 | ||||
-rw-r--r-- | sys/ufs/ufs/inode.h | 4 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_vnops.c | 70 |
14 files changed, 101 insertions, 285 deletions
diff --git a/sys/fs/cd9660/cd9660_node.h b/sys/fs/cd9660/cd9660_node.h index 5c0b721..971cdba 100644 --- a/sys/fs/cd9660/cd9660_node.h +++ b/sys/fs/cd9660/cd9660_node.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)cd9660_node.h 8.6 (Berkeley) 5/14/95 - * $Id: cd9660_node.h,v 1.13 1997/10/12 20:23:36 phk Exp $ + * $Id: cd9660_node.h,v 1.14 1997/10/16 10:47:39 phk Exp $ */ /* @@ -61,6 +61,7 @@ typedef struct { struct iso_node { + struct lock i_lock; /* node lock > Keep this first< */ struct iso_node *i_next, **i_prev; /* hash chain */ struct vnode *i_vnode; /* vnode associated with this inode */ struct vnode *i_devvp; /* vnode for block I/O */ @@ -74,7 +75,6 @@ struct iso_node { doff_t i_diroff; /* offset in dir, where we found last entry */ doff_t i_offset; /* offset of free space in directory */ ino_t i_ino; /* inode number of found directory */ - struct lock i_lock; /* node lock */ long iso_extent; /* extent of file */ long i_size; diff --git a/sys/fs/cd9660/cd9660_vnops.c b/sys/fs/cd9660/cd9660_vnops.c index 0318324..6a719a8 100644 --- a/sys/fs/cd9660/cd9660_vnops.c +++ b/sys/fs/cd9660/cd9660_vnops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)cd9660_vnops.c 8.19 (Berkeley) 5/27/95 - * $Id: cd9660_vnops.c,v 1.44 1997/10/16 10:47:47 phk Exp $ + * $Id: cd9660_vnops.c,v 1.45 1997/10/16 20:32:21 phk Exp $ */ #include <sys/param.h> @@ -69,11 +69,8 @@ static int iso_shipdir __P((struct isoreaddir *idp)); static int cd9660_readdir __P((struct vop_readdir_args *)); static int cd9660_readlink __P((struct vop_readlink_args *ap)); static int cd9660_abortop __P((struct vop_abortop_args *)); -static int cd9660_lock __P((struct vop_lock_args *)); -static int cd9660_unlock __P((struct vop_unlock_args *)); static int cd9660_strategy __P((struct vop_strategy_args *)); static int cd9660_print __P((struct vop_print_args *)); -static int cd9660_islocked __P((struct vop_islocked_args *)); /* * Setattr call. Only allowed for block and character special devices. @@ -718,40 +715,6 @@ cd9660_abortop(ap) } /* - * Lock an inode. - */ -static int -cd9660_lock(ap) - struct vop_lock_args /* { - struct vnode *a_vp; - int a_flags; - struct proc *a_p; - } */ *ap; -{ - struct vnode *vp = ap->a_vp; - - return (lockmgr(&VTOI(vp)->i_lock, ap->a_flags, &vp->v_interlock, - ap->a_p)); -} - -/* - * Unlock an inode. - */ -static int -cd9660_unlock(ap) - struct vop_unlock_args /* { - struct vnode *a_vp; - int a_flags; - struct proc *a_p; - } */ *ap; -{ - struct vnode *vp = ap->a_vp; - - return (lockmgr(&VTOI(vp)->i_lock, ap->a_flags | LK_RELEASE, - &vp->v_interlock, ap->a_p)); -} - -/* * Calculate the logical to physical mapping if not done already, * then call the device strategy routine. */ @@ -805,19 +768,6 @@ cd9660_print(ap) } /* - * Check for a locked inode. - */ -int -cd9660_islocked(ap) - struct vop_islocked_args /* { - struct vnode *a_vp; - } */ *ap; -{ - - return (lockstatus(&VTOI(ap->a_vp)->i_lock)); -} - -/* * Return POSIX pathconf information applicable to cd9660 filesystems. */ int @@ -869,8 +819,8 @@ struct vnodeopv_entry_desc cd9660_vnodeop_entries[] = { { &vop_cachedlookup_desc, (vop_t *) cd9660_lookup }, { &vop_getattr_desc, (vop_t *) cd9660_getattr }, { &vop_inactive_desc, (vop_t *) cd9660_inactive }, - { &vop_islocked_desc, (vop_t *) cd9660_islocked }, - { &vop_lock_desc, (vop_t *) cd9660_lock }, + { &vop_islocked_desc, (vop_t *) vop_stdislocked }, + { &vop_lock_desc, (vop_t *) vop_stdlock }, { &vop_lookup_desc, (vop_t *) vfs_cache_lookup }, { &vop_pathconf_desc, (vop_t *) cd9660_pathconf }, { &vop_print_desc, (vop_t *) cd9660_print }, @@ -880,7 +830,7 @@ struct vnodeopv_entry_desc cd9660_vnodeop_entries[] = { { &vop_reclaim_desc, (vop_t *) cd9660_reclaim }, { &vop_setattr_desc, (vop_t *) cd9660_setattr }, { &vop_strategy_desc, (vop_t *) cd9660_strategy }, - { &vop_unlock_desc, (vop_t *) cd9660_unlock }, + { &vop_unlock_desc, (vop_t *) vop_stdunlock }, { NULL, NULL } }; static struct vnodeopv_desc cd9660_vnodeop_opv_desc = @@ -896,12 +846,12 @@ struct vnodeopv_entry_desc cd9660_specop_entries[] = { { &vop_access_desc, (vop_t *) cd9660_access }, { &vop_getattr_desc, (vop_t *) cd9660_getattr }, { &vop_inactive_desc, (vop_t *) cd9660_inactive }, - { &vop_islocked_desc, (vop_t *) cd9660_islocked }, - { &vop_lock_desc, (vop_t *) cd9660_lock }, + { &vop_islocked_desc, (vop_t *) vop_stdislocked }, + { &vop_lock_desc, (vop_t *) vop_stdlock }, { &vop_print_desc, (vop_t *) cd9660_print }, { &vop_reclaim_desc, (vop_t *) cd9660_reclaim }, { &vop_setattr_desc, (vop_t *) cd9660_setattr }, - { &vop_unlock_desc, (vop_t *) cd9660_unlock }, + { &vop_unlock_desc, (vop_t *) vop_stdunlock }, { NULL, NULL } }; static struct vnodeopv_desc cd9660_specop_opv_desc = @@ -914,12 +864,12 @@ struct vnodeopv_entry_desc cd9660_fifoop_entries[] = { { &vop_access_desc, (vop_t *) cd9660_access }, { &vop_getattr_desc, (vop_t *) cd9660_getattr }, { &vop_inactive_desc, (vop_t *) cd9660_inactive }, - { &vop_islocked_desc, (vop_t *) cd9660_islocked }, - { &vop_lock_desc, (vop_t *) cd9660_lock }, + { &vop_islocked_desc, (vop_t *) vop_stdislocked }, + { &vop_lock_desc, (vop_t *) vop_stdlock }, { &vop_print_desc, (vop_t *) cd9660_print }, { &vop_reclaim_desc, (vop_t *) cd9660_reclaim }, { &vop_setattr_desc, (vop_t *) cd9660_setattr }, - { &vop_unlock_desc, (vop_t *) cd9660_unlock }, + { &vop_unlock_desc, (vop_t *) vop_stdunlock }, { NULL, NULL } }; static struct vnodeopv_desc cd9660_fifoop_opv_desc = diff --git a/sys/fs/msdosfs/denode.h b/sys/fs/msdosfs/denode.h index 335e4d0..6ad3fcc 100644 --- a/sys/fs/msdosfs/denode.h +++ b/sys/fs/msdosfs/denode.h @@ -1,4 +1,4 @@ -/* $Id: denode.h,v 1.12 1997/02/26 14:23:09 bde Exp $ */ +/* $Id: denode.h,v 1.13 1997/08/26 07:32:36 phk Exp $ */ /* $NetBSD: denode.h,v 1.8 1994/08/21 18:43:49 ws Exp $ */ /*- @@ -135,6 +135,7 @@ struct fatcache { * contained within a vnode. */ struct denode { + struct lock de_lock; /* denode lock >Keep this first< */ struct denode *de_next; /* Hash chain forward */ struct denode **de_prev; /* Hash chain back */ struct vnode *de_vnode; /* addr of vnode we are part of */ @@ -148,7 +149,6 @@ struct denode { long de_refcnt; /* reference count */ struct msdosfsmount *de_pmp; /* addr of our mount struct */ struct lockf *de_lockf; /* byte level lock list */ - struct lock de_lock; /* denode lock */ /* the next two fields must be contiguous in memory... */ u_char de_Name[8]; /* name, from directory entry */ u_char de_Extension[3]; /* extension, from directory entry */ diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c index 5adce6f..d228f49 100644 --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -1,4 +1,4 @@ -/* $Id: msdosfs_vnops.c,v 1.48 1997/10/16 10:48:52 phk Exp $ */ +/* $Id: msdosfs_vnops.c,v 1.49 1997/10/16 20:32:31 phk Exp $ */ /* $NetBSD: msdosfs_vnops.c,v 1.20 1994/08/21 18:44:13 ws Exp $ */ /*- @@ -94,12 +94,9 @@ static int msdosfs_rmdir __P((struct vop_rmdir_args *)); static int msdosfs_symlink __P((struct vop_symlink_args *)); static int msdosfs_readdir __P((struct vop_readdir_args *)); static int msdosfs_abortop __P((struct vop_abortop_args *)); -static int msdosfs_lock __P((struct vop_lock_args *)); -static int msdosfs_unlock __P((struct vop_unlock_args *)); static int msdosfs_bmap __P((struct vop_bmap_args *)); static int msdosfs_strategy __P((struct vop_strategy_args *)); static int msdosfs_print __P((struct vop_print_args *)); -static int msdosfs_islocked __P((struct vop_islocked_args *)); static int msdosfs_pathconf __P((struct vop_pathconf_args *ap)); /* @@ -1709,44 +1706,6 @@ msdosfs_abortop(ap) return 0; } -static int -msdosfs_lock(ap) - struct vop_lock_args /* { - struct vnode *a_vp; - int a_flags; - struct proc *a_p; - } */ *ap; -{ - struct vnode *vp = ap->a_vp; - - return (lockmgr(&VTODE(vp)->de_lock, ap->a_flags, &vp->v_interlock, - ap->a_p)); -} - -int -msdosfs_unlock(ap) - struct vop_unlock_args /* { - struct vnode *a_vp; - int a_flags; - struct proc *a_p; - } */ *ap; -{ - struct vnode *vp = ap->a_vp; - - return (lockmgr(&VTODE(vp)->de_lock, ap->a_flags | LK_RELEASE, - &vp->v_interlock, ap->a_p)); -} - -int -msdosfs_islocked(ap) - struct vop_islocked_args /* { - struct vnode *a_vp; - } */ *ap; -{ - - return (lockstatus(&VTODE(ap->a_vp)->de_lock)); -} - /* * vp - address of vnode file the file * bn - which cluster we are interested in mapping to a filesystem block number. @@ -1884,9 +1843,9 @@ static struct vnodeopv_entry_desc msdosfs_vnodeop_entries[] = { { &vop_fsync_desc, (vop_t *) msdosfs_fsync }, { &vop_getattr_desc, (vop_t *) msdosfs_getattr }, { &vop_inactive_desc, (vop_t *) msdosfs_inactive }, - { &vop_islocked_desc, (vop_t *) msdosfs_islocked }, + { &vop_islocked_desc, (vop_t *) vop_stdislocked }, { &vop_link_desc, (vop_t *) msdosfs_link }, - { &vop_lock_desc, (vop_t *) msdosfs_lock }, + { &vop_lock_desc, (vop_t *) vop_stdlock }, { &vop_lookup_desc, (vop_t *) vfs_cache_lookup }, { &vop_mkdir_desc, (vop_t *) msdosfs_mkdir }, { &vop_mknod_desc, (vop_t *) msdosfs_mknod }, @@ -1901,7 +1860,7 @@ static struct vnodeopv_entry_desc msdosfs_vnodeop_entries[] = { { &vop_setattr_desc, (vop_t *) msdosfs_setattr }, { &vop_strategy_desc, (vop_t *) msdosfs_strategy }, { &vop_symlink_desc, (vop_t *) msdosfs_symlink }, - { &vop_unlock_desc, (vop_t *) msdosfs_unlock }, + { &vop_unlock_desc, (vop_t *) vop_stdunlock }, { &vop_write_desc, (vop_t *) msdosfs_write }, { NULL, NULL } }; diff --git a/sys/gnu/ext2fs/inode.h b/sys/gnu/ext2fs/inode.h index 8a7e935..f33dc27 100644 --- a/sys/gnu/ext2fs/inode.h +++ b/sys/gnu/ext2fs/inode.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)inode.h 8.9 (Berkeley) 5/14/95 - * $Id: inode.h,v 1.16 1997/07/13 15:40:31 bde Exp $ + * $Id: inode.h,v 1.17 1997/10/14 18:46:45 phk Exp $ */ #ifndef _UFS_UFS_INODE_H_ @@ -59,6 +59,7 @@ * active, and is put back when the file is no longer being used. */ struct inode { + struct lock i_lock; /* Inode lock. >Keep this first< */ LIST_ENTRY(inode) i_hash;/* Hash chain. */ struct vnode *i_vnode;/* Vnode associated with this inode. */ struct vnode *i_devvp;/* Vnode for block I/O. */ @@ -77,7 +78,6 @@ struct inode { struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ u_quad_t i_modrev; /* Revision level for NFS lease. */ struct lockf *i_lockf;/* Head of byte-level lock list. */ - struct lock i_lock; /* Inode lock. */ /* * Side effects; used during directory lookup. */ diff --git a/sys/gnu/fs/ext2fs/inode.h b/sys/gnu/fs/ext2fs/inode.h index 8a7e935..f33dc27 100644 --- a/sys/gnu/fs/ext2fs/inode.h +++ b/sys/gnu/fs/ext2fs/inode.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)inode.h 8.9 (Berkeley) 5/14/95 - * $Id: inode.h,v 1.16 1997/07/13 15:40:31 bde Exp $ + * $Id: inode.h,v 1.17 1997/10/14 18:46:45 phk Exp $ */ #ifndef _UFS_UFS_INODE_H_ @@ -59,6 +59,7 @@ * active, and is put back when the file is no longer being used. */ struct inode { + struct lock i_lock; /* Inode lock. >Keep this first< */ LIST_ENTRY(inode) i_hash;/* Hash chain. */ struct vnode *i_vnode;/* Vnode associated with this inode. */ struct vnode *i_devvp;/* Vnode for block I/O. */ @@ -77,7 +78,6 @@ struct inode { struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ u_quad_t i_modrev; /* Revision level for NFS lease. */ struct lockf *i_lockf;/* Head of byte-level lock list. */ - struct lock i_lock; /* Inode lock. */ /* * Side effects; used during directory lookup. */ diff --git a/sys/isofs/cd9660/cd9660_node.h b/sys/isofs/cd9660/cd9660_node.h index 5c0b721..971cdba 100644 --- a/sys/isofs/cd9660/cd9660_node.h +++ b/sys/isofs/cd9660/cd9660_node.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)cd9660_node.h 8.6 (Berkeley) 5/14/95 - * $Id: cd9660_node.h,v 1.13 1997/10/12 20:23:36 phk Exp $ + * $Id: cd9660_node.h,v 1.14 1997/10/16 10:47:39 phk Exp $ */ /* @@ -61,6 +61,7 @@ typedef struct { struct iso_node { + struct lock i_lock; /* node lock > Keep this first< */ struct iso_node *i_next, **i_prev; /* hash chain */ struct vnode *i_vnode; /* vnode associated with this inode */ struct vnode *i_devvp; /* vnode for block I/O */ @@ -74,7 +75,6 @@ struct iso_node { doff_t i_diroff; /* offset in dir, where we found last entry */ doff_t i_offset; /* offset of free space in directory */ ino_t i_ino; /* inode number of found directory */ - struct lock i_lock; /* node lock */ long iso_extent; /* extent of file */ long i_size; diff --git a/sys/isofs/cd9660/cd9660_vnops.c b/sys/isofs/cd9660/cd9660_vnops.c index 0318324..6a719a8 100644 --- a/sys/isofs/cd9660/cd9660_vnops.c +++ b/sys/isofs/cd9660/cd9660_vnops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)cd9660_vnops.c 8.19 (Berkeley) 5/27/95 - * $Id: cd9660_vnops.c,v 1.44 1997/10/16 10:47:47 phk Exp $ + * $Id: cd9660_vnops.c,v 1.45 1997/10/16 20:32:21 phk Exp $ */ #include <sys/param.h> @@ -69,11 +69,8 @@ static int iso_shipdir __P((struct isoreaddir *idp)); static int cd9660_readdir __P((struct vop_readdir_args *)); static int cd9660_readlink __P((struct vop_readlink_args *ap)); static int cd9660_abortop __P((struct vop_abortop_args *)); -static int cd9660_lock __P((struct vop_lock_args *)); -static int cd9660_unlock __P((struct vop_unlock_args *)); static int cd9660_strategy __P((struct vop_strategy_args *)); static int cd9660_print __P((struct vop_print_args *)); -static int cd9660_islocked __P((struct vop_islocked_args *)); /* * Setattr call. Only allowed for block and character special devices. @@ -718,40 +715,6 @@ cd9660_abortop(ap) } /* - * Lock an inode. - */ -static int -cd9660_lock(ap) - struct vop_lock_args /* { - struct vnode *a_vp; - int a_flags; - struct proc *a_p; - } */ *ap; -{ - struct vnode *vp = ap->a_vp; - - return (lockmgr(&VTOI(vp)->i_lock, ap->a_flags, &vp->v_interlock, - ap->a_p)); -} - -/* - * Unlock an inode. - */ -static int -cd9660_unlock(ap) - struct vop_unlock_args /* { - struct vnode *a_vp; - int a_flags; - struct proc *a_p; - } */ *ap; -{ - struct vnode *vp = ap->a_vp; - - return (lockmgr(&VTOI(vp)->i_lock, ap->a_flags | LK_RELEASE, - &vp->v_interlock, ap->a_p)); -} - -/* * Calculate the logical to physical mapping if not done already, * then call the device strategy routine. */ @@ -805,19 +768,6 @@ cd9660_print(ap) } /* - * Check for a locked inode. - */ -int -cd9660_islocked(ap) - struct vop_islocked_args /* { - struct vnode *a_vp; - } */ *ap; -{ - - return (lockstatus(&VTOI(ap->a_vp)->i_lock)); -} - -/* * Return POSIX pathconf information applicable to cd9660 filesystems. */ int @@ -869,8 +819,8 @@ struct vnodeopv_entry_desc cd9660_vnodeop_entries[] = { { &vop_cachedlookup_desc, (vop_t *) cd9660_lookup }, { &vop_getattr_desc, (vop_t *) cd9660_getattr }, { &vop_inactive_desc, (vop_t *) cd9660_inactive }, - { &vop_islocked_desc, (vop_t *) cd9660_islocked }, - { &vop_lock_desc, (vop_t *) cd9660_lock }, + { &vop_islocked_desc, (vop_t *) vop_stdislocked }, + { &vop_lock_desc, (vop_t *) vop_stdlock }, { &vop_lookup_desc, (vop_t *) vfs_cache_lookup }, { &vop_pathconf_desc, (vop_t *) cd9660_pathconf }, { &vop_print_desc, (vop_t *) cd9660_print }, @@ -880,7 +830,7 @@ struct vnodeopv_entry_desc cd9660_vnodeop_entries[] = { { &vop_reclaim_desc, (vop_t *) cd9660_reclaim }, { &vop_setattr_desc, (vop_t *) cd9660_setattr }, { &vop_strategy_desc, (vop_t *) cd9660_strategy }, - { &vop_unlock_desc, (vop_t *) cd9660_unlock }, + { &vop_unlock_desc, (vop_t *) vop_stdunlock }, { NULL, NULL } }; static struct vnodeopv_desc cd9660_vnodeop_opv_desc = @@ -896,12 +846,12 @@ struct vnodeopv_entry_desc cd9660_specop_entries[] = { { &vop_access_desc, (vop_t *) cd9660_access }, { &vop_getattr_desc, (vop_t *) cd9660_getattr }, { &vop_inactive_desc, (vop_t *) cd9660_inactive }, - { &vop_islocked_desc, (vop_t *) cd9660_islocked }, - { &vop_lock_desc, (vop_t *) cd9660_lock }, + { &vop_islocked_desc, (vop_t *) vop_stdislocked }, + { &vop_lock_desc, (vop_t *) vop_stdlock }, { &vop_print_desc, (vop_t *) cd9660_print }, { &vop_reclaim_desc, (vop_t *) cd9660_reclaim }, { &vop_setattr_desc, (vop_t *) cd9660_setattr }, - { &vop_unlock_desc, (vop_t *) cd9660_unlock }, + { &vop_unlock_desc, (vop_t *) vop_stdunlock }, { NULL, NULL } }; static struct vnodeopv_desc cd9660_specop_opv_desc = @@ -914,12 +864,12 @@ struct vnodeopv_entry_desc cd9660_fifoop_entries[] = { { &vop_access_desc, (vop_t *) cd9660_access }, { &vop_getattr_desc, (vop_t *) cd9660_getattr }, { &vop_inactive_desc, (vop_t *) cd9660_inactive }, - { &vop_islocked_desc, (vop_t *) cd9660_islocked }, - { &vop_lock_desc, (vop_t *) cd9660_lock }, + { &vop_islocked_desc, (vop_t *) vop_stdislocked }, + { &vop_lock_desc, (vop_t *) vop_stdlock }, { &vop_print_desc, (vop_t *) cd9660_print }, { &vop_reclaim_desc, (vop_t *) cd9660_reclaim }, { &vop_setattr_desc, (vop_t *) cd9660_setattr }, - { &vop_unlock_desc, (vop_t *) cd9660_unlock }, + { &vop_unlock_desc, (vop_t *) vop_stdunlock }, { NULL, NULL } }; static struct vnodeopv_desc cd9660_fifoop_opv_desc = diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index a6a1d39..d130200 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -172,3 +172,48 @@ vop_stdpathconf(ap) } /* NOTREACHED */ } + +/* + * Standard lock, unlock and islocked functions. + * + * These depend on the lock structure being the first element in the + * inode, ie: vp->v_data points to the the lock! + */ +int +vop_stdlock(ap) + struct vop_lock_args /* { + struct vnode *a_vp; + int a_flags; + struct proc *a_p; + } */ *ap; +{ + struct lock *l = (struct lock*)ap->a_vp->v_data; + + return (lockmgr(l, ap->a_flags, &ap->a_vp->v_interlock, ap->a_p)); +} + +int +vop_stdunlock(ap) + struct vop_unlock_args /* { + struct vnode *a_vp; + int a_flags; + struct proc *a_p; + } */ *ap; +{ + struct lock *l = (struct lock*)ap->a_vp->v_data; + + return (lockmgr(l, ap->a_flags | LK_RELEASE, &ap->a_vp->v_interlock, + ap->a_p)); +} + +int +vop_stdislocked(ap) + struct vop_islocked_args /* { + struct vnode *a_vp; + } */ *ap; +{ + struct lock *l = (struct lock*)ap->a_vp->v_data; + + return (lockstatus(l)); +} + diff --git a/sys/msdosfs/denode.h b/sys/msdosfs/denode.h index 335e4d0..6ad3fcc 100644 --- a/sys/msdosfs/denode.h +++ b/sys/msdosfs/denode.h @@ -1,4 +1,4 @@ -/* $Id: denode.h,v 1.12 1997/02/26 14:23:09 bde Exp $ */ +/* $Id: denode.h,v 1.13 1997/08/26 07:32:36 phk Exp $ */ /* $NetBSD: denode.h,v 1.8 1994/08/21 18:43:49 ws Exp $ */ /*- @@ -135,6 +135,7 @@ struct fatcache { * contained within a vnode. */ struct denode { + struct lock de_lock; /* denode lock >Keep this first< */ struct denode *de_next; /* Hash chain forward */ struct denode **de_prev; /* Hash chain back */ struct vnode *de_vnode; /* addr of vnode we are part of */ @@ -148,7 +149,6 @@ struct denode { long de_refcnt; /* reference count */ struct msdosfsmount *de_pmp; /* addr of our mount struct */ struct lockf *de_lockf; /* byte level lock list */ - struct lock de_lock; /* denode lock */ /* the next two fields must be contiguous in memory... */ u_char de_Name[8]; /* name, from directory entry */ u_char de_Extension[3]; /* extension, from directory entry */ diff --git a/sys/msdosfs/msdosfs_vnops.c b/sys/msdosfs/msdosfs_vnops.c index 5adce6f..d228f49 100644 --- a/sys/msdosfs/msdosfs_vnops.c +++ b/sys/msdosfs/msdosfs_vnops.c @@ -1,4 +1,4 @@ -/* $Id: msdosfs_vnops.c,v 1.48 1997/10/16 10:48:52 phk Exp $ */ +/* $Id: msdosfs_vnops.c,v 1.49 1997/10/16 20:32:31 phk Exp $ */ /* $NetBSD: msdosfs_vnops.c,v 1.20 1994/08/21 18:44:13 ws Exp $ */ /*- @@ -94,12 +94,9 @@ static int msdosfs_rmdir __P((struct vop_rmdir_args *)); static int msdosfs_symlink __P((struct vop_symlink_args *)); static int msdosfs_readdir __P((struct vop_readdir_args *)); static int msdosfs_abortop __P((struct vop_abortop_args *)); -static int msdosfs_lock __P((struct vop_lock_args *)); -static int msdosfs_unlock __P((struct vop_unlock_args *)); static int msdosfs_bmap __P((struct vop_bmap_args *)); static int msdosfs_strategy __P((struct vop_strategy_args *)); static int msdosfs_print __P((struct vop_print_args *)); -static int msdosfs_islocked __P((struct vop_islocked_args *)); static int msdosfs_pathconf __P((struct vop_pathconf_args *ap)); /* @@ -1709,44 +1706,6 @@ msdosfs_abortop(ap) return 0; } -static int -msdosfs_lock(ap) - struct vop_lock_args /* { - struct vnode *a_vp; - int a_flags; - struct proc *a_p; - } */ *ap; -{ - struct vnode *vp = ap->a_vp; - - return (lockmgr(&VTODE(vp)->de_lock, ap->a_flags, &vp->v_interlock, - ap->a_p)); -} - -int -msdosfs_unlock(ap) - struct vop_unlock_args /* { - struct vnode *a_vp; - int a_flags; - struct proc *a_p; - } */ *ap; -{ - struct vnode *vp = ap->a_vp; - - return (lockmgr(&VTODE(vp)->de_lock, ap->a_flags | LK_RELEASE, - &vp->v_interlock, ap->a_p)); -} - -int -msdosfs_islocked(ap) - struct vop_islocked_args /* { - struct vnode *a_vp; - } */ *ap; -{ - - return (lockstatus(&VTODE(ap->a_vp)->de_lock)); -} - /* * vp - address of vnode file the file * bn - which cluster we are interested in mapping to a filesystem block number. @@ -1884,9 +1843,9 @@ static struct vnodeopv_entry_desc msdosfs_vnodeop_entries[] = { { &vop_fsync_desc, (vop_t *) msdosfs_fsync }, { &vop_getattr_desc, (vop_t *) msdosfs_getattr }, { &vop_inactive_desc, (vop_t *) msdosfs_inactive }, - { &vop_islocked_desc, (vop_t *) msdosfs_islocked }, + { &vop_islocked_desc, (vop_t *) vop_stdislocked }, { &vop_link_desc, (vop_t *) msdosfs_link }, - { &vop_lock_desc, (vop_t *) msdosfs_lock }, + { &vop_lock_desc, (vop_t *) vop_stdlock }, { &vop_lookup_desc, (vop_t *) vfs_cache_lookup }, { &vop_mkdir_desc, (vop_t *) msdosfs_mkdir }, { &vop_mknod_desc, (vop_t *) msdosfs_mknod }, @@ -1901,7 +1860,7 @@ static struct vnodeopv_entry_desc msdosfs_vnodeop_entries[] = { { &vop_setattr_desc, (vop_t *) msdosfs_setattr }, { &vop_strategy_desc, (vop_t *) msdosfs_strategy }, { &vop_symlink_desc, (vop_t *) msdosfs_symlink }, - { &vop_unlock_desc, (vop_t *) msdosfs_unlock }, + { &vop_unlock_desc, (vop_t *) vop_stdunlock }, { &vop_write_desc, (vop_t *) msdosfs_write }, { NULL, NULL } }; diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index e6a5e29..2f93a64 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)vnode.h 8.7 (Berkeley) 2/4/94 - * $Id: vnode.h,v 1.51 1997/10/16 10:49:13 phk Exp $ + * $Id: vnode.h,v 1.52 1997/10/16 20:32:33 phk Exp $ */ #ifndef _SYS_VNODE_H_ @@ -502,6 +502,9 @@ int vfs_cache_lookup __P((struct vop_lookup_args *ap)); int vfs_object_create __P((struct vnode *vp, struct proc *p, struct ucred *cred, int waslocked)); int vn_writechk __P((struct vnode *vp)); +int vop_stdislocked __P((struct vop_islocked_args *)); +int vop_stdlock __P((struct vop_lock_args *)); +int vop_stdunlock __P((struct vop_unlock_args *)); int vop_noislocked __P((struct vop_islocked_args *)); int vop_nolock __P((struct vop_lock_args *)); int vop_nopoll __P((struct vop_poll_args *)); diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index 8a7e935..f33dc27 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)inode.h 8.9 (Berkeley) 5/14/95 - * $Id: inode.h,v 1.16 1997/07/13 15:40:31 bde Exp $ + * $Id: inode.h,v 1.17 1997/10/14 18:46:45 phk Exp $ */ #ifndef _UFS_UFS_INODE_H_ @@ -59,6 +59,7 @@ * active, and is put back when the file is no longer being used. */ struct inode { + struct lock i_lock; /* Inode lock. >Keep this first< */ LIST_ENTRY(inode) i_hash;/* Hash chain. */ struct vnode *i_vnode;/* Vnode associated with this inode. */ struct vnode *i_devvp;/* Vnode for block I/O. */ @@ -77,7 +78,6 @@ struct inode { struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ u_quad_t i_modrev; /* Revision level for NFS lease. */ struct lockf *i_lockf;/* Head of byte-level lock list. */ - struct lock i_lock; /* Inode lock. */ /* * Side effects; used during directory lookup. */ diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 0a80e7f..ce7ca2d 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)ufs_vnops.c 8.27 (Berkeley) 5/27/95 - * $Id: ufs_vnops.c,v 1.61 1997/10/16 11:59:09 phk Exp $ + * $Id: ufs_vnops.c,v 1.62 1997/10/16 20:32:39 phk Exp $ */ #include "opt_quota.h" @@ -73,9 +73,7 @@ static int ufs_chown __P((struct vnode *, uid_t, gid_t, struct ucred *, struct p static int ufs_close __P((struct vop_close_args *)); static int ufs_create __P((struct vop_create_args *)); static int ufs_getattr __P((struct vop_getattr_args *)); -static int ufs_islocked __P((struct vop_islocked_args *)); static int ufs_link __P((struct vop_link_args *)); -static int ufs_lock __P((struct vop_lock_args *)); static int ufs_makeinode __P((int mode, struct vnode *, struct vnode **, struct componentname *)); static int ufs_missingop __P((struct vop_generic_args *ap)); static int ufs_mkdir __P((struct vop_mkdir_args *)); @@ -91,7 +89,6 @@ static int ufs_rmdir __P((struct vop_rmdir_args *)); static int ufs_setattr __P((struct vop_setattr_args *)); static int ufs_strategy __P((struct vop_strategy_args *)); static int ufs_symlink __P((struct vop_symlink_args *)); -static int ufs_unlock __P((struct vop_unlock_args *)); static int ufs_whiteout __P((struct vop_whiteout_args *)); static int ufsfifo_close __P((struct vop_close_args *)); static int ufsfifo_read __P((struct vop_read_args *)); @@ -1719,53 +1716,6 @@ ufs_abortop(ap) } /* - * Lock an inode. If its already locked, set the WANT bit and sleep. - */ -int -ufs_lock(ap) - struct vop_lock_args /* { - struct vnode *a_vp; - int a_flags; - struct proc *a_p; - } */ *ap; -{ - struct vnode *vp = ap->a_vp; - - return (lockmgr(&VTOI(vp)->i_lock, ap->a_flags, &vp->v_interlock, - ap->a_p)); -} - -/* - * Unlock an inode. - */ -int -ufs_unlock(ap) - struct vop_unlock_args /* { - struct vnode *a_vp; - int a_flags; - struct proc *a_p; - } */ *ap; -{ - struct vnode *vp = ap->a_vp; - - return (lockmgr(&VTOI(vp)->i_lock, ap->a_flags | LK_RELEASE, - &vp->v_interlock, ap->a_p)); -} - -/* - * Check for a locked inode. - */ -int -ufs_islocked(ap) - struct vop_islocked_args /* { - struct vnode *a_vp; - } */ *ap; -{ - - return (lockstatus(&VTOI(ap->a_vp)->i_lock)); -} - -/* * Calculate the logical to physical mapping if not done already, * then call the device strategy routine. */ @@ -2146,9 +2096,9 @@ static struct vnodeopv_entry_desc ufs_vnodeop_entries[] = { { &vop_create_desc, (vop_t *) ufs_create }, { &vop_getattr_desc, (vop_t *) ufs_getattr }, { &vop_inactive_desc, (vop_t *) ufs_inactive }, - { &vop_islocked_desc, (vop_t *) ufs_islocked }, + { &vop_islocked_desc, (vop_t *) vop_stdislocked }, { &vop_link_desc, (vop_t *) ufs_link }, - { &vop_lock_desc, (vop_t *) ufs_lock }, + { &vop_lock_desc, (vop_t *) vop_stdlock }, { &vop_lookup_desc, (vop_t *) vfs_cache_lookup }, { &vop_mkdir_desc, (vop_t *) ufs_mkdir }, { &vop_mknod_desc, (vop_t *) ufs_mknod }, @@ -2165,7 +2115,7 @@ static struct vnodeopv_entry_desc ufs_vnodeop_entries[] = { { &vop_setattr_desc, (vop_t *) ufs_setattr }, { &vop_strategy_desc, (vop_t *) ufs_strategy }, { &vop_symlink_desc, (vop_t *) ufs_symlink }, - { &vop_unlock_desc, (vop_t *) ufs_unlock }, + { &vop_unlock_desc, (vop_t *) vop_stdunlock }, { &vop_whiteout_desc, (vop_t *) ufs_whiteout }, { NULL, NULL } }; @@ -2180,13 +2130,13 @@ static struct vnodeopv_entry_desc ufs_specop_entries[] = { { &vop_close_desc, (vop_t *) ufsspec_close }, { &vop_getattr_desc, (vop_t *) ufs_getattr }, { &vop_inactive_desc, (vop_t *) ufs_inactive }, - { &vop_islocked_desc, (vop_t *) ufs_islocked }, - { &vop_lock_desc, (vop_t *) ufs_lock }, + { &vop_islocked_desc, (vop_t *) vop_stdislocked }, + { &vop_lock_desc, (vop_t *) vop_stdlock }, { &vop_print_desc, (vop_t *) ufs_print }, { &vop_read_desc, (vop_t *) ufsspec_read }, { &vop_reclaim_desc, (vop_t *) ufs_reclaim }, { &vop_setattr_desc, (vop_t *) ufs_setattr }, - { &vop_unlock_desc, (vop_t *) ufs_unlock }, + { &vop_unlock_desc, (vop_t *) vop_stdunlock }, { &vop_write_desc, (vop_t *) ufsspec_write }, { NULL, NULL } }; @@ -2201,13 +2151,13 @@ static struct vnodeopv_entry_desc ufs_fifoop_entries[] = { { &vop_close_desc, (vop_t *) ufsfifo_close }, { &vop_getattr_desc, (vop_t *) ufs_getattr }, { &vop_inactive_desc, (vop_t *) ufs_inactive }, - { &vop_islocked_desc, (vop_t *) ufs_islocked }, - { &vop_lock_desc, (vop_t *) ufs_lock }, + { &vop_islocked_desc, (vop_t *) vop_stdislocked }, + { &vop_lock_desc, (vop_t *) vop_stdlock }, { &vop_print_desc, (vop_t *) ufs_print }, { &vop_read_desc, (vop_t *) ufsfifo_read }, { &vop_reclaim_desc, (vop_t *) ufs_reclaim }, { &vop_setattr_desc, (vop_t *) ufs_setattr }, - { &vop_unlock_desc, (vop_t *) ufs_unlock }, + { &vop_unlock_desc, (vop_t *) vop_stdunlock }, { &vop_write_desc, (vop_t *) ufsfifo_write }, { NULL, NULL } }; |