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)
23 struct hlist_node *cur, *head;
25 struct list_head *cur, *head;
28 /* First, see if we can evict the inode from the dcache */
29 if (defersleep && avc != afs_globalVp && VREFCOUNT(avc) > 1 && avc->opens == 0) {
31 ReleaseWriteLock(&afs_xvcache);
34 #if defined(HAVE_DCACHE_LOCK)
35 spin_lock(&dcache_lock);
36 head = &inode->i_dentry;
40 while ((cur = cur->next) != head) {
41 dentry = list_entry(cur, struct dentry, d_alias);
43 if (d_unhashed(dentry))
47 spin_unlock(&dcache_lock);
48 if (d_invalidate(dentry) == -EBUSY) {
50 /* perhaps lock and try to continue? (use cur as head?) */
54 spin_lock(&dcache_lock);
57 spin_unlock(&dcache_lock);
58 #else /* HAVE_DCACHE_LOCK */
59 spin_lock(&inode->i_lock);
60 #if defined(D_ALIAS_IS_HLIST)
61 head = inode->i_dentry.first;
63 head = &inode->i_dentry;
68 while ((cur = cur->next) != head) {
69 #if defined(D_ALIAS_IS_HLIST)
70 dentry = hlist_entry(cur, struct dentry, d_alias);
72 dentry = list_entry(cur, struct dentry, d_alias);
75 spin_lock(&dentry->d_lock);
76 if (d_unhashed(dentry)) {
77 spin_unlock(&dentry->d_lock);
80 spin_unlock(&dentry->d_lock);
83 spin_unlock(&inode->i_lock);
84 if (d_invalidate(dentry) == -EBUSY) {
86 /* perhaps lock and try to continue? (use cur as head?) */
90 spin_lock(&inode->i_lock);
93 spin_unlock(&inode->i_lock);
94 #endif /* HAVE_DCACHE_LOCK */
97 ObtainWriteLock(&afs_xvcache, 733);
100 /* See if we can evict it from the VLRUQ */
101 if (VREFCOUNT_GT(avc,0) && !VREFCOUNT_GT(avc,1) && avc->opens == 0
102 && (avc->f.states & CUnlinkedDel) == 0) {
103 int didsleep = *slept;
105 code = afs_FlushVCache(avc, slept);
106 /* flushvcache wipes slept; restore slept if we did before */
124 ip = new_inode(afs_globalVFS);
126 osi_Panic("afs_NewVCache: no more inodes");
128 #if defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)
131 tvc = afs_osi_Alloc(sizeof(struct vcache));
132 ip->u.generic_ip = tvc;
140 osi_PrePopulateVCache(struct vcache *avc) {
142 memset(&(avc->f), 0, sizeof(struct fvcache));
147 osi_AttachVnode(struct vcache *avc, int seq) { /* Nada */ }
150 osi_PostPopulateVCache(struct vcache *avc) {