hpux11i-20030310
[openafs.git] / src / afs / VNOPS / afs_vnop_attrs.c
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 /*
11  * afs_vnop_attrs.c - setattr and getattr vnodeops
12  *
13  * Implements:
14  * afs_CopyOutAttrs
15  * afs_getattr
16  * afs_VAttrToAS
17  * afs_setattr
18  *
19  */
20
21 #include <afsconfig.h>
22 #include "afs/param.h"
23
24 RCSID("$Header$");
25
26 #include "afs/sysincludes.h"    /* Standard vendor system headers */
27 #include "afsincludes.h"        /* Afs-based standard headers */
28 #include "afs/afs_stats.h" /* statistics */
29 #include "afs/afs_cbqueue.h"
30 #include "afs/nfsclient.h"
31 #include "afs/afs_osidnlc.h"
32
33 extern afs_rwlock_t afs_xcbhash;
34 struct afs_exporter *afs_nfsexporter;
35 extern struct vcache *afs_globalVp;
36 #if defined(AFS_HPUX110_ENV)
37 extern struct vfs *afs_globalVFS;
38 #endif
39
40 /* copy out attributes from cache entry */
41 int afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs)
42 {
43     register struct volume *tvp;
44     register struct cell *tcell;
45     int fakedir = 0;
46
47     AFS_STATCNT(afs_CopyOutAttrs);
48     if (afs_fakestat_enable && avc->mvstat == 1)
49         fakedir = 1;
50 #if     defined(AFS_MACH_ENV )
51     attrs->va_mode = fakedir ? VDIR | 0755 : vType(avc) | (avc->m.Mode&~VFMT);
52 #else /* AFS_MACH_ENV */
53     attrs->va_type = fakedir ? VDIR : vType(avc);
54 #if defined(AFS_SGI_ENV) || defined(AFS_AIX32_ENV) || defined(AFS_SUN5_ENV)
55     attrs->va_mode = fakedir ? 0755 : (mode_t)(avc->m.Mode & 0xffff);
56 #else
57     attrs->va_mode = fakedir ? VDIR | 0755 : avc->m.Mode;
58 #endif
59 #endif /* AFS_MACH_ENV */
60
61     if (avc->m.Mode & (VSUID|VSGID)) {
62         /* setuid or setgid, make sure we're allowed to run them from this cell */
63         tcell = afs_GetCell(avc->fid.Cell, 0);
64         if (tcell && (tcell->states & CNoSUID))
65             attrs->va_mode &= ~(VSUID|VSGID);
66     }
67     attrs->va_uid = fakedir ? 0 : avc->m.Owner;
68     attrs->va_gid = fakedir ? 0 : avc->m.Group;   /* yeah! */
69 #if     defined(AFS_SUN56_ENV)
70     attrs->va_fsid = avc->v.v_vfsp->vfs_fsid.val[0];
71 #else
72 #ifdef  AFS_SUN5_ENV
73     /* XXX We try making this match the vfs's dev field  XXX */
74     attrs->va_fsid = 1;
75 #else
76 #ifdef AFS_OSF_ENV
77     attrs->va_fsid = avc->v.v_mount->m_stat.f_fsid.val[0]; 
78 #else
79     attrs->va_fsid = 1;
80 #endif
81 #endif
82 #endif /* AFS_SUN56_ENV */
83     if (avc->mvstat == 2) {
84         tvp = afs_GetVolume(&avc->fid, 0, READ_LOCK);
85         /* The mount point's vnode. */
86         if (tvp) {
87             attrs->va_nodeid =
88                 tvp->mtpoint.Fid.Vnode + (tvp->mtpoint.Fid.Volume << 16);
89             if (FidCmp(&afs_rootFid, &avc->fid) && !attrs->va_nodeid)
90                 attrs->va_nodeid = 2;
91             afs_PutVolume(tvp, READ_LOCK);
92         }
93         else attrs->va_nodeid = 2;
94     }
95     else attrs->va_nodeid = avc->fid.Fid.Vnode + (avc->fid.Fid.Volume << 16);
96     attrs->va_nodeid &= 0x7fffffff;     /* Saber C hates negative inode #s! */
97     attrs->va_nlink = fakedir ? 100 : avc->m.LinkCount;
98     attrs->va_size = fakedir ? 4096 : avc->m.Length;
99     attrs->va_atime.tv_sec = attrs->va_mtime.tv_sec = attrs->va_ctime.tv_sec =
100         fakedir ? 0 : (int)avc->m.Date;
101     /* set microseconds to be dataversion # so that we approximate NFS-style
102      * use of mtime as a dataversion #.  We take it mod 512K because
103      * microseconds *must* be less than a million, and 512K is the biggest
104      * power of 2 less than such.  DataVersions are typically pretty small
105      * anyway, so the difference between 512K and 1000000 shouldn't matter
106      * much, and "&" is a lot faster than "%".
107      */
108 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
109     /* nfs on these systems puts an 0 in nsec and stores the nfs usec (aka 
110        dataversion) in va_gen */
111
112     attrs->va_atime.tv_nsec = attrs->va_mtime.tv_nsec =
113         attrs->va_ctime.tv_nsec = 0;
114     attrs->va_gen = hgetlo(avc->m.DataVersion);
115 #elif defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_OBSD_ENV)
116     attrs->va_atime.tv_nsec = attrs->va_mtime.tv_nsec =
117         attrs->va_ctime.tv_nsec = (hgetlo(avc->m.DataVersion) & 0x7ffff) * 1000;
118 #else
119     attrs->va_atime.tv_usec = attrs->va_mtime.tv_usec =
120         attrs->va_ctime.tv_usec = (hgetlo(avc->m.DataVersion) & 0x7ffff);
121 #endif
122 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) || defined(AFS_OSF_ENV)
123     attrs->va_flags = 0;
124 #endif
125 #if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV)
126     attrs->va_blksize = PAGESIZE;               /* XXX Was 8192 XXX */
127 #else
128     attrs->va_blocksize = PAGESIZE;             /* XXX Was 8192 XXX */
129 #endif
130 #ifdef AFS_DEC_ENV
131     /* Have to use real device #s in Ultrix, since that's how FS type is
132      * encoded.  If rdev doesn't match Ultrix equivalent of statfs's rdev, then
133      * "df ." doesn't work.
134      */
135     if (afs_globalVFS && afs_globalVFS->vfs_data)
136         attrs->va_rdev = ((struct mount *)(afs_globalVFS->vfs_data))->m_dev;
137     else
138         attrs->va_rdev = 1;     /* better than nothing */
139 #else 
140     attrs->va_rdev = 1;
141 #endif
142 #if defined(AFS_HPUX110_ENV)
143         if (afs_globalVFS) attrs->va_fstype = afs_globalVFS->vfs_mtype;
144 #endif
145
146     /*
147      * Below return 0 (and not 1) blocks if the file is zero length. This conforms
148      * better with the other filesystems that do return 0.      
149      */
150 #if !defined(AFS_OSF_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV)
151 #if !defined(AFS_HPUX_ENV)
152 #ifdef  AFS_SUN5_ENV
153     attrs->va_nblocks = (attrs->va_size? ((attrs->va_size + 1023)>>10) << 1 : 0);
154 #elif defined(AFS_SGI_ENV)
155     attrs->va_blocks = BTOBB(attrs->va_size);
156 #else
157     attrs->va_blocks = (attrs->va_size? ((attrs->va_size + 1023)>>10) << 1 : 0);
158 #endif
159 #else /* !defined(AFS_HPUX_ENV) */
160     attrs->va_blocks = (attrs->va_size? ((attrs->va_size + 1023)>>10) : 0);
161 #endif /* !defined(AFS_HPUX_ENV) */
162 #else   /* ! AFS_OSF_ENV && !AFS_DARWIN_ENV && !AFS_XBSD_ENV */
163     attrs->va_bytes = (attrs->va_size? (attrs->va_size + 1023) : 1024);
164 #ifdef  va_bytes_rsv
165     attrs->va_bytes_rsv = -1;
166 #endif
167 #endif  /* ! AFS_OSF_ENV && !AFS_DARWIN_ENV && !AFS_XBSD_ENV */
168
169 #ifdef AFS_LINUX22_ENV
170     /* And linux has its own stash as well. */
171     vattr2inode(AFSTOV(avc), attrs);
172 #endif
173 #ifdef notdef
174 #ifdef AFS_AIX51_ENV
175     afs_Trace2(afs_iclSetp, CM_TRACE_STATACLX, 
176                 ICL_TYPE_POINTER, attrs->va_acl, 
177                 ICL_TYPE_INT32, attrs->va_aclsiz);
178     if (attrs->va_acl && attrs->va_aclsiz >= 12) {
179         struct acl *ap;
180
181         ap = (struct acl *) attrs->va_acl;
182         ap->acl_len = 8;
183         ap->acl_mode = ACL_MODE;
184         ap->acl_rsvd = 0;
185         ap->u_access = 7;
186     }
187     /* temporary fix ? */
188     attrs->va_aclsiz = 1;
189 #endif
190 #endif
191     return 0;
192 }
193
194
195
196 #if     defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
197 int afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, int flags, struct AFS_UCRED *acred)
198 #else
199 int afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, struct AFS_UCRED *acred)
200 #endif
201 {
202     afs_int32 code;
203     struct vrequest treq;
204     extern struct unixuser *afs_FindUser();
205     struct unixuser *au;
206     int inited = 0;
207     OSI_VC_CONVERT(avc)
208
209     AFS_STATCNT(afs_getattr);
210     afs_Trace2(afs_iclSetp, CM_TRACE_GETATTR, ICL_TYPE_POINTER, avc, 
211                ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length));
212
213     if (afs_fakestat_enable && avc->mvstat == 1) {
214         struct afs_fakestat_state fakestat;
215
216         code = afs_InitReq(&treq, acred);
217         if (code) return code;
218         afs_InitFakeStat(&fakestat);
219         code = afs_TryEvalFakeStat(&avc, &fakestat, &treq);
220         if (code) {
221             afs_PutFakeStat(&fakestat);
222             return code;
223         }
224
225         code = afs_CopyOutAttrs(avc, attrs);
226         afs_PutFakeStat(&fakestat);
227         return code;
228     }
229
230 #if defined(AFS_SUN5_ENV)
231     if (flags & ATTR_HINT) {
232        code = afs_CopyOutAttrs(avc, attrs);
233        return code;
234     }
235 #endif
236 #if defined(AFS_DARWIN_ENV)
237     if (avc->states & CUBCinit) {
238        code = afs_CopyOutAttrs(avc, attrs);
239        return code;
240     }
241 #endif
242
243 #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
244     afs_BozonLock(&avc->pvnLock, avc);
245 #endif
246
247     if (afs_shuttingdown) return EIO;
248
249     if (!(avc->states & CStatd)) {
250       if (!(code = afs_InitReq(&treq, acred))) {
251         code = afs_VerifyVCache2(avc, &treq);
252         inited = 1;
253       }
254     }
255     else code = 0;
256
257 #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
258     if (code == 0) osi_FlushPages(avc, acred);
259     afs_BozonUnlock(&avc->pvnLock, avc);
260 #endif
261
262
263     if (code == 0) {
264         osi_FlushText(avc); /* only needed to flush text if text locked last time */
265         code = afs_CopyOutAttrs(avc, attrs);
266
267         if (afs_nfsexporter) {
268           if (!inited) {
269             if ((code = afs_InitReq(&treq, acred)))
270               return code;
271              inited = 1;
272           }
273           if (AFS_NFSXLATORREQ(acred)) {
274               if ((vType(avc) != VDIR) &&
275                   !afs_AccessOK(avc, PRSFS_READ, &treq,
276                                 CHECK_MODE_BITS|CMB_ALLOW_EXEC_AS_READ)) {
277                   return EACCES;
278               }
279               if (avc->mvstat == 2) {
280 #if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
281                   attrs->va_mtime.tv_nsec += ((++avc->xlatordv) * 1000); 
282 #else
283                   attrs->va_mtime.tv_usec += ++avc->xlatordv; 
284 #endif
285               }
286           }
287           if ((au = afs_FindUser(treq.uid, -1, READ_LOCK))) {
288             register struct afs_exporter *exporter = au->exporter;
289
290             if (exporter && !(afs_nfsexporter->exp_states & EXP_UNIXMODE)) {
291                 unsigned int ubits;
292                 /*
293                  *  If the remote user wishes to enforce default Unix mode semantics,
294                  *  like in the nfs exporter case, we OR in the user bits
295                  *  into the group and other bits. We need to do this
296                  *  because there is no RFS_ACCESS call and thus nfs
297                  *  clients implement nfs_access by interpreting the 
298                  *  mode bits in the traditional way, which of course
299                  *  loses with afs.
300                  */
301                 ubits = (attrs->va_mode & 0700) >> 6;
302                 attrs->va_mode = attrs->va_mode | ubits | (ubits << 3);
303                 /* If it's the root of AFS, replace the inode number with the
304                  * inode number of the mounted on directory; otherwise this 
305                  * confuses getwd()... */
306 #ifdef AFS_LINUX22_ENV
307                 if (avc == afs_globalVp) {
308                     struct inode *ip = avc->v.i_sb->s_root->d_inode;
309                     attrs->va_nodeid = ip->i_ino;
310                 }
311 #else
312                 if (AFSTOV(avc)->v_flag & VROOT) {
313                     struct vnode *vp = AFSTOV(avc);
314
315                     vp = vp->v_vfsp->vfs_vnodecovered;
316                     if (vp) {   /* Ignore weird failures */
317 #ifdef AFS_SGI62_ENV
318                         attrs->va_nodeid = VnodeToIno(vp);
319 #else
320                         struct inode *ip;
321                         
322                         ip = (struct inode *) VTOI(vp);
323                         if (ip) /* Ignore weird failures */
324                             attrs->va_nodeid = ip->i_number;
325 #endif
326                     }
327                 }
328 #endif /* AFS_LINUX22_ENV */
329               }
330             afs_PutUser(au, READ_LOCK);
331           }
332         }
333     }
334     if (!code)
335       return 0;
336     code = afs_CheckCode(code, &treq, 14);
337     return code;
338 }
339
340 /* convert a Unix request into a status store request */
341 int afs_VAttrToAS(register struct vcache *avc, register struct vattr *av, 
342         register struct AFSStoreStatus *as)
343 {
344     register int mask;
345     mask = 0;
346     AFS_STATCNT(afs_VAttrToAS);
347 #if     defined(AFS_AIX_ENV)
348 /* Boy, was this machine dependent bogosity hard to swallow????.... */
349     if (av->va_mode != -1) {
350 #else
351 #if     defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
352     if (av->va_mask & AT_MODE) {
353 #else
354     if (av->va_mode != ((unsigned short)-1)) {
355 #endif
356 #endif
357         mask |= AFS_SETMODE;
358         as->UnixModeBits = av->va_mode & 0xffff;
359         if (avc->states & CForeign) {
360             ObtainWriteLock(&avc->lock,127);
361             afs_FreeAllAxs(&(avc->Access));
362             ReleaseWriteLock(&avc->lock);
363         }
364     }
365
366 #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
367     if (av->va_mask & AT_GID) {
368 #else
369 #if (defined(AFS_HPUX_ENV) || defined(AFS_SUN_ENV))
370 #if     defined(AFS_HPUX102_ENV)
371     if (av->va_gid != GID_NO_CHANGE) {
372 #else
373     if (av->va_gid != ((unsigned short)-1)) {
374 #endif
375 #else
376     if (av->va_gid != -1) {
377 #endif
378 #endif /* AFS_SUN5_ENV */
379         mask |= AFS_SETGROUP;
380         as->Group = av->va_gid;
381     }
382
383 #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
384     if (av->va_mask & AT_UID) {
385 #else
386 #if (defined(AFS_HPUX_ENV) || defined(AFS_SUN_ENV))
387 #if     defined(AFS_HPUX102_ENV)
388     if (av->va_uid != UID_NO_CHANGE) {
389 #else
390     if (av->va_uid != ((unsigned short)-1)) {
391 #endif
392 #else
393     if (av->va_uid != -1) {
394 #endif
395 #endif /* AFS_SUN5_ENV */
396         mask |= AFS_SETOWNER;
397         as->Owner = av->va_uid;
398     }
399 #if     defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
400     if (av->va_mask & AT_MTIME) {
401 #else
402     if (av->va_mtime.tv_sec != -1) {
403 #endif
404         mask |= AFS_SETMODTIME;
405 #ifndef AFS_SGI_ENV
406 #if     defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
407         if (av->va_mtime.tv_nsec == -1)
408 #else
409         if (av->va_mtime.tv_usec == -1)
410 #endif
411             as->ClientModTime = osi_Time();     /* special Sys V compat hack for Suns */
412         else
413 #endif
414             as->ClientModTime = av->va_mtime.tv_sec;
415     }
416     as->Mask = mask;
417     return 0;
418 }
419
420 /* We don't set CDirty bit in avc->states because setattr calls WriteVCache
421  * synchronously, therefore, it's not needed.
422  */
423 #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
424 int afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, int flags, struct AFS_UCRED *acred)
425 #else
426 int afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, struct AFS_UCRED *acred)
427 #endif
428 {
429     struct vrequest treq;
430     struct AFSStoreStatus astat;
431     register afs_int32 code;
432     struct afs_fakestat_state fakestate;
433     OSI_VC_CONVERT(avc)
434
435     AFS_STATCNT(afs_setattr);
436     afs_Trace2(afs_iclSetp, CM_TRACE_SETATTR, ICL_TYPE_POINTER, avc, 
437                ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length));
438     if ((code = afs_InitReq(&treq, acred))) return code;
439  
440     afs_InitFakeStat(&fakestate);
441     code = afs_EvalFakeStat(&avc, &fakestate, &treq);
442     if (code)
443         goto done;
444
445     if (avc->states & CRO) {
446         code=EROFS;
447         goto done;
448     }
449 #if defined(AFS_SGI_ENV)
450     /* ignore ATTR_LAZY calls - they are really only for keeping
451      * the access/mtime of mmaped files up to date
452      */
453     if (flags & ATTR_LAZY)
454         goto done;
455 #endif
456 #ifndef AFS_DEC_ENV
457     /* if file size has changed, we need write access, otherwise (e.g.
458      * chmod) give it a shot; if it fails, we'll discard the status
459      * info.
460      *
461      * Note that Ultrix actually defines ftruncate of a file you have open to
462      * be O.K., and does the proper access checks itself in the truncate
463      * path (unlike BSD or SUNOS), so we skip this check for Ultrix.
464      *
465      */
466 #if     defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
467     if (attrs->va_mask & AT_SIZE) {
468 #else
469 #ifdef  AFS_OSF_ENV
470     if (attrs->va_size != VNOVAL) {
471 #else
472 #ifdef  AFS_AIX41_ENV
473     if (attrs->va_size != -1) {
474 #else
475     if (attrs->va_size != ~0) {
476 #endif
477 #endif
478 #endif
479         if (!afs_AccessOK(avc, PRSFS_WRITE, &treq, DONT_CHECK_MODE_BITS)) {
480             code = EACCES;
481             goto done;
482         }
483     }
484 #endif
485
486     afs_VAttrToAS(avc, attrs, &astat);  /* interpret request */
487     code = 0;
488 #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
489     afs_BozonLock(&avc->pvnLock, avc);
490 #endif
491 #if     defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
492     if (AFS_NFSXLATORREQ(acred)) {
493         avc->execsOrWriters++;
494     }
495 #endif
496
497 #if defined(AFS_SGI_ENV)
498     AFS_RWLOCK((vnode_t *)avc, VRWLOCK_WRITE);
499 #endif
500 #if     defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
501     if (attrs->va_mask & AT_SIZE) {
502 #else
503 #if     defined(AFS_OSF_ENV)
504     if (attrs->va_size != VNOVAL) {
505 #else   /* AFS_OSF_ENV */
506     if (attrs->va_size != -1) {
507 #endif
508 #endif
509         afs_size_t tsize = attrs->va_size;
510         ObtainWriteLock(&avc->lock,128);
511         avc->states |= CDirty;
512         code = afs_TruncateAllSegments(avc, tsize, &treq, acred);
513         /* if date not explicitly set by this call, set it ourselves, since we
514          * changed the data */
515         if (!(astat.Mask & AFS_SETMODTIME)) {
516             astat.Mask |= AFS_SETMODTIME;
517             astat.ClientModTime = osi_Time();
518         }
519         if (code == 0) {
520           if ( ( (avc->execsOrWriters <= 0 ) && (avc->states & CCreating) == 0)
521                 || (  avc->execsOrWriters == 1 && AFS_NFSXLATORREQ(acred)) ) {
522             code = afs_StoreAllSegments(avc, &treq, AFS_ASYNC);
523             if (!code)
524               avc->states &= ~CDirty;
525           }
526         } else
527           avc->states &= ~CDirty;
528
529         ReleaseWriteLock(&avc->lock);
530         hzero(avc->flushDV);
531         osi_FlushText(avc);     /* do this after releasing all locks */
532 #ifdef AFS_DEC_ENV
533         /* in case we changed the size here, propagate it to gp->g_size */
534         afs_gfshack((struct gnode *)avc);
535 #endif
536     }
537     if (code == 0) {
538         ObtainSharedLock(&avc->lock,16);        /* lock entry */
539         code = afs_WriteVCache(avc, &astat, &treq);    /* send request */
540         ReleaseSharedLock(&avc->lock);  /* release lock */
541     }
542     if (code) {
543        ObtainWriteLock(&afs_xcbhash, 487);
544        afs_DequeueCallback(avc);
545        avc->states &= ~CStatd;      
546        ReleaseWriteLock(&afs_xcbhash);
547        if (avc->fid.Fid.Vnode & 1 || (vType(avc) == VDIR))
548            osi_dnlc_purgedp(avc);
549        /* error?  erase any changes we made to vcache entry */
550      }
551
552 #if     defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
553     if (AFS_NFSXLATORREQ(acred)) {
554         avc->execsOrWriters--;
555     }
556 #endif
557 #if defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN5_ENV)
558     afs_BozonUnlock(&avc->pvnLock, avc);
559 #endif
560 #if defined(AFS_SGI_ENV)
561     AFS_RWUNLOCK((vnode_t *)avc, VRWLOCK_WRITE);
562 #endif
563 done:
564     afs_PutFakeStat(&fakestate);
565     code = afs_CheckCode(code, &treq, 15);
566     return code;
567 }