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) {
20 struct dentry *dentry;
21 struct inode *inode = AFSTOV(avc);
22 struct list_head *cur, *head;
24 /* First, see if we can evict the inode from the dcache */
25 if (avc != afs_globalVp && VREFCOUNT(avc) > 1 && avc->opens == 0) {
27 ReleaseWriteLock(&afs_xvcache);
30 #if defined(HAVE_DCACHE_LOCK)
31 spin_lock(&dcache_lock);
32 head = &inode->i_dentry;
36 while ((cur = cur->next) != head) {
37 dentry = list_entry(cur, struct dentry, d_alias);
39 if (d_unhashed(dentry))
43 spin_unlock(&dcache_lock);
44 if (d_invalidate(dentry) == -EBUSY) {
46 /* perhaps lock and try to continue? (use cur as head?) */
50 spin_lock(&dcache_lock);
53 spin_unlock(&dcache_lock);
54 #else /* HAVE_DCACHE_LOCK */
55 spin_lock(&inode->i_lock);
56 head = &inode->i_dentry;
60 while ((cur = cur->next) != head) {
61 dentry = list_entry(cur, struct dentry, d_alias);
63 spin_lock(&dentry->d_lock);
64 if (d_unhashed(dentry)) {
65 spin_unlock(&dentry->d_lock);
68 spin_unlock(&dentry->d_lock);
71 spin_unlock(&inode->i_lock);
72 if (d_invalidate(dentry) == -EBUSY) {
74 /* perhaps lock and try to continue? (use cur as head?) */
78 spin_lock(&inode->i_lock);
81 spin_unlock(&inode->i_lock);
82 #endif /* HAVE_DCACHE_LOCK */
85 ObtainWriteLock(&afs_xvcache, 733);
88 /* See if we can evict it from the VLRUQ */
89 if (VREFCOUNT_GT(avc,0) && !VREFCOUNT_GT(avc,1) && avc->opens == 0
90 && (avc->f.states & CUnlinkedDel) == 0) {
91 int didsleep = *slept;
93 code = afs_FlushVCache(avc, slept);
94 /* flushvcache wipes slept; restore slept if we did before */
112 ip = new_inode(afs_globalVFS);
114 osi_Panic("afs_NewVCache: no more inodes");
116 #if defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)
119 tvc = afs_osi_Alloc(sizeof(struct vcache));
120 ip->u.generic_ip = tvc;
128 osi_PrePopulateVCache(struct vcache *avc) {
130 memset(&(avc->f), 0, sizeof(struct fvcache));
135 osi_AttachVnode(struct vcache *avc, int seq) { /* Nada */ }
138 osi_PostPopulateVCache(struct vcache *avc) {