2 * Copyright 2000, International Business Machines Corporation and others.
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
10 #include <afsconfig.h>
11 #include "afs/param.h"
13 #include "afs/sysincludes.h" /*Standard vendor system headers */
14 #include "afsincludes.h" /*AFS-based standard headers */
17 osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
20 struct dentry *dentry;
21 struct inode *inode = AFSTOV(avc);
22 #if defined(D_ALIAS_IS_HLIST) && !defined(HLIST_ITERATOR_NO_NODE)
26 /* First, see if we can evict the inode from the dcache */
27 if (defersleep && avc != afs_globalVp && VREFCOUNT(avc) > 1 && avc->opens == 0) {
29 ReleaseWriteLock(&afs_xvcache);
32 #if defined(HAVE_DCACHE_LOCK)
33 spin_lock(&dcache_lock);
36 list_for_each_entry(dentry, &inode->i_dentry, d_alias) {
37 if (d_unhashed(dentry))
41 spin_unlock(&dcache_lock);
42 if (d_invalidate(dentry) == -EBUSY) {
44 /* perhaps lock and try to continue? (use cur as head?) */
48 spin_lock(&dcache_lock);
51 spin_unlock(&dcache_lock);
52 #else /* HAVE_DCACHE_LOCK */
53 spin_lock(&inode->i_lock);
56 #if defined(D_ALIAS_IS_HLIST)
57 # if defined(HLIST_ITERATOR_NO_NODE)
58 hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) {
60 hlist_for_each_entry(dentry, p, &inode->i_dentry, d_alias) {
63 list_for_each_entry(dentry, &inode->i_dentry, d_alias) {
65 spin_lock(&dentry->d_lock);
66 if (d_unhashed(dentry)) {
67 spin_unlock(&dentry->d_lock);
70 spin_unlock(&dentry->d_lock);
73 spin_unlock(&inode->i_lock);
74 if (d_invalidate(dentry) == -EBUSY) {
76 /* perhaps lock and try to continue? (use cur as head?) */
80 spin_lock(&inode->i_lock);
83 spin_unlock(&inode->i_lock);
84 #endif /* HAVE_DCACHE_LOCK */
87 ObtainWriteLock(&afs_xvcache, 733);
90 /* See if we can evict it from the VLRUQ */
91 if (VREFCOUNT_GT(avc,0) && !VREFCOUNT_GT(avc,1) && avc->opens == 0
92 && (avc->f.states & CUnlinkedDel) == 0) {
93 int didsleep = *slept;
95 code = afs_FlushVCache(avc, slept);
96 /* flushvcache wipes slept; restore slept if we did before */
114 ip = new_inode(afs_globalVFS);
116 osi_Panic("afs_NewVCache: no more inodes");
118 #if defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)
121 tvc = afs_osi_Alloc(sizeof(struct vcache));
122 ip->u.generic_ip = tvc;
130 osi_PrePopulateVCache(struct vcache *avc) {
132 memset(&(avc->f), 0, sizeof(struct fvcache));
137 osi_AttachVnode(struct vcache *avc, int seq) { /* Nada */ }
140 osi_PostPopulateVCache(struct vcache *avc) {