~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/afs/cmservice.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/afs/cmservice.c (Version linux-6.11-rc3) and /fs/afs/cmservice.c (Version linux-5.4.281)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /* AFS Cache Manager Service                        2 /* AFS Cache Manager Service
  3  *                                                  3  *
  4  * Copyright (C) 2002 Red Hat, Inc. All Rights      4  * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
  5  * Written by David Howells (dhowells@redhat.c      5  * Written by David Howells (dhowells@redhat.com)
  6  */                                                 6  */
  7                                                     7 
  8 #include <linux/module.h>                           8 #include <linux/module.h>
  9 #include <linux/init.h>                             9 #include <linux/init.h>
 10 #include <linux/slab.h>                            10 #include <linux/slab.h>
 11 #include <linux/sched.h>                           11 #include <linux/sched.h>
 12 #include <linux/ip.h>                              12 #include <linux/ip.h>
 13 #include "internal.h"                              13 #include "internal.h"
 14 #include "afs_cm.h"                                14 #include "afs_cm.h"
 15 #include "protocol_yfs.h"                          15 #include "protocol_yfs.h"
 16 #define RXRPC_TRACE_ONLY_DEFINE_ENUMS          << 
 17 #include <trace/events/rxrpc.h>                << 
 18                                                    16 
 19 static int afs_deliver_cb_init_call_back_state     17 static int afs_deliver_cb_init_call_back_state(struct afs_call *);
 20 static int afs_deliver_cb_init_call_back_state     18 static int afs_deliver_cb_init_call_back_state3(struct afs_call *);
 21 static int afs_deliver_cb_probe(struct afs_cal     19 static int afs_deliver_cb_probe(struct afs_call *);
 22 static int afs_deliver_cb_callback(struct afs_     20 static int afs_deliver_cb_callback(struct afs_call *);
 23 static int afs_deliver_cb_probe_uuid(struct af     21 static int afs_deliver_cb_probe_uuid(struct afs_call *);
 24 static int afs_deliver_cb_tell_me_about_yourse     22 static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *);
 25 static void afs_cm_destructor(struct afs_call      23 static void afs_cm_destructor(struct afs_call *);
 26 static void SRXAFSCB_CallBack(struct work_stru     24 static void SRXAFSCB_CallBack(struct work_struct *);
 27 static void SRXAFSCB_InitCallBackState(struct      25 static void SRXAFSCB_InitCallBackState(struct work_struct *);
 28 static void SRXAFSCB_Probe(struct work_struct      26 static void SRXAFSCB_Probe(struct work_struct *);
 29 static void SRXAFSCB_ProbeUuid(struct work_str     27 static void SRXAFSCB_ProbeUuid(struct work_struct *);
 30 static void SRXAFSCB_TellMeAboutYourself(struc     28 static void SRXAFSCB_TellMeAboutYourself(struct work_struct *);
 31                                                    29 
 32 static int afs_deliver_yfs_cb_callback(struct      30 static int afs_deliver_yfs_cb_callback(struct afs_call *);
 33                                                    31 
 34 /*                                                 32 /*
 35  * CB.CallBack operation type                      33  * CB.CallBack operation type
 36  */                                                34  */
 37 static const struct afs_call_type afs_SRXCBCal     35 static const struct afs_call_type afs_SRXCBCallBack = {
 38         .name           = "CB.CallBack",           36         .name           = "CB.CallBack",
 39         .deliver        = afs_deliver_cb_callb     37         .deliver        = afs_deliver_cb_callback,
 40         .destructor     = afs_cm_destructor,       38         .destructor     = afs_cm_destructor,
 41         .work           = SRXAFSCB_CallBack,       39         .work           = SRXAFSCB_CallBack,
 42 };                                                 40 };
 43                                                    41 
 44 /*                                                 42 /*
 45  * CB.InitCallBackState operation type             43  * CB.InitCallBackState operation type
 46  */                                                44  */
 47 static const struct afs_call_type afs_SRXCBIni     45 static const struct afs_call_type afs_SRXCBInitCallBackState = {
 48         .name           = "CB.InitCallBackStat     46         .name           = "CB.InitCallBackState",
 49         .deliver        = afs_deliver_cb_init_     47         .deliver        = afs_deliver_cb_init_call_back_state,
 50         .destructor     = afs_cm_destructor,       48         .destructor     = afs_cm_destructor,
 51         .work           = SRXAFSCB_InitCallBac     49         .work           = SRXAFSCB_InitCallBackState,
 52 };                                                 50 };
 53                                                    51 
 54 /*                                                 52 /*
 55  * CB.InitCallBackState3 operation type            53  * CB.InitCallBackState3 operation type
 56  */                                                54  */
 57 static const struct afs_call_type afs_SRXCBIni     55 static const struct afs_call_type afs_SRXCBInitCallBackState3 = {
 58         .name           = "CB.InitCallBackStat     56         .name           = "CB.InitCallBackState3",
 59         .deliver        = afs_deliver_cb_init_     57         .deliver        = afs_deliver_cb_init_call_back_state3,
 60         .destructor     = afs_cm_destructor,       58         .destructor     = afs_cm_destructor,
 61         .work           = SRXAFSCB_InitCallBac     59         .work           = SRXAFSCB_InitCallBackState,
 62 };                                                 60 };
 63                                                    61 
 64 /*                                                 62 /*
 65  * CB.Probe operation type                         63  * CB.Probe operation type
 66  */                                                64  */
 67 static const struct afs_call_type afs_SRXCBPro     65 static const struct afs_call_type afs_SRXCBProbe = {
 68         .name           = "CB.Probe",              66         .name           = "CB.Probe",
 69         .deliver        = afs_deliver_cb_probe     67         .deliver        = afs_deliver_cb_probe,
 70         .destructor     = afs_cm_destructor,       68         .destructor     = afs_cm_destructor,
 71         .work           = SRXAFSCB_Probe,          69         .work           = SRXAFSCB_Probe,
 72 };                                                 70 };
 73                                                    71 
 74 /*                                                 72 /*
 75  * CB.ProbeUuid operation type                     73  * CB.ProbeUuid operation type
 76  */                                                74  */
 77 static const struct afs_call_type afs_SRXCBPro     75 static const struct afs_call_type afs_SRXCBProbeUuid = {
 78         .name           = "CB.ProbeUuid",          76         .name           = "CB.ProbeUuid",
 79         .deliver        = afs_deliver_cb_probe     77         .deliver        = afs_deliver_cb_probe_uuid,
 80         .destructor     = afs_cm_destructor,       78         .destructor     = afs_cm_destructor,
 81         .work           = SRXAFSCB_ProbeUuid,      79         .work           = SRXAFSCB_ProbeUuid,
 82 };                                                 80 };
 83                                                    81 
 84 /*                                                 82 /*
 85  * CB.TellMeAboutYourself operation type           83  * CB.TellMeAboutYourself operation type
 86  */                                                84  */
 87 static const struct afs_call_type afs_SRXCBTel     85 static const struct afs_call_type afs_SRXCBTellMeAboutYourself = {
 88         .name           = "CB.TellMeAboutYours     86         .name           = "CB.TellMeAboutYourself",
 89         .deliver        = afs_deliver_cb_tell_     87         .deliver        = afs_deliver_cb_tell_me_about_yourself,
 90         .destructor     = afs_cm_destructor,       88         .destructor     = afs_cm_destructor,
 91         .work           = SRXAFSCB_TellMeAbout     89         .work           = SRXAFSCB_TellMeAboutYourself,
 92 };                                                 90 };
 93                                                    91 
 94 /*                                                 92 /*
 95  * YFS CB.CallBack operation type                  93  * YFS CB.CallBack operation type
 96  */                                                94  */
 97 static const struct afs_call_type afs_SRXYFSCB     95 static const struct afs_call_type afs_SRXYFSCB_CallBack = {
 98         .name           = "YFSCB.CallBack",        96         .name           = "YFSCB.CallBack",
 99         .deliver        = afs_deliver_yfs_cb_c     97         .deliver        = afs_deliver_yfs_cb_callback,
100         .destructor     = afs_cm_destructor,       98         .destructor     = afs_cm_destructor,
101         .work           = SRXAFSCB_CallBack,       99         .work           = SRXAFSCB_CallBack,
102 };                                                100 };
103                                                   101 
104 /*                                                102 /*
105  * route an incoming cache manager call           103  * route an incoming cache manager call
106  * - return T if supported, F if not              104  * - return T if supported, F if not
107  */                                               105  */
108 bool afs_cm_incoming_call(struct afs_call *cal    106 bool afs_cm_incoming_call(struct afs_call *call)
109 {                                                 107 {
110         _enter("{%u, CB.OP %u}", call->service    108         _enter("{%u, CB.OP %u}", call->service_id, call->operation_ID);
111                                                   109 
                                                   >> 110         call->epoch = rxrpc_kernel_get_epoch(call->net->socket, call->rxcall);
                                                   >> 111 
112         switch (call->operation_ID) {             112         switch (call->operation_ID) {
113         case CBCallBack:                          113         case CBCallBack:
114                 call->type = &afs_SRXCBCallBac    114                 call->type = &afs_SRXCBCallBack;
115                 return true;                      115                 return true;
116         case CBInitCallBackState:                 116         case CBInitCallBackState:
117                 call->type = &afs_SRXCBInitCal    117                 call->type = &afs_SRXCBInitCallBackState;
118                 return true;                      118                 return true;
119         case CBInitCallBackState3:                119         case CBInitCallBackState3:
120                 call->type = &afs_SRXCBInitCal    120                 call->type = &afs_SRXCBInitCallBackState3;
121                 return true;                      121                 return true;
122         case CBProbe:                             122         case CBProbe:
123                 call->type = &afs_SRXCBProbe;     123                 call->type = &afs_SRXCBProbe;
124                 return true;                      124                 return true;
125         case CBProbeUuid:                         125         case CBProbeUuid:
126                 call->type = &afs_SRXCBProbeUu    126                 call->type = &afs_SRXCBProbeUuid;
127                 return true;                      127                 return true;
128         case CBTellMeAboutYourself:               128         case CBTellMeAboutYourself:
129                 call->type = &afs_SRXCBTellMeA    129                 call->type = &afs_SRXCBTellMeAboutYourself;
130                 return true;                      130                 return true;
131         case YFSCBCallBack:                       131         case YFSCBCallBack:
132                 if (call->service_id != YFS_CM    132                 if (call->service_id != YFS_CM_SERVICE)
133                         return false;             133                         return false;
134                 call->type = &afs_SRXYFSCB_Cal    134                 call->type = &afs_SRXYFSCB_CallBack;
135                 return true;                      135                 return true;
136         default:                                  136         default:
137                 return false;                     137                 return false;
138         }                                         138         }
139 }                                                 139 }
140                                                   140 
141 /*                                                141 /*
                                                   >> 142  * Record a probe to the cache manager from a server.
                                                   >> 143  */
                                                   >> 144 static int afs_record_cm_probe(struct afs_call *call, struct afs_server *server)
                                                   >> 145 {
                                                   >> 146         _enter("");
                                                   >> 147 
                                                   >> 148         if (test_bit(AFS_SERVER_FL_HAVE_EPOCH, &server->flags) &&
                                                   >> 149             !test_bit(AFS_SERVER_FL_PROBING, &server->flags)) {
                                                   >> 150                 if (server->cm_epoch == call->epoch)
                                                   >> 151                         return 0;
                                                   >> 152 
                                                   >> 153                 if (!server->probe.said_rebooted) {
                                                   >> 154                         pr_notice("kAFS: FS rebooted %pU\n", &server->uuid);
                                                   >> 155                         server->probe.said_rebooted = true;
                                                   >> 156                 }
                                                   >> 157         }
                                                   >> 158 
                                                   >> 159         spin_lock(&server->probe_lock);
                                                   >> 160 
                                                   >> 161         if (!test_and_set_bit(AFS_SERVER_FL_HAVE_EPOCH, &server->flags)) {
                                                   >> 162                 server->cm_epoch = call->epoch;
                                                   >> 163                 server->probe.cm_epoch = call->epoch;
                                                   >> 164                 goto out;
                                                   >> 165         }
                                                   >> 166 
                                                   >> 167         if (server->probe.cm_probed &&
                                                   >> 168             call->epoch != server->probe.cm_epoch &&
                                                   >> 169             !server->probe.said_inconsistent) {
                                                   >> 170                 pr_notice("kAFS: FS endpoints inconsistent %pU\n",
                                                   >> 171                           &server->uuid);
                                                   >> 172                 server->probe.said_inconsistent = true;
                                                   >> 173         }
                                                   >> 174 
                                                   >> 175         if (!server->probe.cm_probed || call->epoch == server->cm_epoch)
                                                   >> 176                 server->probe.cm_epoch = server->cm_epoch;
                                                   >> 177 
                                                   >> 178 out:
                                                   >> 179         server->probe.cm_probed = true;
                                                   >> 180         spin_unlock(&server->probe_lock);
                                                   >> 181         return 0;
                                                   >> 182 }
                                                   >> 183 
                                                   >> 184 /*
142  * Find the server record by peer address and     185  * Find the server record by peer address and record a probe to the cache
143  * manager from a server.                         186  * manager from a server.
144  */                                               187  */
145 static int afs_find_cm_server_by_peer(struct a    188 static int afs_find_cm_server_by_peer(struct afs_call *call)
146 {                                                 189 {
147         struct sockaddr_rxrpc srx;                190         struct sockaddr_rxrpc srx;
148         struct afs_server *server;                191         struct afs_server *server;
149         struct rxrpc_peer *peer;               << 
150                                                   192 
151         peer = rxrpc_kernel_get_call_peer(call !! 193         rxrpc_kernel_get_peer(call->net->socket, call->rxcall, &srx);
152                                                   194 
153         server = afs_find_server(call->net, pe !! 195         server = afs_find_server(call->net, &srx);
154         if (!server) {                            196         if (!server) {
155                 trace_afs_cm_no_server(call, &    197                 trace_afs_cm_no_server(call, &srx);
156                 return 0;                         198                 return 0;
157         }                                         199         }
158                                                   200 
159         call->server = server;                    201         call->server = server;
160         return 0;                              !! 202         return afs_record_cm_probe(call, server);
161 }                                                 203 }
162                                                   204 
163 /*                                                205 /*
164  * Find the server record by server UUID and r    206  * Find the server record by server UUID and record a probe to the cache
165  * manager from a server.                         207  * manager from a server.
166  */                                               208  */
167 static int afs_find_cm_server_by_uuid(struct a    209 static int afs_find_cm_server_by_uuid(struct afs_call *call,
168                                       struct a    210                                       struct afs_uuid *uuid)
169 {                                                 211 {
170         struct afs_server *server;                212         struct afs_server *server;
171                                                   213 
172         rcu_read_lock();                          214         rcu_read_lock();
173         server = afs_find_server_by_uuid(call-    215         server = afs_find_server_by_uuid(call->net, call->request);
174         rcu_read_unlock();                        216         rcu_read_unlock();
175         if (!server) {                            217         if (!server) {
176                 trace_afs_cm_no_server_u(call,    218                 trace_afs_cm_no_server_u(call, call->request);
177                 return 0;                         219                 return 0;
178         }                                         220         }
179                                                   221 
180         call->server = server;                    222         call->server = server;
181         return 0;                              !! 223         return afs_record_cm_probe(call, server);
182 }                                                 224 }
183                                                   225 
184 /*                                                226 /*
185  * Clean up a cache manager call.                 227  * Clean up a cache manager call.
186  */                                               228  */
187 static void afs_cm_destructor(struct afs_call     229 static void afs_cm_destructor(struct afs_call *call)
188 {                                                 230 {
189         kfree(call->buffer);                      231         kfree(call->buffer);
190         call->buffer = NULL;                      232         call->buffer = NULL;
191 }                                                 233 }
192                                                   234 
193 /*                                                235 /*
194  * Abort a service call from within an action     236  * Abort a service call from within an action function.
195  */                                               237  */
196 static void afs_abort_service_call(struct afs_    238 static void afs_abort_service_call(struct afs_call *call, u32 abort_code, int error,
197                                    enum rxrpc_ !! 239                                    const char *why)
198 {                                                 240 {
199         rxrpc_kernel_abort_call(call->net->soc    241         rxrpc_kernel_abort_call(call->net->socket, call->rxcall,
200                                 abort_code, er    242                                 abort_code, error, why);
201         afs_set_call_complete(call, error, 0);    243         afs_set_call_complete(call, error, 0);
202 }                                                 244 }
203                                                   245 
204 /*                                                246 /*
205  * The server supplied a list of callbacks tha    247  * The server supplied a list of callbacks that it wanted to break.
206  */                                               248  */
207 static void SRXAFSCB_CallBack(struct work_stru    249 static void SRXAFSCB_CallBack(struct work_struct *work)
208 {                                                 250 {
209         struct afs_call *call = container_of(w    251         struct afs_call *call = container_of(work, struct afs_call, work);
210                                                   252 
211         _enter("");                               253         _enter("");
212                                                   254 
213         /* We need to break the callbacks befo    255         /* We need to break the callbacks before sending the reply as the
214          * server holds up change visibility t    256          * server holds up change visibility till it receives our reply so as
215          * to maintain cache coherency.           257          * to maintain cache coherency.
216          */                                       258          */
217         if (call->server) {                       259         if (call->server) {
218                 trace_afs_server(call->server- !! 260                 trace_afs_server(call->server, atomic_read(&call->server->usage),
219                                  refcount_read << 
220                                  atomic_read(& << 
221                                  afs_server_tr    261                                  afs_server_trace_callback);
222                 afs_break_callbacks(call->serv    262                 afs_break_callbacks(call->server, call->count, call->request);
223         }                                         263         }
224                                                   264 
225         afs_send_empty_reply(call);               265         afs_send_empty_reply(call);
226         afs_put_call(call);                       266         afs_put_call(call);
227         _leave("");                               267         _leave("");
228 }                                                 268 }
229                                                   269 
230 /*                                                270 /*
231  * deliver request data to a CB.CallBack call     271  * deliver request data to a CB.CallBack call
232  */                                               272  */
233 static int afs_deliver_cb_callback(struct afs_    273 static int afs_deliver_cb_callback(struct afs_call *call)
234 {                                                 274 {
235         struct afs_callback_break *cb;            275         struct afs_callback_break *cb;
236         __be32 *bp;                               276         __be32 *bp;
237         int ret, loop;                            277         int ret, loop;
238                                                   278 
239         _enter("{%u}", call->unmarshall);         279         _enter("{%u}", call->unmarshall);
240                                                   280 
241         switch (call->unmarshall) {               281         switch (call->unmarshall) {
242         case 0:                                   282         case 0:
243                 afs_extract_to_tmp(call);         283                 afs_extract_to_tmp(call);
244                 call->unmarshall++;               284                 call->unmarshall++;
245                                                   285 
246                 /* extract the FID array and i    286                 /* extract the FID array and its count in two steps */
247                 fallthrough;                   !! 287                 /* fall through */
248         case 1:                                   288         case 1:
249                 _debug("extract FID count");      289                 _debug("extract FID count");
250                 ret = afs_extract_data(call, t    290                 ret = afs_extract_data(call, true);
251                 if (ret < 0)                      291                 if (ret < 0)
252                         return ret;               292                         return ret;
253                                                   293 
254                 call->count = ntohl(call->tmp)    294                 call->count = ntohl(call->tmp);
255                 _debug("FID count: %u", call->    295                 _debug("FID count: %u", call->count);
256                 if (call->count > AFSCBMAX)       296                 if (call->count > AFSCBMAX)
257                         return afs_protocol_er !! 297                         return afs_protocol_error(call, -EBADMSG,
                                                   >> 298                                                   afs_eproto_cb_fid_count);
258                                                   299 
259                 call->buffer = kmalloc(array3_    300                 call->buffer = kmalloc(array3_size(call->count, 3, 4),
260                                        GFP_KER    301                                        GFP_KERNEL);
261                 if (!call->buffer)                302                 if (!call->buffer)
262                         return -ENOMEM;           303                         return -ENOMEM;
263                 afs_extract_to_buf(call, call-    304                 afs_extract_to_buf(call, call->count * 3 * 4);
264                 call->unmarshall++;               305                 call->unmarshall++;
265                                                   306 
266                 fallthrough;                   !! 307                 /* Fall through */
267         case 2:                                   308         case 2:
268                 _debug("extract FID array");      309                 _debug("extract FID array");
269                 ret = afs_extract_data(call, t    310                 ret = afs_extract_data(call, true);
270                 if (ret < 0)                      311                 if (ret < 0)
271                         return ret;               312                         return ret;
272                                                   313 
273                 _debug("unmarshall FID array")    314                 _debug("unmarshall FID array");
274                 call->request = kcalloc(call->    315                 call->request = kcalloc(call->count,
275                                         sizeof    316                                         sizeof(struct afs_callback_break),
276                                         GFP_KE    317                                         GFP_KERNEL);
277                 if (!call->request)               318                 if (!call->request)
278                         return -ENOMEM;           319                         return -ENOMEM;
279                                                   320 
280                 cb = call->request;               321                 cb = call->request;
281                 bp = call->buffer;                322                 bp = call->buffer;
282                 for (loop = call->count; loop     323                 for (loop = call->count; loop > 0; loop--, cb++) {
283                         cb->fid.vid     = ntoh    324                         cb->fid.vid     = ntohl(*bp++);
284                         cb->fid.vnode   = ntoh    325                         cb->fid.vnode   = ntohl(*bp++);
285                         cb->fid.unique  = ntoh    326                         cb->fid.unique  = ntohl(*bp++);
286                 }                                 327                 }
287                                                   328 
288                 afs_extract_to_tmp(call);         329                 afs_extract_to_tmp(call);
289                 call->unmarshall++;               330                 call->unmarshall++;
290                                                   331 
291                 /* extract the callback array     332                 /* extract the callback array and its count in two steps */
292                 fallthrough;                   !! 333                 /* fall through */
293         case 3:                                   334         case 3:
294                 _debug("extract CB count");       335                 _debug("extract CB count");
295                 ret = afs_extract_data(call, t    336                 ret = afs_extract_data(call, true);
296                 if (ret < 0)                      337                 if (ret < 0)
297                         return ret;               338                         return ret;
298                                                   339 
299                 call->count2 = ntohl(call->tmp    340                 call->count2 = ntohl(call->tmp);
300                 _debug("CB count: %u", call->c    341                 _debug("CB count: %u", call->count2);
301                 if (call->count2 != call->coun    342                 if (call->count2 != call->count && call->count2 != 0)
302                         return afs_protocol_er !! 343                         return afs_protocol_error(call, -EBADMSG,
303                 call->iter = &call->def_iter;  !! 344                                                   afs_eproto_cb_count);
304                 iov_iter_discard(&call->def_it !! 345                 call->_iter = &call->iter;
                                                   >> 346                 iov_iter_discard(&call->iter, READ, call->count2 * 3 * 4);
305                 call->unmarshall++;               347                 call->unmarshall++;
306                                                   348 
307                 fallthrough;                   !! 349                 /* Fall through */
308         case 4:                                   350         case 4:
309                 _debug("extract discard %zu/%u    351                 _debug("extract discard %zu/%u",
310                        iov_iter_count(call->it !! 352                        iov_iter_count(&call->iter), call->count2 * 3 * 4);
311                                                   353 
312                 ret = afs_extract_data(call, f    354                 ret = afs_extract_data(call, false);
313                 if (ret < 0)                      355                 if (ret < 0)
314                         return ret;               356                         return ret;
315                                                   357 
316                 call->unmarshall++;               358                 call->unmarshall++;
317                 fallthrough;                   << 
318                                                << 
319         case 5:                                   359         case 5:
320                 break;                            360                 break;
321         }                                         361         }
322                                                   362 
323         if (!afs_check_call_state(call, AFS_CA    363         if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
324                 return afs_io_error(call, afs_    364                 return afs_io_error(call, afs_io_error_cm_reply);
325                                                   365 
326         /* we'll need the file server record a    366         /* we'll need the file server record as that tells us which set of
327          * vnodes to operate upon */              367          * vnodes to operate upon */
328         return afs_find_cm_server_by_peer(call    368         return afs_find_cm_server_by_peer(call);
329 }                                                 369 }
330                                                   370 
331 /*                                                371 /*
332  * allow the fileserver to request callback st    372  * allow the fileserver to request callback state (re-)initialisation
333  */                                               373  */
334 static void SRXAFSCB_InitCallBackState(struct     374 static void SRXAFSCB_InitCallBackState(struct work_struct *work)
335 {                                                 375 {
336         struct afs_call *call = container_of(w    376         struct afs_call *call = container_of(work, struct afs_call, work);
337                                                   377 
338         _enter("{%p}", call->server);             378         _enter("{%p}", call->server);
339                                                   379 
340         if (call->server)                         380         if (call->server)
341                 afs_init_callback_state(call->    381                 afs_init_callback_state(call->server);
342         afs_send_empty_reply(call);               382         afs_send_empty_reply(call);
343         afs_put_call(call);                       383         afs_put_call(call);
344         _leave("");                               384         _leave("");
345 }                                                 385 }
346                                                   386 
347 /*                                                387 /*
348  * deliver request data to a CB.InitCallBackSt    388  * deliver request data to a CB.InitCallBackState call
349  */                                               389  */
350 static int afs_deliver_cb_init_call_back_state    390 static int afs_deliver_cb_init_call_back_state(struct afs_call *call)
351 {                                                 391 {
352         int ret;                                  392         int ret;
353                                                   393 
354         _enter("");                               394         _enter("");
355                                                   395 
356         afs_extract_discard(call, 0);             396         afs_extract_discard(call, 0);
357         ret = afs_extract_data(call, false);      397         ret = afs_extract_data(call, false);
358         if (ret < 0)                              398         if (ret < 0)
359                 return ret;                       399                 return ret;
360                                                   400 
361         /* we'll need the file server record a    401         /* we'll need the file server record as that tells us which set of
362          * vnodes to operate upon */              402          * vnodes to operate upon */
363         return afs_find_cm_server_by_peer(call    403         return afs_find_cm_server_by_peer(call);
364 }                                                 404 }
365                                                   405 
366 /*                                                406 /*
367  * deliver request data to a CB.InitCallBackSt    407  * deliver request data to a CB.InitCallBackState3 call
368  */                                               408  */
369 static int afs_deliver_cb_init_call_back_state    409 static int afs_deliver_cb_init_call_back_state3(struct afs_call *call)
370 {                                                 410 {
371         struct afs_uuid *r;                       411         struct afs_uuid *r;
372         unsigned loop;                            412         unsigned loop;
373         __be32 *b;                                413         __be32 *b;
374         int ret;                                  414         int ret;
375                                                   415 
376         _enter("");                               416         _enter("");
377                                                   417 
378         _enter("{%u}", call->unmarshall);         418         _enter("{%u}", call->unmarshall);
379                                                   419 
380         switch (call->unmarshall) {               420         switch (call->unmarshall) {
381         case 0:                                   421         case 0:
382                 call->buffer = kmalloc_array(1    422                 call->buffer = kmalloc_array(11, sizeof(__be32), GFP_KERNEL);
383                 if (!call->buffer)                423                 if (!call->buffer)
384                         return -ENOMEM;           424                         return -ENOMEM;
385                 afs_extract_to_buf(call, 11 *     425                 afs_extract_to_buf(call, 11 * sizeof(__be32));
386                 call->unmarshall++;               426                 call->unmarshall++;
387                                                   427 
388                 fallthrough;                   !! 428                 /* Fall through */
389         case 1:                                   429         case 1:
390                 _debug("extract UUID");           430                 _debug("extract UUID");
391                 ret = afs_extract_data(call, f    431                 ret = afs_extract_data(call, false);
392                 switch (ret) {                    432                 switch (ret) {
393                 case 0:         break;            433                 case 0:         break;
394                 case -EAGAIN:   return 0;         434                 case -EAGAIN:   return 0;
395                 default:        return ret;       435                 default:        return ret;
396                 }                                 436                 }
397                                                   437 
398                 _debug("unmarshall UUID");        438                 _debug("unmarshall UUID");
399                 call->request = kmalloc(sizeof    439                 call->request = kmalloc(sizeof(struct afs_uuid), GFP_KERNEL);
400                 if (!call->request)               440                 if (!call->request)
401                         return -ENOMEM;           441                         return -ENOMEM;
402                                                   442 
403                 b = call->buffer;                 443                 b = call->buffer;
404                 r = call->request;                444                 r = call->request;
405                 r->time_low                       445                 r->time_low                     = b[0];
406                 r->time_mid                       446                 r->time_mid                     = htons(ntohl(b[1]));
407                 r->time_hi_and_version            447                 r->time_hi_and_version          = htons(ntohl(b[2]));
408                 r->clock_seq_hi_and_reserved      448                 r->clock_seq_hi_and_reserved    = ntohl(b[3]);
409                 r->clock_seq_low                  449                 r->clock_seq_low                = ntohl(b[4]);
410                                                   450 
411                 for (loop = 0; loop < 6; loop+    451                 for (loop = 0; loop < 6; loop++)
412                         r->node[loop] = ntohl(    452                         r->node[loop] = ntohl(b[loop + 5]);
413                                                   453 
414                 call->unmarshall++;               454                 call->unmarshall++;
415                 fallthrough;                   << 
416                                                   455 
417         case 2:                                   456         case 2:
418                 break;                            457                 break;
419         }                                         458         }
420                                                   459 
421         if (!afs_check_call_state(call, AFS_CA    460         if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
422                 return afs_io_error(call, afs_    461                 return afs_io_error(call, afs_io_error_cm_reply);
423                                                   462 
424         /* we'll need the file server record a    463         /* we'll need the file server record as that tells us which set of
425          * vnodes to operate upon */              464          * vnodes to operate upon */
426         return afs_find_cm_server_by_uuid(call    465         return afs_find_cm_server_by_uuid(call, call->request);
427 }                                                 466 }
428                                                   467 
429 /*                                                468 /*
430  * allow the fileserver to see if the cache ma    469  * allow the fileserver to see if the cache manager is still alive
431  */                                               470  */
432 static void SRXAFSCB_Probe(struct work_struct     471 static void SRXAFSCB_Probe(struct work_struct *work)
433 {                                                 472 {
434         struct afs_call *call = container_of(w    473         struct afs_call *call = container_of(work, struct afs_call, work);
435                                                   474 
436         _enter("");                               475         _enter("");
437         afs_send_empty_reply(call);               476         afs_send_empty_reply(call);
438         afs_put_call(call);                       477         afs_put_call(call);
439         _leave("");                               478         _leave("");
440 }                                                 479 }
441                                                   480 
442 /*                                                481 /*
443  * deliver request data to a CB.Probe call        482  * deliver request data to a CB.Probe call
444  */                                               483  */
445 static int afs_deliver_cb_probe(struct afs_cal    484 static int afs_deliver_cb_probe(struct afs_call *call)
446 {                                                 485 {
447         int ret;                                  486         int ret;
448                                                   487 
449         _enter("");                               488         _enter("");
450                                                   489 
451         afs_extract_discard(call, 0);             490         afs_extract_discard(call, 0);
452         ret = afs_extract_data(call, false);      491         ret = afs_extract_data(call, false);
453         if (ret < 0)                              492         if (ret < 0)
454                 return ret;                       493                 return ret;
455                                                   494 
456         if (!afs_check_call_state(call, AFS_CA    495         if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
457                 return afs_io_error(call, afs_    496                 return afs_io_error(call, afs_io_error_cm_reply);
458         return afs_find_cm_server_by_peer(call    497         return afs_find_cm_server_by_peer(call);
459 }                                                 498 }
460                                                   499 
461 /*                                                500 /*
462  * Allow the fileserver to quickly find out if !! 501  * allow the fileserver to quickly find out if the fileserver has been rebooted
463  * rebooted.                                   << 
464  */                                               502  */
465 static void SRXAFSCB_ProbeUuid(struct work_str    503 static void SRXAFSCB_ProbeUuid(struct work_struct *work)
466 {                                                 504 {
467         struct afs_call *call = container_of(w    505         struct afs_call *call = container_of(work, struct afs_call, work);
468         struct afs_uuid *r = call->request;       506         struct afs_uuid *r = call->request;
469                                                   507 
470         _enter("");                               508         _enter("");
471                                                   509 
472         if (memcmp(r, &call->net->uuid, sizeof    510         if (memcmp(r, &call->net->uuid, sizeof(call->net->uuid)) == 0)
473                 afs_send_empty_reply(call);       511                 afs_send_empty_reply(call);
474         else                                      512         else
475                 afs_abort_service_call(call, 1 !! 513                 afs_abort_service_call(call, 1, 1, "K-1");
476                                                   514 
477         afs_put_call(call);                       515         afs_put_call(call);
478         _leave("");                               516         _leave("");
479 }                                                 517 }
480                                                   518 
481 /*                                                519 /*
482  * deliver request data to a CB.ProbeUuid call    520  * deliver request data to a CB.ProbeUuid call
483  */                                               521  */
484 static int afs_deliver_cb_probe_uuid(struct af    522 static int afs_deliver_cb_probe_uuid(struct afs_call *call)
485 {                                                 523 {
486         struct afs_uuid *r;                       524         struct afs_uuid *r;
487         unsigned loop;                            525         unsigned loop;
488         __be32 *b;                                526         __be32 *b;
489         int ret;                                  527         int ret;
490                                                   528 
491         _enter("{%u}", call->unmarshall);         529         _enter("{%u}", call->unmarshall);
492                                                   530 
493         switch (call->unmarshall) {               531         switch (call->unmarshall) {
494         case 0:                                   532         case 0:
495                 call->buffer = kmalloc_array(1    533                 call->buffer = kmalloc_array(11, sizeof(__be32), GFP_KERNEL);
496                 if (!call->buffer)                534                 if (!call->buffer)
497                         return -ENOMEM;           535                         return -ENOMEM;
498                 afs_extract_to_buf(call, 11 *     536                 afs_extract_to_buf(call, 11 * sizeof(__be32));
499                 call->unmarshall++;               537                 call->unmarshall++;
500                                                   538 
501                 fallthrough;                   !! 539                 /* Fall through */
502         case 1:                                   540         case 1:
503                 _debug("extract UUID");           541                 _debug("extract UUID");
504                 ret = afs_extract_data(call, f    542                 ret = afs_extract_data(call, false);
505                 switch (ret) {                    543                 switch (ret) {
506                 case 0:         break;            544                 case 0:         break;
507                 case -EAGAIN:   return 0;         545                 case -EAGAIN:   return 0;
508                 default:        return ret;       546                 default:        return ret;
509                 }                                 547                 }
510                                                   548 
511                 _debug("unmarshall UUID");        549                 _debug("unmarshall UUID");
512                 call->request = kmalloc(sizeof    550                 call->request = kmalloc(sizeof(struct afs_uuid), GFP_KERNEL);
513                 if (!call->request)               551                 if (!call->request)
514                         return -ENOMEM;           552                         return -ENOMEM;
515                                                   553 
516                 b = call->buffer;                 554                 b = call->buffer;
517                 r = call->request;                555                 r = call->request;
518                 r->time_low                       556                 r->time_low                     = b[0];
519                 r->time_mid                       557                 r->time_mid                     = htons(ntohl(b[1]));
520                 r->time_hi_and_version            558                 r->time_hi_and_version          = htons(ntohl(b[2]));
521                 r->clock_seq_hi_and_reserved      559                 r->clock_seq_hi_and_reserved    = ntohl(b[3]);
522                 r->clock_seq_low                  560                 r->clock_seq_low                = ntohl(b[4]);
523                                                   561 
524                 for (loop = 0; loop < 6; loop+    562                 for (loop = 0; loop < 6; loop++)
525                         r->node[loop] = ntohl(    563                         r->node[loop] = ntohl(b[loop + 5]);
526                                                   564 
527                 call->unmarshall++;               565                 call->unmarshall++;
528                 fallthrough;                   << 
529                                                   566 
530         case 2:                                   567         case 2:
531                 break;                            568                 break;
532         }                                         569         }
533                                                   570 
534         if (!afs_check_call_state(call, AFS_CA    571         if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
535                 return afs_io_error(call, afs_    572                 return afs_io_error(call, afs_io_error_cm_reply);
536         return afs_find_cm_server_by_peer(call !! 573         return afs_find_cm_server_by_uuid(call, call->request);
537 }                                                 574 }
538                                                   575 
539 /*                                                576 /*
540  * allow the fileserver to ask about the cache    577  * allow the fileserver to ask about the cache manager's capabilities
541  */                                               578  */
542 static void SRXAFSCB_TellMeAboutYourself(struc    579 static void SRXAFSCB_TellMeAboutYourself(struct work_struct *work)
543 {                                                 580 {
544         struct afs_call *call = container_of(w    581         struct afs_call *call = container_of(work, struct afs_call, work);
545         int loop;                                 582         int loop;
546                                                   583 
547         struct {                                  584         struct {
548                 struct /* InterfaceAddr */ {      585                 struct /* InterfaceAddr */ {
549                         __be32 nifs;              586                         __be32 nifs;
550                         __be32 uuid[11];          587                         __be32 uuid[11];
551                         __be32 ifaddr[32];        588                         __be32 ifaddr[32];
552                         __be32 netmask[32];       589                         __be32 netmask[32];
553                         __be32 mtu[32];           590                         __be32 mtu[32];
554                 } ia;                             591                 } ia;
555                 struct /* Capabilities */ {       592                 struct /* Capabilities */ {
556                         __be32 capcount;          593                         __be32 capcount;
557                         __be32 caps[1];           594                         __be32 caps[1];
558                 } cap;                            595                 } cap;
559         } reply;                                  596         } reply;
560                                                   597 
561         _enter("");                               598         _enter("");
562                                                   599 
563         memset(&reply, 0, sizeof(reply));         600         memset(&reply, 0, sizeof(reply));
564                                                   601 
565         reply.ia.uuid[0] = call->net->uuid.tim    602         reply.ia.uuid[0] = call->net->uuid.time_low;
566         reply.ia.uuid[1] = htonl(ntohs(call->n    603         reply.ia.uuid[1] = htonl(ntohs(call->net->uuid.time_mid));
567         reply.ia.uuid[2] = htonl(ntohs(call->n    604         reply.ia.uuid[2] = htonl(ntohs(call->net->uuid.time_hi_and_version));
568         reply.ia.uuid[3] = htonl((s8) call->ne    605         reply.ia.uuid[3] = htonl((s8) call->net->uuid.clock_seq_hi_and_reserved);
569         reply.ia.uuid[4] = htonl((s8) call->ne    606         reply.ia.uuid[4] = htonl((s8) call->net->uuid.clock_seq_low);
570         for (loop = 0; loop < 6; loop++)          607         for (loop = 0; loop < 6; loop++)
571                 reply.ia.uuid[loop + 5] = hton    608                 reply.ia.uuid[loop + 5] = htonl((s8) call->net->uuid.node[loop]);
572                                                   609 
573         reply.cap.capcount = htonl(1);            610         reply.cap.capcount = htonl(1);
574         reply.cap.caps[0] = htonl(AFS_CAP_ERRO    611         reply.cap.caps[0] = htonl(AFS_CAP_ERROR_TRANSLATION);
575         afs_send_simple_reply(call, &reply, si    612         afs_send_simple_reply(call, &reply, sizeof(reply));
576         afs_put_call(call);                       613         afs_put_call(call);
577         _leave("");                               614         _leave("");
578 }                                                 615 }
579                                                   616 
580 /*                                                617 /*
581  * deliver request data to a CB.TellMeAboutYou    618  * deliver request data to a CB.TellMeAboutYourself call
582  */                                               619  */
583 static int afs_deliver_cb_tell_me_about_yourse    620 static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *call)
584 {                                                 621 {
585         int ret;                                  622         int ret;
586                                                   623 
587         _enter("");                               624         _enter("");
588                                                   625 
589         afs_extract_discard(call, 0);             626         afs_extract_discard(call, 0);
590         ret = afs_extract_data(call, false);      627         ret = afs_extract_data(call, false);
591         if (ret < 0)                              628         if (ret < 0)
592                 return ret;                       629                 return ret;
593                                                   630 
594         if (!afs_check_call_state(call, AFS_CA    631         if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
595                 return afs_io_error(call, afs_    632                 return afs_io_error(call, afs_io_error_cm_reply);
596         return afs_find_cm_server_by_peer(call    633         return afs_find_cm_server_by_peer(call);
597 }                                                 634 }
598                                                   635 
599 /*                                                636 /*
600  * deliver request data to a YFS CB.CallBack c    637  * deliver request data to a YFS CB.CallBack call
601  */                                               638  */
602 static int afs_deliver_yfs_cb_callback(struct     639 static int afs_deliver_yfs_cb_callback(struct afs_call *call)
603 {                                                 640 {
604         struct afs_callback_break *cb;            641         struct afs_callback_break *cb;
605         struct yfs_xdr_YFSFid *bp;                642         struct yfs_xdr_YFSFid *bp;
606         size_t size;                              643         size_t size;
607         int ret, loop;                            644         int ret, loop;
608                                                   645 
609         _enter("{%u}", call->unmarshall);         646         _enter("{%u}", call->unmarshall);
610                                                   647 
611         switch (call->unmarshall) {               648         switch (call->unmarshall) {
612         case 0:                                   649         case 0:
613                 afs_extract_to_tmp(call);         650                 afs_extract_to_tmp(call);
614                 call->unmarshall++;               651                 call->unmarshall++;
615                                                   652 
616                 /* extract the FID array and i    653                 /* extract the FID array and its count in two steps */
617                 fallthrough;                   !! 654                 /* Fall through */
618         case 1:                                   655         case 1:
619                 _debug("extract FID count");      656                 _debug("extract FID count");
620                 ret = afs_extract_data(call, t    657                 ret = afs_extract_data(call, true);
621                 if (ret < 0)                      658                 if (ret < 0)
622                         return ret;               659                         return ret;
623                                                   660 
624                 call->count = ntohl(call->tmp)    661                 call->count = ntohl(call->tmp);
625                 _debug("FID count: %u", call->    662                 _debug("FID count: %u", call->count);
626                 if (call->count > YFSCBMAX)       663                 if (call->count > YFSCBMAX)
627                         return afs_protocol_er !! 664                         return afs_protocol_error(call, -EBADMSG,
                                                   >> 665                                                   afs_eproto_cb_fid_count);
628                                                   666 
629                 size = array_size(call->count,    667                 size = array_size(call->count, sizeof(struct yfs_xdr_YFSFid));
630                 call->buffer = kmalloc(size, G    668                 call->buffer = kmalloc(size, GFP_KERNEL);
631                 if (!call->buffer)                669                 if (!call->buffer)
632                         return -ENOMEM;           670                         return -ENOMEM;
633                 afs_extract_to_buf(call, size)    671                 afs_extract_to_buf(call, size);
634                 call->unmarshall++;               672                 call->unmarshall++;
635                                                   673 
636                 fallthrough;                   !! 674                 /* Fall through */
637         case 2:                                   675         case 2:
638                 _debug("extract FID array");      676                 _debug("extract FID array");
639                 ret = afs_extract_data(call, f    677                 ret = afs_extract_data(call, false);
640                 if (ret < 0)                      678                 if (ret < 0)
641                         return ret;               679                         return ret;
642                                                   680 
643                 _debug("unmarshall FID array")    681                 _debug("unmarshall FID array");
644                 call->request = kcalloc(call->    682                 call->request = kcalloc(call->count,
645                                         sizeof    683                                         sizeof(struct afs_callback_break),
646                                         GFP_KE    684                                         GFP_KERNEL);
647                 if (!call->request)               685                 if (!call->request)
648                         return -ENOMEM;           686                         return -ENOMEM;
649                                                   687 
650                 cb = call->request;               688                 cb = call->request;
651                 bp = call->buffer;                689                 bp = call->buffer;
652                 for (loop = call->count; loop     690                 for (loop = call->count; loop > 0; loop--, cb++) {
653                         cb->fid.vid     = xdr_    691                         cb->fid.vid     = xdr_to_u64(bp->volume);
654                         cb->fid.vnode   = xdr_    692                         cb->fid.vnode   = xdr_to_u64(bp->vnode.lo);
655                         cb->fid.vnode_hi = nto    693                         cb->fid.vnode_hi = ntohl(bp->vnode.hi);
656                         cb->fid.unique  = ntoh    694                         cb->fid.unique  = ntohl(bp->vnode.unique);
657                         bp++;                     695                         bp++;
658                 }                                 696                 }
659                                                   697 
660                 afs_extract_to_tmp(call);         698                 afs_extract_to_tmp(call);
661                 call->unmarshall++;               699                 call->unmarshall++;
662                 fallthrough;                   << 
663                                                   700 
664         case 3:                                   701         case 3:
665                 break;                            702                 break;
666         }                                         703         }
667                                                   704 
668         if (!afs_check_call_state(call, AFS_CA    705         if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
669                 return afs_io_error(call, afs_    706                 return afs_io_error(call, afs_io_error_cm_reply);
670                                                   707 
671         /* We'll need the file server record a    708         /* We'll need the file server record as that tells us which set of
672          * vnodes to operate upon.                709          * vnodes to operate upon.
673          */                                       710          */
674         return afs_find_cm_server_by_peer(call    711         return afs_find_cm_server_by_peer(call);
675 }                                                 712 }
676                                                   713 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php