vfs_subr.c (bcf11e8d0048006ba97cb460a134cc23290428b2) | vfs_subr.c (d8b0556c6dcaf4c506039f86af2b52b29524f89e) |
---|---|
1/*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 96 unchanged lines hidden (view full) --- 105static void v_decr_usecount(struct vnode *); 106static void v_decr_useonly(struct vnode *); 107static void v_upgrade_usecount(struct vnode *); 108static void vfree(struct vnode *); 109static void vnlru_free(int); 110static void vgonel(struct vnode *); 111static void vfs_knllock(void *arg); 112static void vfs_knlunlock(void *arg); | 1/*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 96 unchanged lines hidden (view full) --- 105static void v_decr_usecount(struct vnode *); 106static void v_decr_useonly(struct vnode *); 107static void v_upgrade_usecount(struct vnode *); 108static void vfree(struct vnode *); 109static void vnlru_free(int); 110static void vgonel(struct vnode *); 111static void vfs_knllock(void *arg); 112static void vfs_knlunlock(void *arg); |
113static int vfs_knllocked(void *arg); | 113static void vfs_knl_assert_locked(void *arg); 114static void vfs_knl_assert_unlocked(void *arg); |
114static void destroy_vpollinfo(struct vpollinfo *vi); 115 116/* 117 * Number of vnodes in existence. Increased whenever getnewvnode() 118 * allocates a new vnode, decreased on vdestroy() called on VI_DOOMed 119 * vnode. 120 */ 121static unsigned long numvnodes; --- 3144 unchanged lines hidden (view full) --- 3266{ 3267 struct vpollinfo *vi; 3268 3269 if (vp->v_pollinfo != NULL) 3270 return; 3271 vi = uma_zalloc(vnodepoll_zone, M_WAITOK); 3272 mtx_init(&vi->vpi_lock, "vnode pollinfo", NULL, MTX_DEF); 3273 knlist_init(&vi->vpi_selinfo.si_note, vp, vfs_knllock, | 115static void destroy_vpollinfo(struct vpollinfo *vi); 116 117/* 118 * Number of vnodes in existence. Increased whenever getnewvnode() 119 * allocates a new vnode, decreased on vdestroy() called on VI_DOOMed 120 * vnode. 121 */ 122static unsigned long numvnodes; --- 3144 unchanged lines hidden (view full) --- 3267{ 3268 struct vpollinfo *vi; 3269 3270 if (vp->v_pollinfo != NULL) 3271 return; 3272 vi = uma_zalloc(vnodepoll_zone, M_WAITOK); 3273 mtx_init(&vi->vpi_lock, "vnode pollinfo", NULL, MTX_DEF); 3274 knlist_init(&vi->vpi_selinfo.si_note, vp, vfs_knllock, |
3274 vfs_knlunlock, vfs_knllocked); | 3275 vfs_knlunlock, vfs_knl_assert_locked, vfs_knl_assert_unlocked); |
3275 VI_LOCK(vp); 3276 if (vp->v_pollinfo != NULL) { 3277 VI_UNLOCK(vp); 3278 destroy_vpollinfo(vi); 3279 return; 3280 } 3281 vp->v_pollinfo = vi; 3282 VI_UNLOCK(vp); --- 698 unchanged lines hidden (view full) --- 3981 VFS_KNOTE_LOCKED(a->a_dvp, NOTE_WRITE); 3982} 3983 3984static struct knlist fs_knlist; 3985 3986static void 3987vfs_event_init(void *arg) 3988{ | 3276 VI_LOCK(vp); 3277 if (vp->v_pollinfo != NULL) { 3278 VI_UNLOCK(vp); 3279 destroy_vpollinfo(vi); 3280 return; 3281 } 3282 vp->v_pollinfo = vi; 3283 VI_UNLOCK(vp); --- 698 unchanged lines hidden (view full) --- 3982 VFS_KNOTE_LOCKED(a->a_dvp, NOTE_WRITE); 3983} 3984 3985static struct knlist fs_knlist; 3986 3987static void 3988vfs_event_init(void *arg) 3989{ |
3989 knlist_init(&fs_knlist, NULL, NULL, NULL, NULL); | 3990 knlist_init_mtx(&fs_knlist, NULL); |
3990} 3991/* XXX - correct order? */ 3992SYSINIT(vfs_knlist, SI_SUB_VFS, SI_ORDER_ANY, vfs_event_init, NULL); 3993 3994void 3995vfs_event_signal(fsid_t *fsid, u_int32_t event, intptr_t data __unused) 3996{ 3997 --- 96 unchanged lines hidden (view full) --- 4094static void 4095vfs_knlunlock(void *arg) 4096{ 4097 struct vnode *vp = arg; 4098 4099 VOP_UNLOCK(vp, 0); 4100} 4101 | 3991} 3992/* XXX - correct order? */ 3993SYSINIT(vfs_knlist, SI_SUB_VFS, SI_ORDER_ANY, vfs_event_init, NULL); 3994 3995void 3996vfs_event_signal(fsid_t *fsid, u_int32_t event, intptr_t data __unused) 3997{ 3998 --- 96 unchanged lines hidden (view full) --- 4095static void 4096vfs_knlunlock(void *arg) 4097{ 4098 struct vnode *vp = arg; 4099 4100 VOP_UNLOCK(vp, 0); 4101} 4102 |
4102static int 4103vfs_knllocked(void *arg) | 4103static void 4104vfs_knl_assert_locked(void *arg) |
4104{ | 4105{ |
4106#ifdef DEBUG_VFS_LOCKS |
|
4105 struct vnode *vp = arg; 4106 | 4107 struct vnode *vp = arg; 4108 |
4107 return (VOP_ISLOCKED(vp) == LK_EXCLUSIVE); | 4109 ASSERT_VOP_LOCKED(vp, "vfs_knl_assert_locked"); 4110#endif |
4108} 4109 | 4111} 4112 |
4113static void 4114vfs_knl_assert_unlocked(void *arg) 4115{ 4116#ifdef DEBUG_VFS_LOCKS 4117 struct vnode *vp = arg; 4118 4119 ASSERT_VOP_UNLOCKED(vp, "vfs_knl_assert_unlocked"); 4120#endif 4121} 4122 |
|
4110int 4111vfs_kqfilter(struct vop_kqfilter_args *ap) 4112{ 4113 struct vnode *vp = ap->a_vp; 4114 struct knote *kn = ap->a_kn; 4115 struct knlist *knl; 4116 4117 switch (kn->kn_filter) { --- 34 unchanged lines hidden (view full) --- 4152} 4153 4154/*ARGSUSED*/ 4155static int 4156filt_vfsread(struct knote *kn, long hint) 4157{ 4158 struct vnode *vp = (struct vnode *)kn->kn_hook; 4159 struct vattr va; | 4123int 4124vfs_kqfilter(struct vop_kqfilter_args *ap) 4125{ 4126 struct vnode *vp = ap->a_vp; 4127 struct knote *kn = ap->a_kn; 4128 struct knlist *knl; 4129 4130 switch (kn->kn_filter) { --- 34 unchanged lines hidden (view full) --- 4165} 4166 4167/*ARGSUSED*/ 4168static int 4169filt_vfsread(struct knote *kn, long hint) 4170{ 4171 struct vnode *vp = (struct vnode *)kn->kn_hook; 4172 struct vattr va; |
4173 int res; |
|
4160 4161 /* 4162 * filesystem is gone, so set the EOF flag and schedule 4163 * the knote for deletion. 4164 */ 4165 if (hint == NOTE_REVOKE) { | 4174 4175 /* 4176 * filesystem is gone, so set the EOF flag and schedule 4177 * the knote for deletion. 4178 */ 4179 if (hint == NOTE_REVOKE) { |
4180 VI_LOCK(vp); |
|
4166 kn->kn_flags |= (EV_EOF | EV_ONESHOT); | 4181 kn->kn_flags |= (EV_EOF | EV_ONESHOT); |
4182 VI_UNLOCK(vp); |
|
4167 return (1); 4168 } 4169 4170 if (VOP_GETATTR(vp, &va, curthread->td_ucred)) 4171 return (0); 4172 | 4183 return (1); 4184 } 4185 4186 if (VOP_GETATTR(vp, &va, curthread->td_ucred)) 4187 return (0); 4188 |
4189 VI_LOCK(vp); |
|
4173 kn->kn_data = va.va_size - kn->kn_fp->f_offset; | 4190 kn->kn_data = va.va_size - kn->kn_fp->f_offset; |
4174 return (kn->kn_data != 0); | 4191 res = (kn->kn_data != 0); 4192 VI_UNLOCK(vp); 4193 return (res); |
4175} 4176 4177/*ARGSUSED*/ 4178static int 4179filt_vfswrite(struct knote *kn, long hint) 4180{ | 4194} 4195 4196/*ARGSUSED*/ 4197static int 4198filt_vfswrite(struct knote *kn, long hint) 4199{ |
4200 struct vnode *vp = (struct vnode *)kn->kn_hook; 4201 4202 VI_LOCK(vp); 4203 |
|
4181 /* 4182 * filesystem is gone, so set the EOF flag and schedule 4183 * the knote for deletion. 4184 */ 4185 if (hint == NOTE_REVOKE) 4186 kn->kn_flags |= (EV_EOF | EV_ONESHOT); 4187 4188 kn->kn_data = 0; | 4204 /* 4205 * filesystem is gone, so set the EOF flag and schedule 4206 * the knote for deletion. 4207 */ 4208 if (hint == NOTE_REVOKE) 4209 kn->kn_flags |= (EV_EOF | EV_ONESHOT); 4210 4211 kn->kn_data = 0; |
4212 VI_UNLOCK(vp); |
|
4189 return (1); 4190} 4191 4192static int 4193filt_vfsvnode(struct knote *kn, long hint) 4194{ | 4213 return (1); 4214} 4215 4216static int 4217filt_vfsvnode(struct knote *kn, long hint) 4218{ |
4219 struct vnode *vp = (struct vnode *)kn->kn_hook; 4220 int res; 4221 4222 VI_LOCK(vp); |
|
4195 if (kn->kn_sfflags & hint) 4196 kn->kn_fflags |= hint; 4197 if (hint == NOTE_REVOKE) { 4198 kn->kn_flags |= EV_EOF; | 4223 if (kn->kn_sfflags & hint) 4224 kn->kn_fflags |= hint; 4225 if (hint == NOTE_REVOKE) { 4226 kn->kn_flags |= EV_EOF; |
4227 VI_UNLOCK(vp); |
|
4199 return (1); 4200 } | 4228 return (1); 4229 } |
4201 return (kn->kn_fflags != 0); | 4230 res = (kn->kn_fflags != 0); 4231 VI_UNLOCK(vp); 4232 return (res); |
4202} 4203 4204int 4205vfs_read_dirent(struct vop_readdir_args *ap, struct dirent *dp, off_t off) 4206{ 4207 int error; 4208 4209 if (dp->d_reclen > ap->a_uio->uio_resid) --- 83 unchanged lines hidden --- | 4233} 4234 4235int 4236vfs_read_dirent(struct vop_readdir_args *ap, struct dirent *dp, off_t off) 4237{ 4238 int error; 4239 4240 if (dp->d_reclen > ap->a_uio->uio_resid) --- 83 unchanged lines hidden --- |