2 * Copyright (c) 2002 Red Hat, Inc. All rights reserved.
4 * This software may be freely redistributed under the terms of the
5 * GNU General Public License.
7 * You should have received a copy of the GNU General Public License
8 * along with this program; if not, write to the Free Software
9 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
11 * Authors: David Woodhouse <dwmw2@cambridge.redhat.com>
12 * David Howells <dhowells@redhat.com>
16 #include <linux/kernel.h>
17 #include <linux/module.h>
18 #include <linux/init.h>
22 #include "cmservice.h"
25 * allow the fileserver to request callback state (re-)initialisation
27 int SRXAFSCM_InitCallBackState(struct afs_server
*server
)
29 struct list_head callbacks
;
33 INIT_LIST_HEAD(&callbacks
);
35 /* transfer the callback list from the server to a temp holding area */
36 spin_lock(&server
->cb_lock
);
38 list_add(&callbacks
, &server
->cb_promises
);
39 list_del_init(&server
->cb_promises
);
41 /* munch our way through the list, grabbing the inode, dropping all the
42 * locks and regetting them in the right order
44 while (!list_empty(&callbacks
)) {
45 struct afs_vnode
*vnode
;
48 vnode
= list_entry(callbacks
.next
, struct afs_vnode
, cb_link
);
49 list_del_init(&vnode
->cb_link
);
51 /* try and grab the inode - may fail */
52 inode
= igrab(AFS_VNODE_TO_I(vnode
));
56 spin_unlock(&server
->cb_lock
);
57 spin_lock(&vnode
->lock
);
59 if (vnode
->cb_server
== server
) {
60 vnode
->cb_server
= NULL
;
61 afs_kafstimod_del_timer(&vnode
->cb_timeout
);
62 spin_lock(&afs_cb_hash_lock
);
63 list_del_init(&vnode
->cb_hash_link
);
64 spin_unlock(&afs_cb_hash_lock
);
68 spin_unlock(&vnode
->lock
);
71 afs_put_server(server
);
73 spin_lock(&server
->cb_lock
);
77 spin_unlock(&server
->cb_lock
);
84 * allow the fileserver to break callback promises
86 int SRXAFSCM_CallBack(struct afs_server
*server
, size_t count
,
87 struct afs_callback callbacks
[])
89 _enter("%p,%u,", server
, count
);
91 for (; count
> 0; callbacks
++, count
--) {
92 struct afs_vnode
*vnode
= NULL
;
93 struct inode
*inode
= NULL
;
96 _debug("- Fid { vl=%08x n=%u u=%u } CB { v=%u x=%u t=%u }",
99 callbacks
->fid
.unique
,
105 /* find the inode for this fid */
106 spin_lock(&afs_cb_hash_lock
);
108 list_for_each_entry(vnode
,
109 &afs_cb_hash(server
, &callbacks
->fid
),
111 if (memcmp(&vnode
->fid
, &callbacks
->fid
,
112 sizeof(struct afs_fid
)) != 0)
115 /* right vnode, but is it same server? */
116 if (vnode
->cb_server
!= server
)
119 /* try and nail the inode down */
120 inode
= igrab(AFS_VNODE_TO_I(vnode
));
124 spin_unlock(&afs_cb_hash_lock
);
127 /* we've found the record for this vnode */
128 spin_lock(&vnode
->lock
);
129 if (vnode
->cb_server
== server
) {
130 /* the callback _is_ on the calling server */
131 vnode
->cb_server
= NULL
;
134 afs_kafstimod_del_timer(&vnode
->cb_timeout
);
135 vnode
->flags
|= AFS_VNODE_CHANGED
;
137 spin_lock(&server
->cb_lock
);
138 list_del_init(&vnode
->cb_link
);
139 spin_unlock(&server
->cb_lock
);
141 spin_lock(&afs_cb_hash_lock
);
142 list_del_init(&vnode
->cb_hash_link
);
143 spin_unlock(&afs_cb_hash_lock
);
145 spin_unlock(&vnode
->lock
);
148 invalidate_remote_inode(inode
);
149 afs_put_server(server
);
160 * allow the fileserver to see if the cache manager is still alive
162 int SRXAFSCM_Probe(struct afs_server
*server
)
164 _debug("SRXAFSCM_Probe(%p)\n", server
);