cmservice.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. /* AFS Cache Manager Service
  2. *
  3. * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/init.h>
  13. #include <linux/slab.h>
  14. #include <linux/sched.h>
  15. #include <linux/ip.h>
  16. #include "internal.h"
  17. #include "afs_cm.h"
  18. #include "protocol_yfs.h"
  19. static int afs_deliver_cb_init_call_back_state(struct afs_call *);
  20. static int afs_deliver_cb_init_call_back_state3(struct afs_call *);
  21. static int afs_deliver_cb_probe(struct afs_call *);
  22. static int afs_deliver_cb_callback(struct afs_call *);
  23. static int afs_deliver_cb_probe_uuid(struct afs_call *);
  24. static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *);
  25. static void afs_cm_destructor(struct afs_call *);
  26. static void SRXAFSCB_CallBack(struct work_struct *);
  27. static void SRXAFSCB_InitCallBackState(struct work_struct *);
  28. static void SRXAFSCB_Probe(struct work_struct *);
  29. static void SRXAFSCB_ProbeUuid(struct work_struct *);
  30. static void SRXAFSCB_TellMeAboutYourself(struct work_struct *);
  31. static int afs_deliver_yfs_cb_callback(struct afs_call *);
  32. #define CM_NAME(name) \
  33. const char afs_SRXCB##name##_name[] __tracepoint_string = \
  34. "CB." #name
  35. /*
  36. * CB.CallBack operation type
  37. */
  38. static CM_NAME(CallBack);
  39. static const struct afs_call_type afs_SRXCBCallBack = {
  40. .name = afs_SRXCBCallBack_name,
  41. .deliver = afs_deliver_cb_callback,
  42. .destructor = afs_cm_destructor,
  43. .work = SRXAFSCB_CallBack,
  44. };
  45. /*
  46. * CB.InitCallBackState operation type
  47. */
  48. static CM_NAME(InitCallBackState);
  49. static const struct afs_call_type afs_SRXCBInitCallBackState = {
  50. .name = afs_SRXCBInitCallBackState_name,
  51. .deliver = afs_deliver_cb_init_call_back_state,
  52. .destructor = afs_cm_destructor,
  53. .work = SRXAFSCB_InitCallBackState,
  54. };
  55. /*
  56. * CB.InitCallBackState3 operation type
  57. */
  58. static CM_NAME(InitCallBackState3);
  59. static const struct afs_call_type afs_SRXCBInitCallBackState3 = {
  60. .name = afs_SRXCBInitCallBackState3_name,
  61. .deliver = afs_deliver_cb_init_call_back_state3,
  62. .destructor = afs_cm_destructor,
  63. .work = SRXAFSCB_InitCallBackState,
  64. };
  65. /*
  66. * CB.Probe operation type
  67. */
  68. static CM_NAME(Probe);
  69. static const struct afs_call_type afs_SRXCBProbe = {
  70. .name = afs_SRXCBProbe_name,
  71. .deliver = afs_deliver_cb_probe,
  72. .destructor = afs_cm_destructor,
  73. .work = SRXAFSCB_Probe,
  74. };
  75. /*
  76. * CB.ProbeUuid operation type
  77. */
  78. static CM_NAME(ProbeUuid);
  79. static const struct afs_call_type afs_SRXCBProbeUuid = {
  80. .name = afs_SRXCBProbeUuid_name,
  81. .deliver = afs_deliver_cb_probe_uuid,
  82. .destructor = afs_cm_destructor,
  83. .work = SRXAFSCB_ProbeUuid,
  84. };
  85. /*
  86. * CB.TellMeAboutYourself operation type
  87. */
  88. static CM_NAME(TellMeAboutYourself);
  89. static const struct afs_call_type afs_SRXCBTellMeAboutYourself = {
  90. .name = afs_SRXCBTellMeAboutYourself_name,
  91. .deliver = afs_deliver_cb_tell_me_about_yourself,
  92. .destructor = afs_cm_destructor,
  93. .work = SRXAFSCB_TellMeAboutYourself,
  94. };
  95. /*
  96. * YFS CB.CallBack operation type
  97. */
  98. static CM_NAME(YFS_CallBack);
  99. static const struct afs_call_type afs_SRXYFSCB_CallBack = {
  100. .name = afs_SRXCBYFS_CallBack_name,
  101. .deliver = afs_deliver_yfs_cb_callback,
  102. .destructor = afs_cm_destructor,
  103. .work = SRXAFSCB_CallBack,
  104. };
  105. /*
  106. * route an incoming cache manager call
  107. * - return T if supported, F if not
  108. */
  109. bool afs_cm_incoming_call(struct afs_call *call)
  110. {
  111. _enter("{%u, CB.OP %u}", call->service_id, call->operation_ID);
  112. call->epoch = rxrpc_kernel_get_epoch(call->net->socket, call->rxcall);
  113. switch (call->operation_ID) {
  114. case CBCallBack:
  115. call->type = &afs_SRXCBCallBack;
  116. return true;
  117. case CBInitCallBackState:
  118. call->type = &afs_SRXCBInitCallBackState;
  119. return true;
  120. case CBInitCallBackState3:
  121. call->type = &afs_SRXCBInitCallBackState3;
  122. return true;
  123. case CBProbe:
  124. call->type = &afs_SRXCBProbe;
  125. return true;
  126. case CBProbeUuid:
  127. call->type = &afs_SRXCBProbeUuid;
  128. return true;
  129. case CBTellMeAboutYourself:
  130. call->type = &afs_SRXCBTellMeAboutYourself;
  131. return true;
  132. case YFSCBCallBack:
  133. if (call->service_id != YFS_CM_SERVICE)
  134. return false;
  135. call->type = &afs_SRXYFSCB_CallBack;
  136. return true;
  137. default:
  138. return false;
  139. }
  140. }
  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. if (test_bit(AFS_SERVER_FL_HAVE_EPOCH, &server->flags) &&
  148. !test_bit(AFS_SERVER_FL_PROBING, &server->flags)) {
  149. if (server->cm_epoch == call->epoch)
  150. return 0;
  151. if (!server->probe.said_rebooted) {
  152. pr_notice("kAFS: FS rebooted %pU\n", &server->uuid);
  153. server->probe.said_rebooted = true;
  154. }
  155. }
  156. spin_lock(&server->probe_lock);
  157. if (!test_bit(AFS_SERVER_FL_HAVE_EPOCH, &server->flags)) {
  158. server->cm_epoch = call->epoch;
  159. server->probe.cm_epoch = call->epoch;
  160. goto out;
  161. }
  162. if (server->probe.cm_probed &&
  163. call->epoch != server->probe.cm_epoch &&
  164. !server->probe.said_inconsistent) {
  165. pr_notice("kAFS: FS endpoints inconsistent %pU\n",
  166. &server->uuid);
  167. server->probe.said_inconsistent = true;
  168. }
  169. if (!server->probe.cm_probed || call->epoch == server->cm_epoch)
  170. server->probe.cm_epoch = server->cm_epoch;
  171. out:
  172. server->probe.cm_probed = true;
  173. spin_unlock(&server->probe_lock);
  174. return 0;
  175. }
  176. /*
  177. * Find the server record by peer address and record a probe to the cache
  178. * manager from a server.
  179. */
  180. static int afs_find_cm_server_by_peer(struct afs_call *call)
  181. {
  182. struct sockaddr_rxrpc srx;
  183. struct afs_server *server;
  184. rxrpc_kernel_get_peer(call->net->socket, call->rxcall, &srx);
  185. server = afs_find_server(call->net, &srx);
  186. if (!server) {
  187. trace_afs_cm_no_server(call, &srx);
  188. return 0;
  189. }
  190. call->cm_server = server;
  191. return afs_record_cm_probe(call, server);
  192. }
  193. /*
  194. * Find the server record by server UUID and record a probe to the cache
  195. * manager from a server.
  196. */
  197. static int afs_find_cm_server_by_uuid(struct afs_call *call,
  198. struct afs_uuid *uuid)
  199. {
  200. struct afs_server *server;
  201. rcu_read_lock();
  202. server = afs_find_server_by_uuid(call->net, call->request);
  203. rcu_read_unlock();
  204. if (!server) {
  205. trace_afs_cm_no_server_u(call, call->request);
  206. return 0;
  207. }
  208. call->cm_server = server;
  209. return afs_record_cm_probe(call, server);
  210. }
  211. /*
  212. * Clean up a cache manager call.
  213. */
  214. static void afs_cm_destructor(struct afs_call *call)
  215. {
  216. kfree(call->buffer);
  217. call->buffer = NULL;
  218. }
  219. /*
  220. * The server supplied a list of callbacks that it wanted to break.
  221. */
  222. static void SRXAFSCB_CallBack(struct work_struct *work)
  223. {
  224. struct afs_call *call = container_of(work, struct afs_call, work);
  225. _enter("");
  226. /* We need to break the callbacks before sending the reply as the
  227. * server holds up change visibility till it receives our reply so as
  228. * to maintain cache coherency.
  229. */
  230. if (call->cm_server)
  231. afs_break_callbacks(call->cm_server, call->count, call->request);
  232. afs_send_empty_reply(call);
  233. afs_put_call(call);
  234. _leave("");
  235. }
  236. /*
  237. * deliver request data to a CB.CallBack call
  238. */
  239. static int afs_deliver_cb_callback(struct afs_call *call)
  240. {
  241. struct afs_callback_break *cb;
  242. __be32 *bp;
  243. int ret, loop;
  244. _enter("{%u}", call->unmarshall);
  245. switch (call->unmarshall) {
  246. case 0:
  247. afs_extract_to_tmp(call);
  248. call->unmarshall++;
  249. /* extract the FID array and its count in two steps */
  250. case 1:
  251. _debug("extract FID count");
  252. ret = afs_extract_data(call, true);
  253. if (ret < 0)
  254. return ret;
  255. call->count = ntohl(call->tmp);
  256. _debug("FID count: %u", call->count);
  257. if (call->count > AFSCBMAX)
  258. return afs_protocol_error(call, -EBADMSG,
  259. afs_eproto_cb_fid_count);
  260. call->buffer = kmalloc(array3_size(call->count, 3, 4),
  261. GFP_KERNEL);
  262. if (!call->buffer)
  263. return -ENOMEM;
  264. afs_extract_to_buf(call, call->count * 3 * 4);
  265. call->unmarshall++;
  266. case 2:
  267. _debug("extract FID array");
  268. ret = afs_extract_data(call, true);
  269. if (ret < 0)
  270. return ret;
  271. _debug("unmarshall FID array");
  272. call->request = kcalloc(call->count,
  273. sizeof(struct afs_callback_break),
  274. GFP_KERNEL);
  275. if (!call->request)
  276. return -ENOMEM;
  277. cb = call->request;
  278. bp = call->buffer;
  279. for (loop = call->count; loop > 0; loop--, cb++) {
  280. cb->fid.vid = ntohl(*bp++);
  281. cb->fid.vnode = ntohl(*bp++);
  282. cb->fid.unique = ntohl(*bp++);
  283. }
  284. afs_extract_to_tmp(call);
  285. call->unmarshall++;
  286. /* extract the callback array and its count in two steps */
  287. case 3:
  288. _debug("extract CB count");
  289. ret = afs_extract_data(call, true);
  290. if (ret < 0)
  291. return ret;
  292. call->count2 = ntohl(call->tmp);
  293. _debug("CB count: %u", call->count2);
  294. if (call->count2 != call->count && call->count2 != 0)
  295. return afs_protocol_error(call, -EBADMSG,
  296. afs_eproto_cb_count);
  297. call->_iter = &call->iter;
  298. iov_iter_discard(&call->iter, READ, call->count2 * 3 * 4);
  299. call->unmarshall++;
  300. case 4:
  301. _debug("extract discard %zu/%u",
  302. iov_iter_count(&call->iter), call->count2 * 3 * 4);
  303. ret = afs_extract_data(call, false);
  304. if (ret < 0)
  305. return ret;
  306. call->unmarshall++;
  307. case 5:
  308. break;
  309. }
  310. if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
  311. return afs_io_error(call, afs_io_error_cm_reply);
  312. /* we'll need the file server record as that tells us which set of
  313. * vnodes to operate upon */
  314. return afs_find_cm_server_by_peer(call);
  315. }
  316. /*
  317. * allow the fileserver to request callback state (re-)initialisation
  318. */
  319. static void SRXAFSCB_InitCallBackState(struct work_struct *work)
  320. {
  321. struct afs_call *call = container_of(work, struct afs_call, work);
  322. _enter("{%p}", call->cm_server);
  323. if (call->cm_server)
  324. afs_init_callback_state(call->cm_server);
  325. afs_send_empty_reply(call);
  326. afs_put_call(call);
  327. _leave("");
  328. }
  329. /*
  330. * deliver request data to a CB.InitCallBackState call
  331. */
  332. static int afs_deliver_cb_init_call_back_state(struct afs_call *call)
  333. {
  334. int ret;
  335. _enter("");
  336. afs_extract_discard(call, 0);
  337. ret = afs_extract_data(call, false);
  338. if (ret < 0)
  339. return ret;
  340. /* we'll need the file server record as that tells us which set of
  341. * vnodes to operate upon */
  342. return afs_find_cm_server_by_peer(call);
  343. }
  344. /*
  345. * deliver request data to a CB.InitCallBackState3 call
  346. */
  347. static int afs_deliver_cb_init_call_back_state3(struct afs_call *call)
  348. {
  349. struct afs_uuid *r;
  350. unsigned loop;
  351. __be32 *b;
  352. int ret;
  353. _enter("");
  354. _enter("{%u}", call->unmarshall);
  355. switch (call->unmarshall) {
  356. case 0:
  357. call->buffer = kmalloc_array(11, sizeof(__be32), GFP_KERNEL);
  358. if (!call->buffer)
  359. return -ENOMEM;
  360. afs_extract_to_buf(call, 11 * sizeof(__be32));
  361. call->unmarshall++;
  362. case 1:
  363. _debug("extract UUID");
  364. ret = afs_extract_data(call, false);
  365. switch (ret) {
  366. case 0: break;
  367. case -EAGAIN: return 0;
  368. default: return ret;
  369. }
  370. _debug("unmarshall UUID");
  371. call->request = kmalloc(sizeof(struct afs_uuid), GFP_KERNEL);
  372. if (!call->request)
  373. return -ENOMEM;
  374. b = call->buffer;
  375. r = call->request;
  376. r->time_low = b[0];
  377. r->time_mid = htons(ntohl(b[1]));
  378. r->time_hi_and_version = htons(ntohl(b[2]));
  379. r->clock_seq_hi_and_reserved = ntohl(b[3]);
  380. r->clock_seq_low = ntohl(b[4]);
  381. for (loop = 0; loop < 6; loop++)
  382. r->node[loop] = ntohl(b[loop + 5]);
  383. call->unmarshall++;
  384. case 2:
  385. break;
  386. }
  387. if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
  388. return afs_io_error(call, afs_io_error_cm_reply);
  389. /* we'll need the file server record as that tells us which set of
  390. * vnodes to operate upon */
  391. return afs_find_cm_server_by_uuid(call, call->request);
  392. }
  393. /*
  394. * allow the fileserver to see if the cache manager is still alive
  395. */
  396. static void SRXAFSCB_Probe(struct work_struct *work)
  397. {
  398. struct afs_call *call = container_of(work, struct afs_call, work);
  399. _enter("");
  400. afs_send_empty_reply(call);
  401. afs_put_call(call);
  402. _leave("");
  403. }
  404. /*
  405. * deliver request data to a CB.Probe call
  406. */
  407. static int afs_deliver_cb_probe(struct afs_call *call)
  408. {
  409. int ret;
  410. _enter("");
  411. afs_extract_discard(call, 0);
  412. ret = afs_extract_data(call, false);
  413. if (ret < 0)
  414. return ret;
  415. if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
  416. return afs_io_error(call, afs_io_error_cm_reply);
  417. return afs_find_cm_server_by_peer(call);
  418. }
  419. /*
  420. * allow the fileserver to quickly find out if the fileserver has been rebooted
  421. */
  422. static void SRXAFSCB_ProbeUuid(struct work_struct *work)
  423. {
  424. struct afs_call *call = container_of(work, struct afs_call, work);
  425. struct afs_uuid *r = call->request;
  426. struct {
  427. __be32 match;
  428. } reply;
  429. _enter("");
  430. if (memcmp(r, &call->net->uuid, sizeof(call->net->uuid)) == 0)
  431. reply.match = htonl(0);
  432. else
  433. reply.match = htonl(1);
  434. afs_send_simple_reply(call, &reply, sizeof(reply));
  435. afs_put_call(call);
  436. _leave("");
  437. }
  438. /*
  439. * deliver request data to a CB.ProbeUuid call
  440. */
  441. static int afs_deliver_cb_probe_uuid(struct afs_call *call)
  442. {
  443. struct afs_uuid *r;
  444. unsigned loop;
  445. __be32 *b;
  446. int ret;
  447. _enter("{%u}", call->unmarshall);
  448. switch (call->unmarshall) {
  449. case 0:
  450. call->buffer = kmalloc_array(11, sizeof(__be32), GFP_KERNEL);
  451. if (!call->buffer)
  452. return -ENOMEM;
  453. afs_extract_to_buf(call, 11 * sizeof(__be32));
  454. call->unmarshall++;
  455. case 1:
  456. _debug("extract UUID");
  457. ret = afs_extract_data(call, false);
  458. switch (ret) {
  459. case 0: break;
  460. case -EAGAIN: return 0;
  461. default: return ret;
  462. }
  463. _debug("unmarshall UUID");
  464. call->request = kmalloc(sizeof(struct afs_uuid), GFP_KERNEL);
  465. if (!call->request)
  466. return -ENOMEM;
  467. b = call->buffer;
  468. r = call->request;
  469. r->time_low = b[0];
  470. r->time_mid = htons(ntohl(b[1]));
  471. r->time_hi_and_version = htons(ntohl(b[2]));
  472. r->clock_seq_hi_and_reserved = ntohl(b[3]);
  473. r->clock_seq_low = ntohl(b[4]);
  474. for (loop = 0; loop < 6; loop++)
  475. r->node[loop] = ntohl(b[loop + 5]);
  476. call->unmarshall++;
  477. case 2:
  478. break;
  479. }
  480. if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
  481. return afs_io_error(call, afs_io_error_cm_reply);
  482. return afs_find_cm_server_by_uuid(call, call->request);
  483. }
  484. /*
  485. * allow the fileserver to ask about the cache manager's capabilities
  486. */
  487. static void SRXAFSCB_TellMeAboutYourself(struct work_struct *work)
  488. {
  489. struct afs_interface *ifs;
  490. struct afs_call *call = container_of(work, struct afs_call, work);
  491. int loop, nifs;
  492. struct {
  493. struct /* InterfaceAddr */ {
  494. __be32 nifs;
  495. __be32 uuid[11];
  496. __be32 ifaddr[32];
  497. __be32 netmask[32];
  498. __be32 mtu[32];
  499. } ia;
  500. struct /* Capabilities */ {
  501. __be32 capcount;
  502. __be32 caps[1];
  503. } cap;
  504. } reply;
  505. _enter("");
  506. nifs = 0;
  507. ifs = kcalloc(32, sizeof(*ifs), GFP_KERNEL);
  508. if (ifs) {
  509. nifs = afs_get_ipv4_interfaces(call->net, ifs, 32, false);
  510. if (nifs < 0) {
  511. kfree(ifs);
  512. ifs = NULL;
  513. nifs = 0;
  514. }
  515. }
  516. memset(&reply, 0, sizeof(reply));
  517. reply.ia.nifs = htonl(nifs);
  518. reply.ia.uuid[0] = call->net->uuid.time_low;
  519. reply.ia.uuid[1] = htonl(ntohs(call->net->uuid.time_mid));
  520. reply.ia.uuid[2] = htonl(ntohs(call->net->uuid.time_hi_and_version));
  521. reply.ia.uuid[3] = htonl((s8) call->net->uuid.clock_seq_hi_and_reserved);
  522. reply.ia.uuid[4] = htonl((s8) call->net->uuid.clock_seq_low);
  523. for (loop = 0; loop < 6; loop++)
  524. reply.ia.uuid[loop + 5] = htonl((s8) call->net->uuid.node[loop]);
  525. if (ifs) {
  526. for (loop = 0; loop < nifs; loop++) {
  527. reply.ia.ifaddr[loop] = ifs[loop].address.s_addr;
  528. reply.ia.netmask[loop] = ifs[loop].netmask.s_addr;
  529. reply.ia.mtu[loop] = htonl(ifs[loop].mtu);
  530. }
  531. kfree(ifs);
  532. }
  533. reply.cap.capcount = htonl(1);
  534. reply.cap.caps[0] = htonl(AFS_CAP_ERROR_TRANSLATION);
  535. afs_send_simple_reply(call, &reply, sizeof(reply));
  536. afs_put_call(call);
  537. _leave("");
  538. }
  539. /*
  540. * deliver request data to a CB.TellMeAboutYourself call
  541. */
  542. static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *call)
  543. {
  544. int ret;
  545. _enter("");
  546. afs_extract_discard(call, 0);
  547. ret = afs_extract_data(call, false);
  548. if (ret < 0)
  549. return ret;
  550. if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
  551. return afs_io_error(call, afs_io_error_cm_reply);
  552. return afs_find_cm_server_by_peer(call);
  553. }
  554. /*
  555. * deliver request data to a YFS CB.CallBack call
  556. */
  557. static int afs_deliver_yfs_cb_callback(struct afs_call *call)
  558. {
  559. struct afs_callback_break *cb;
  560. struct yfs_xdr_YFSFid *bp;
  561. size_t size;
  562. int ret, loop;
  563. _enter("{%u}", call->unmarshall);
  564. switch (call->unmarshall) {
  565. case 0:
  566. afs_extract_to_tmp(call);
  567. call->unmarshall++;
  568. /* extract the FID array and its count in two steps */
  569. case 1:
  570. _debug("extract FID count");
  571. ret = afs_extract_data(call, true);
  572. if (ret < 0)
  573. return ret;
  574. call->count = ntohl(call->tmp);
  575. _debug("FID count: %u", call->count);
  576. if (call->count > YFSCBMAX)
  577. return afs_protocol_error(call, -EBADMSG,
  578. afs_eproto_cb_fid_count);
  579. size = array_size(call->count, sizeof(struct yfs_xdr_YFSFid));
  580. call->buffer = kmalloc(size, GFP_KERNEL);
  581. if (!call->buffer)
  582. return -ENOMEM;
  583. afs_extract_to_buf(call, size);
  584. call->unmarshall++;
  585. case 2:
  586. _debug("extract FID array");
  587. ret = afs_extract_data(call, false);
  588. if (ret < 0)
  589. return ret;
  590. _debug("unmarshall FID array");
  591. call->request = kcalloc(call->count,
  592. sizeof(struct afs_callback_break),
  593. GFP_KERNEL);
  594. if (!call->request)
  595. return -ENOMEM;
  596. cb = call->request;
  597. bp = call->buffer;
  598. for (loop = call->count; loop > 0; loop--, cb++) {
  599. cb->fid.vid = xdr_to_u64(bp->volume);
  600. cb->fid.vnode = xdr_to_u64(bp->vnode.lo);
  601. cb->fid.vnode_hi = ntohl(bp->vnode.hi);
  602. cb->fid.unique = ntohl(bp->vnode.unique);
  603. bp++;
  604. }
  605. afs_extract_to_tmp(call);
  606. call->unmarshall++;
  607. case 3:
  608. break;
  609. }
  610. if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
  611. return afs_io_error(call, afs_io_error_cm_reply);
  612. /* We'll need the file server record as that tells us which set of
  613. * vnodes to operate upon.
  614. */
  615. return afs_find_cm_server_by_peer(call);
  616. }