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 */
16 #if defined(AFS_LINUX24_ENV)
17 # define afs_linux_lock_dcache() spin_lock(&dcache_lock)
18 # define afs_linux_unlock_dcache() spin_unlock(&dcache_lock)
20 # define afs_linux_lock_dcache()
21 # define afs_linux_unlock_dcache()
25 osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
27 struct dentry *dentry;
28 struct list_head *cur, *head;
30 /* First, see if we can evict the inode from the dcache */
31 if (defersleep && avc != afs_globalVp && VREFCOUNT(avc) > 1 && avc->opens == 0) {
33 ReleaseWriteLock(&afs_xvcache);
35 afs_linux_lock_dcache();
36 head = &(AFSTOV(avc))->i_dentry;
40 while ((cur = cur->next) != head) {
41 dentry = list_entry(cur, struct dentry, d_alias);
43 if (d_unhashed(dentry))
48 afs_linux_unlock_dcache();
50 if (d_invalidate(dentry) == -EBUSY) {
52 /* perhaps lock and try to continue? (use cur as head?) */
56 afs_linux_lock_dcache();
59 afs_linux_unlock_dcache();
62 ObtainWriteLock(&afs_xvcache, 733);
65 /* See if we can evict it from the VLRUQ */
66 if (VREFCOUNT_GT(avc,0) && !VREFCOUNT_GT(avc,1) && avc->opens == 0
67 && (avc->f.states & CUnlinkedDel) == 0) {
68 int didsleep = *slept;
70 code = afs_FlushVCache(avc, slept);
71 /* flushvcache wipes slept; restore slept if we did before */
89 ip = new_inode(afs_globalVFS);
91 osi_Panic("afs_NewVCache: no more inodes");
93 #if defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)
96 tvc = afs_osi_Alloc(sizeof(struct vcache));
97 osi_Assert(tvc != NULL);
98 ip->u.generic_ip = tvc;
105 /* XXX - This should probably be inline */
107 osi_PrePopulateVCache(struct vcache *avc) {
109 memset(&(avc->f), 0, sizeof(struct fvcache));
112 /* XXX - This should become inline, or a #define */
114 osi_AttachVnode(struct vcache *avc, int seq) { }
116 /* XXX - Again, inline or a #define */
118 osi_PostPopulateVCache(struct vcache *avc) {
123 osi_ResetRootVCache(afs_uint32 volid)
125 struct vrequest *treq = NULL;
131 afs_rootFid.Fid.Volume = volid;
132 afs_rootFid.Fid.Vnode = 1;
133 afs_rootFid.Fid.Unique = 1;
136 if (afs_CreateReq(&treq, credp))
138 vcp = afs_GetVCache(&afs_rootFid, treq, NULL, NULL);
141 afs_getattr(vcp, &vattr, credp);
142 afs_fill_inode(AFSTOV(vcp), &vattr);
144 dp = d_find_alias(AFSTOV(afs_globalVp));
145 spin_lock(&dcache_lock);
146 list_del_init(&dp->d_alias);
147 list_add(&dp->d_alias, &(AFSTOV(vcp)->i_dentry));
148 dp->d_inode = AFSTOV(vcp);
149 spin_unlock(&dcache_lock);
152 AFS_FAST_RELE(afs_globalVp);
156 afs_DestroyReq(treq);