| 1 | /* |
| 2 | * Copyright 2000, International Business Machines Corporation and others. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * This software has been released under the terms of the IBM Public |
| 6 | * License. For details, see the LICENSE file in the top-level source |
| 7 | * directory or online at http://www.openafs.org/dl/license10.html |
| 8 | */ |
| 9 | |
| 10 | #include <afsconfig.h> |
| 11 | #include "afs/param.h" |
| 12 | |
| 13 | #include "afs/sysincludes.h" /*Standard vendor system headers */ |
| 14 | #include "afsincludes.h" /*AFS-based standard headers */ |
| 15 | |
| 16 | int |
| 17 | osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) |
| 18 | { |
| 19 | int code; |
| 20 | |
| 21 | /* Perhaps this function should use vgone() or vrecycle() instead. */ |
| 22 | |
| 23 | if ((afs_debug & AFSDEB_GENERAL) != 0) { |
| 24 | printf("%s enter\n", __func__); |
| 25 | } |
| 26 | |
| 27 | if (osi_VM_FlushVCache(avc) != 0) { |
| 28 | code = 0; |
| 29 | } else { |
| 30 | code = 1; |
| 31 | } |
| 32 | |
| 33 | if ((afs_debug & AFSDEB_GENERAL) != 0) { |
| 34 | printf("%s exit %d\n", __func__, code); |
| 35 | } |
| 36 | |
| 37 | return code; |
| 38 | } |
| 39 | |
| 40 | struct vcache * |
| 41 | osi_NewVnode(void) |
| 42 | { |
| 43 | struct vcache *tvc; |
| 44 | |
| 45 | tvc = afs_osi_Alloc(sizeof(struct vcache)); |
| 46 | tvc->v = NULL; /* important to clean this, or use memset 0 */ |
| 47 | |
| 48 | return tvc; |
| 49 | } |
| 50 | |
| 51 | void |
| 52 | osi_PrePopulateVCache(struct vcache *avc) |
| 53 | { |
| 54 | memset(avc, 0, sizeof(struct vcache)); |
| 55 | } |
| 56 | |
| 57 | void |
| 58 | osi_AttachVnode(struct vcache *avc, int seq) |
| 59 | { |
| 60 | ReleaseWriteLock(&afs_xvcache); |
| 61 | AFS_GUNLOCK(); |
| 62 | afs_nbsd_getnewvnode(avc); /* includes one refcount */ |
| 63 | AFS_GLOCK(); |
| 64 | ObtainWriteLock(&afs_xvcache,337); |
| 65 | #ifndef AFS_NBSD50_ENV |
| 66 | lockinit(&avc->rwlock, PINOD, "vcache", 0, 0); |
| 67 | #endif |
| 68 | } |
| 69 | |
| 70 | void |
| 71 | osi_PostPopulateVCache(struct vcache *avc) |
| 72 | { |
| 73 | AFSTOV(avc)->v_mount = afs_globalVFS; |
| 74 | vSetType(avc, VREG); |
| 75 | } |
| 76 | |