rx: Remove RX_CALL_BUSY
[openafs.git] / src / WINNT / afsd / cm_eacces.h
1 /*
2  * Copyright (c) 2012 Your File System, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * - Redistributions of source code must retain the above copyright notice,
9  *   this list of conditions and the following disclaimer.
10  * - Redistributions in binary form must reproduce the above copyright notice,
11  *   this list of conditions and the following disclaimer in the documentation
12  *   and/or other materials provided with the distribution.
13  * - Neither the name of Secure Endpoints Inc. nor the names of its contributors
14  *   may be used to endorse or promote products derived from this software without
15  *   specific prior written permission from Secure Endpoints, Inc. and
16  *   Your File System, Inc.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
22  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #ifndef _CM_EACCES_H_
32 #define _CM_EACCES_H_
33
34 #include <osi.h>
35 #include "cm_scache.h"
36
37 #define CM_EACCES_MAGIC    ('E' | 'A' <<8 | 'C'<<16 | 'C'<<24)
38
39 /*
40  * Structure to hold EACCES error info for FID,User pairs
41  */
42
43 typedef struct cm_eacces {
44     struct osi_queue q;        /* fid hash table or free list */
45     afs_uint32  magic;
46     struct osi_queue parentq;
47     struct osi_queue userq;
48     cm_fid_t    fid;
49     cm_fid_t    parentFid;
50     cm_user_t  *userp;
51     time_t      errorTime;
52 } cm_eacces_t;
53
54 #define parentq_to_cm_eacces_t(q) ((q) ? (cm_eacces_t *)((char *) (q) - offsetof(cm_eacces_t, parentq)) : NULL)
55 #define userq_to_cm_eacces_t(q) ((q) ? (cm_eacces_t *)((char *) (q) - offsetof(cm_eacces_t, userq)) : NULL)
56
57 #define CM_EACCES_FID_HASH(fidp) (opr_jhash(&(fidp)->cell, 4, 0) & (cm_eaccesFidHashTableSize - 1))
58
59 #define CM_EACCES_PARENT_HASH(fidp) (opr_jhash(&(fidp)->cell, 4, 0) & (cm_eaccesParentHashTableSize - 1))
60
61 #define CM_EACCES_USER_HASH(userp) (opr_jhash((const uint32_t *)&userp, sizeof(cm_user_t *)/4, 0) & (cm_eaccesUserHashTableSize - 1))
62
63 extern void cm_EAccesInitCache(void);
64
65 extern cm_eacces_t * cm_EAccesFindEntry(cm_user_t* userp, cm_fid_t *fidp);
66
67 extern afs_uint32 cm_EAccesAddEntry(cm_user_t* userp, cm_fid_t *fidp, cm_fid_t *parentFidp);
68
69 extern void cm_EAccesClearParentEntries(cm_fid_t *parentFip);
70
71 extern void cm_EAccesClearUserEntries(cm_user_t *userp, afs_uint32 CellID);
72
73 extern void cm_EAccesClearOutdatedEntries(void);
74
75
76 /*
77  * The EACCES cache works by storing EACCES events by the FID and User
78  * for which the event occurred, when it occurred and the FID of the parent
79  * directory.  By definition, the parent FID of a volume root directory
80  * is itself.
81  *
82  * Entries are removed from the cache under the following circumstances:
83  *  1. When the parent FID's callback expires or is replaced.
84  *  2. When the parent FID's cm_scache object is recycled.
85  *  3. When the user's tokens expire or are replaced.
86  *
87  * Entries are not removed when the FID's cm_scache object is recycled.
88  */
89 #endif /* _CM_EACCES_H_ */