This source file includes following definitions.
- afs_use_fs_server
- xdr_decode_AFSFid
- xdr_dump_bad
- xdr_decode_AFSFetchStatus
- xdr_decode_expiry
- xdr_decode_AFSCallBack
- xdr_decode_AFSVolSync
- xdr_encode_AFS_StoreStatus
- xdr_decode_AFSFetchVolumeStatus
- afs_deliver_fs_fetch_status_vnode
- afs_fs_fetch_file_status
- afs_deliver_fs_fetch_data
- afs_fetch_data_destructor
- afs_fs_fetch_data64
- afs_fs_fetch_data
- afs_deliver_fs_create_vnode
- afs_fs_create
- afs_deliver_fs_dir_status_and_vol
- afs_fs_remove
- afs_deliver_fs_link
- afs_fs_link
- afs_deliver_fs_symlink
- afs_fs_symlink
- afs_deliver_fs_rename
- afs_fs_rename
- afs_deliver_fs_store_data
- afs_fs_store_data64
- afs_fs_store_data
- afs_deliver_fs_store_status
- afs_fs_setattr_size64
- afs_fs_setattr_size
- afs_fs_setattr
- afs_deliver_fs_get_volume_status
- afs_fs_get_volume_status
- afs_deliver_fs_xxxx_lock
- afs_fs_set_lock
- afs_fs_extend_lock
- afs_fs_release_lock
- afs_deliver_fs_give_up_all_callbacks
- afs_fs_give_up_all_callbacks
- afs_deliver_fs_get_capabilities
- afs_fs_get_capabilities
- afs_deliver_fs_fetch_status
- afs_fs_fetch_status
- afs_deliver_fs_inline_bulk_status
- afs_fs_inline_bulk_status
- afs_deliver_fs_fetch_acl
- afs_destroy_fs_fetch_acl
- afs_fs_fetch_acl
- afs_deliver_fs_file_status_and_vol
- afs_fs_store_acl
1
2
3
4
5
6
7
8 #include <linux/init.h>
9 #include <linux/slab.h>
10 #include <linux/sched.h>
11 #include <linux/circ_buf.h>
12 #include <linux/iversion.h>
13 #include "internal.h"
14 #include "afs_fs.h"
15 #include "xdr_fs.h"
16 #include "protocol_yfs.h"
17
18 static inline void afs_use_fs_server(struct afs_call *call, struct afs_cb_interest *cbi)
19 {
20 call->cbi = afs_get_cb_interest(cbi);
21 }
22
23
24
25
26 static void xdr_decode_AFSFid(const __be32 **_bp, struct afs_fid *fid)
27 {
28 const __be32 *bp = *_bp;
29
30 fid->vid = ntohl(*bp++);
31 fid->vnode = ntohl(*bp++);
32 fid->unique = ntohl(*bp++);
33 *_bp = bp;
34 }
35
36
37
38
39 static void xdr_dump_bad(const __be32 *bp)
40 {
41 __be32 x[4];
42 int i;
43
44 pr_notice("AFS XDR: Bad status record\n");
45 for (i = 0; i < 5 * 4 * 4; i += 16) {
46 memcpy(x, bp, 16);
47 bp += 4;
48 pr_notice("%03x: %08x %08x %08x %08x\n",
49 i, ntohl(x[0]), ntohl(x[1]), ntohl(x[2]), ntohl(x[3]));
50 }
51
52 memcpy(x, bp, 4);
53 pr_notice("0x50: %08x\n", ntohl(x[0]));
54 }
55
56
57
58
59 static int xdr_decode_AFSFetchStatus(const __be32 **_bp,
60 struct afs_call *call,
61 struct afs_status_cb *scb)
62 {
63 const struct afs_xdr_AFSFetchStatus *xdr = (const void *)*_bp;
64 struct afs_file_status *status = &scb->status;
65 bool inline_error = (call->operation_ID == afs_FS_InlineBulkStatus);
66 u64 data_version, size;
67 u32 type, abort_code;
68 int ret;
69
70 abort_code = ntohl(xdr->abort_code);
71
72 if (xdr->if_version != htonl(AFS_FSTATUS_VERSION)) {
73 if (xdr->if_version == htonl(0) &&
74 abort_code != 0 &&
75 inline_error) {
76
77
78
79
80 status->abort_code = abort_code;
81 scb->have_error = true;
82 goto good;
83 }
84
85 pr_warn("Unknown AFSFetchStatus version %u\n", ntohl(xdr->if_version));
86 goto bad;
87 }
88
89 if (abort_code != 0 && inline_error) {
90 status->abort_code = abort_code;
91 scb->have_error = true;
92 goto good;
93 }
94
95 type = ntohl(xdr->type);
96 switch (type) {
97 case AFS_FTYPE_FILE:
98 case AFS_FTYPE_DIR:
99 case AFS_FTYPE_SYMLINK:
100 status->type = type;
101 break;
102 default:
103 goto bad;
104 }
105
106 status->nlink = ntohl(xdr->nlink);
107 status->author = ntohl(xdr->author);
108 status->owner = ntohl(xdr->owner);
109 status->caller_access = ntohl(xdr->caller_access);
110 status->anon_access = ntohl(xdr->anon_access);
111 status->mode = ntohl(xdr->mode) & S_IALLUGO;
112 status->group = ntohl(xdr->group);
113 status->lock_count = ntohl(xdr->lock_count);
114
115 status->mtime_client.tv_sec = ntohl(xdr->mtime_client);
116 status->mtime_client.tv_nsec = 0;
117 status->mtime_server.tv_sec = ntohl(xdr->mtime_server);
118 status->mtime_server.tv_nsec = 0;
119
120 size = (u64)ntohl(xdr->size_lo);
121 size |= (u64)ntohl(xdr->size_hi) << 32;
122 status->size = size;
123
124 data_version = (u64)ntohl(xdr->data_version_lo);
125 data_version |= (u64)ntohl(xdr->data_version_hi) << 32;
126 status->data_version = data_version;
127 scb->have_status = true;
128 good:
129 ret = 0;
130 advance:
131 *_bp = (const void *)*_bp + sizeof(*xdr);
132 return ret;
133
134 bad:
135 xdr_dump_bad(*_bp);
136 ret = afs_protocol_error(call, -EBADMSG, afs_eproto_bad_status);
137 goto advance;
138 }
139
140 static time64_t xdr_decode_expiry(struct afs_call *call, u32 expiry)
141 {
142 return ktime_divns(call->reply_time, NSEC_PER_SEC) + expiry;
143 }
144
145 static void xdr_decode_AFSCallBack(const __be32 **_bp,
146 struct afs_call *call,
147 struct afs_status_cb *scb)
148 {
149 struct afs_callback *cb = &scb->callback;
150 const __be32 *bp = *_bp;
151
152 bp++;
153 cb->expires_at = xdr_decode_expiry(call, ntohl(*bp++));
154 bp++;
155 scb->have_cb = true;
156 *_bp = bp;
157 }
158
159
160
161
162 static void xdr_decode_AFSVolSync(const __be32 **_bp,
163 struct afs_volsync *volsync)
164 {
165 const __be32 *bp = *_bp;
166 u32 creation;
167
168 creation = ntohl(*bp++);
169 bp++;
170 bp++;
171 bp++;
172 bp++;
173 bp++;
174 *_bp = bp;
175
176 if (volsync)
177 volsync->creation = creation;
178 }
179
180
181
182
183 static void xdr_encode_AFS_StoreStatus(__be32 **_bp, struct iattr *attr)
184 {
185 __be32 *bp = *_bp;
186 u32 mask = 0, mtime = 0, owner = 0, group = 0, mode = 0;
187
188 mask = 0;
189 if (attr->ia_valid & ATTR_MTIME) {
190 mask |= AFS_SET_MTIME;
191 mtime = attr->ia_mtime.tv_sec;
192 }
193
194 if (attr->ia_valid & ATTR_UID) {
195 mask |= AFS_SET_OWNER;
196 owner = from_kuid(&init_user_ns, attr->ia_uid);
197 }
198
199 if (attr->ia_valid & ATTR_GID) {
200 mask |= AFS_SET_GROUP;
201 group = from_kgid(&init_user_ns, attr->ia_gid);
202 }
203
204 if (attr->ia_valid & ATTR_MODE) {
205 mask |= AFS_SET_MODE;
206 mode = attr->ia_mode & S_IALLUGO;
207 }
208
209 *bp++ = htonl(mask);
210 *bp++ = htonl(mtime);
211 *bp++ = htonl(owner);
212 *bp++ = htonl(group);
213 *bp++ = htonl(mode);
214 *bp++ = 0;
215 *_bp = bp;
216 }
217
218
219
220
221 static void xdr_decode_AFSFetchVolumeStatus(const __be32 **_bp,
222 struct afs_volume_status *vs)
223 {
224 const __be32 *bp = *_bp;
225
226 vs->vid = ntohl(*bp++);
227 vs->parent_id = ntohl(*bp++);
228 vs->online = ntohl(*bp++);
229 vs->in_service = ntohl(*bp++);
230 vs->blessed = ntohl(*bp++);
231 vs->needs_salvage = ntohl(*bp++);
232 vs->type = ntohl(*bp++);
233 vs->min_quota = ntohl(*bp++);
234 vs->max_quota = ntohl(*bp++);
235 vs->blocks_in_use = ntohl(*bp++);
236 vs->part_blocks_avail = ntohl(*bp++);
237 vs->part_max_blocks = ntohl(*bp++);
238 vs->vol_copy_date = 0;
239 vs->vol_backup_date = 0;
240 *_bp = bp;
241 }
242
243
244
245
246 static int afs_deliver_fs_fetch_status_vnode(struct afs_call *call)
247 {
248 const __be32 *bp;
249 int ret;
250
251 ret = afs_transfer_reply(call);
252 if (ret < 0)
253 return ret;
254
255
256 bp = call->buffer;
257 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
258 if (ret < 0)
259 return ret;
260 xdr_decode_AFSCallBack(&bp, call, call->out_scb);
261 xdr_decode_AFSVolSync(&bp, call->out_volsync);
262
263 _leave(" = 0 [done]");
264 return 0;
265 }
266
267
268
269
270 static const struct afs_call_type afs_RXFSFetchStatus_vnode = {
271 .name = "FS.FetchStatus(vnode)",
272 .op = afs_FS_FetchStatus,
273 .deliver = afs_deliver_fs_fetch_status_vnode,
274 .destructor = afs_flat_call_destructor,
275 };
276
277
278
279
280 int afs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_status_cb *scb,
281 struct afs_volsync *volsync)
282 {
283 struct afs_vnode *vnode = fc->vnode;
284 struct afs_call *call;
285 struct afs_net *net = afs_v2net(vnode);
286 __be32 *bp;
287
288 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
289 return yfs_fs_fetch_file_status(fc, scb, volsync);
290
291 _enter(",%x,{%llx:%llu},,",
292 key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
293
294 call = afs_alloc_flat_call(net, &afs_RXFSFetchStatus_vnode,
295 16, (21 + 3 + 6) * 4);
296 if (!call) {
297 fc->ac.error = -ENOMEM;
298 return -ENOMEM;
299 }
300
301 call->key = fc->key;
302 call->out_scb = scb;
303 call->out_volsync = volsync;
304
305
306 bp = call->request;
307 bp[0] = htonl(FSFETCHSTATUS);
308 bp[1] = htonl(vnode->fid.vid);
309 bp[2] = htonl(vnode->fid.vnode);
310 bp[3] = htonl(vnode->fid.unique);
311
312 afs_use_fs_server(call, fc->cbi);
313 trace_afs_make_fs_call(call, &vnode->fid);
314
315 afs_set_fc_call(call, fc);
316 afs_make_call(&fc->ac, call, GFP_NOFS);
317 return afs_wait_for_call_to_complete(call, &fc->ac);
318 }
319
320
321
322
323 static int afs_deliver_fs_fetch_data(struct afs_call *call)
324 {
325 struct afs_read *req = call->read_request;
326 const __be32 *bp;
327 unsigned int size;
328 int ret;
329
330 _enter("{%u,%zu/%llu}",
331 call->unmarshall, iov_iter_count(&call->iter), req->actual_len);
332
333 switch (call->unmarshall) {
334 case 0:
335 req->actual_len = 0;
336 req->index = 0;
337 req->offset = req->pos & (PAGE_SIZE - 1);
338 call->unmarshall++;
339 if (call->operation_ID == FSFETCHDATA64) {
340 afs_extract_to_tmp64(call);
341 } else {
342 call->tmp_u = htonl(0);
343 afs_extract_to_tmp(call);
344 }
345
346
347
348 case 1:
349 _debug("extract data length");
350 ret = afs_extract_data(call, true);
351 if (ret < 0)
352 return ret;
353
354 req->actual_len = be64_to_cpu(call->tmp64);
355 _debug("DATA length: %llu", req->actual_len);
356 req->remain = min(req->len, req->actual_len);
357 if (req->remain == 0)
358 goto no_more_data;
359
360 call->unmarshall++;
361
362 begin_page:
363 ASSERTCMP(req->index, <, req->nr_pages);
364 if (req->remain > PAGE_SIZE - req->offset)
365 size = PAGE_SIZE - req->offset;
366 else
367 size = req->remain;
368 call->bvec[0].bv_len = size;
369 call->bvec[0].bv_offset = req->offset;
370 call->bvec[0].bv_page = req->pages[req->index];
371 iov_iter_bvec(&call->iter, READ, call->bvec, 1, size);
372 ASSERTCMP(size, <=, PAGE_SIZE);
373
374
375
376 case 2:
377 _debug("extract data %zu/%llu",
378 iov_iter_count(&call->iter), req->remain);
379
380 ret = afs_extract_data(call, true);
381 if (ret < 0)
382 return ret;
383 req->remain -= call->bvec[0].bv_len;
384 req->offset += call->bvec[0].bv_len;
385 ASSERTCMP(req->offset, <=, PAGE_SIZE);
386 if (req->offset == PAGE_SIZE) {
387 req->offset = 0;
388 req->index++;
389 if (req->remain > 0)
390 goto begin_page;
391 }
392
393 ASSERTCMP(req->remain, ==, 0);
394 if (req->actual_len <= req->len)
395 goto no_more_data;
396
397
398 afs_extract_discard(call, req->actual_len - req->len);
399 call->unmarshall = 3;
400
401
402 case 3:
403 _debug("extract discard %zu/%llu",
404 iov_iter_count(&call->iter), req->actual_len - req->len);
405
406 ret = afs_extract_data(call, true);
407 if (ret < 0)
408 return ret;
409
410 no_more_data:
411 call->unmarshall = 4;
412 afs_extract_to_buf(call, (21 + 3 + 6) * 4);
413
414
415
416 case 4:
417 ret = afs_extract_data(call, false);
418 if (ret < 0)
419 return ret;
420
421 bp = call->buffer;
422 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
423 if (ret < 0)
424 return ret;
425 xdr_decode_AFSCallBack(&bp, call, call->out_scb);
426 xdr_decode_AFSVolSync(&bp, call->out_volsync);
427
428 req->data_version = call->out_scb->status.data_version;
429 req->file_size = call->out_scb->status.size;
430
431 call->unmarshall++;
432
433 case 5:
434 break;
435 }
436
437 for (; req->index < req->nr_pages; req->index++) {
438 if (req->offset < PAGE_SIZE)
439 zero_user_segment(req->pages[req->index],
440 req->offset, PAGE_SIZE);
441 req->offset = 0;
442 }
443
444 if (req->page_done)
445 for (req->index = 0; req->index < req->nr_pages; req->index++)
446 req->page_done(req);
447
448 _leave(" = 0 [done]");
449 return 0;
450 }
451
452 static void afs_fetch_data_destructor(struct afs_call *call)
453 {
454 struct afs_read *req = call->read_request;
455
456 afs_put_read(req);
457 afs_flat_call_destructor(call);
458 }
459
460
461
462
463 static const struct afs_call_type afs_RXFSFetchData = {
464 .name = "FS.FetchData",
465 .op = afs_FS_FetchData,
466 .deliver = afs_deliver_fs_fetch_data,
467 .destructor = afs_fetch_data_destructor,
468 };
469
470 static const struct afs_call_type afs_RXFSFetchData64 = {
471 .name = "FS.FetchData64",
472 .op = afs_FS_FetchData64,
473 .deliver = afs_deliver_fs_fetch_data,
474 .destructor = afs_fetch_data_destructor,
475 };
476
477
478
479
480 static int afs_fs_fetch_data64(struct afs_fs_cursor *fc,
481 struct afs_status_cb *scb,
482 struct afs_read *req)
483 {
484 struct afs_vnode *vnode = fc->vnode;
485 struct afs_call *call;
486 struct afs_net *net = afs_v2net(vnode);
487 __be32 *bp;
488
489 _enter("");
490
491 call = afs_alloc_flat_call(net, &afs_RXFSFetchData64, 32, (21 + 3 + 6) * 4);
492 if (!call)
493 return -ENOMEM;
494
495 call->key = fc->key;
496 call->out_scb = scb;
497 call->out_volsync = NULL;
498 call->read_request = req;
499
500
501 bp = call->request;
502 bp[0] = htonl(FSFETCHDATA64);
503 bp[1] = htonl(vnode->fid.vid);
504 bp[2] = htonl(vnode->fid.vnode);
505 bp[3] = htonl(vnode->fid.unique);
506 bp[4] = htonl(upper_32_bits(req->pos));
507 bp[5] = htonl(lower_32_bits(req->pos));
508 bp[6] = 0;
509 bp[7] = htonl(lower_32_bits(req->len));
510
511 refcount_inc(&req->usage);
512 afs_use_fs_server(call, fc->cbi);
513 trace_afs_make_fs_call(call, &vnode->fid);
514 afs_set_fc_call(call, fc);
515 afs_make_call(&fc->ac, call, GFP_NOFS);
516 return afs_wait_for_call_to_complete(call, &fc->ac);
517 }
518
519
520
521
522 int afs_fs_fetch_data(struct afs_fs_cursor *fc,
523 struct afs_status_cb *scb,
524 struct afs_read *req)
525 {
526 struct afs_vnode *vnode = fc->vnode;
527 struct afs_call *call;
528 struct afs_net *net = afs_v2net(vnode);
529 __be32 *bp;
530
531 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
532 return yfs_fs_fetch_data(fc, scb, req);
533
534 if (upper_32_bits(req->pos) ||
535 upper_32_bits(req->len) ||
536 upper_32_bits(req->pos + req->len))
537 return afs_fs_fetch_data64(fc, scb, req);
538
539 _enter("");
540
541 call = afs_alloc_flat_call(net, &afs_RXFSFetchData, 24, (21 + 3 + 6) * 4);
542 if (!call)
543 return -ENOMEM;
544
545 call->key = fc->key;
546 call->out_scb = scb;
547 call->out_volsync = NULL;
548 call->read_request = req;
549
550
551 bp = call->request;
552 bp[0] = htonl(FSFETCHDATA);
553 bp[1] = htonl(vnode->fid.vid);
554 bp[2] = htonl(vnode->fid.vnode);
555 bp[3] = htonl(vnode->fid.unique);
556 bp[4] = htonl(lower_32_bits(req->pos));
557 bp[5] = htonl(lower_32_bits(req->len));
558
559 refcount_inc(&req->usage);
560 afs_use_fs_server(call, fc->cbi);
561 trace_afs_make_fs_call(call, &vnode->fid);
562 afs_set_fc_call(call, fc);
563 afs_make_call(&fc->ac, call, GFP_NOFS);
564 return afs_wait_for_call_to_complete(call, &fc->ac);
565 }
566
567
568
569
570 static int afs_deliver_fs_create_vnode(struct afs_call *call)
571 {
572 const __be32 *bp;
573 int ret;
574
575 ret = afs_transfer_reply(call);
576 if (ret < 0)
577 return ret;
578
579
580 bp = call->buffer;
581 xdr_decode_AFSFid(&bp, call->out_fid);
582 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
583 if (ret < 0)
584 return ret;
585 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
586 if (ret < 0)
587 return ret;
588 xdr_decode_AFSCallBack(&bp, call, call->out_scb);
589 xdr_decode_AFSVolSync(&bp, call->out_volsync);
590
591 _leave(" = 0 [done]");
592 return 0;
593 }
594
595
596
597
598 static const struct afs_call_type afs_RXFSCreateFile = {
599 .name = "FS.CreateFile",
600 .op = afs_FS_CreateFile,
601 .deliver = afs_deliver_fs_create_vnode,
602 .destructor = afs_flat_call_destructor,
603 };
604
605 static const struct afs_call_type afs_RXFSMakeDir = {
606 .name = "FS.MakeDir",
607 .op = afs_FS_MakeDir,
608 .deliver = afs_deliver_fs_create_vnode,
609 .destructor = afs_flat_call_destructor,
610 };
611
612
613
614
615 int afs_fs_create(struct afs_fs_cursor *fc,
616 const char *name,
617 umode_t mode,
618 struct afs_status_cb *dvnode_scb,
619 struct afs_fid *newfid,
620 struct afs_status_cb *new_scb)
621 {
622 struct afs_vnode *dvnode = fc->vnode;
623 struct afs_call *call;
624 struct afs_net *net = afs_v2net(dvnode);
625 size_t namesz, reqsz, padsz;
626 __be32 *bp;
627
628 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)){
629 if (S_ISDIR(mode))
630 return yfs_fs_make_dir(fc, name, mode, dvnode_scb,
631 newfid, new_scb);
632 else
633 return yfs_fs_create_file(fc, name, mode, dvnode_scb,
634 newfid, new_scb);
635 }
636
637 _enter("");
638
639 namesz = strlen(name);
640 padsz = (4 - (namesz & 3)) & 3;
641 reqsz = (5 * 4) + namesz + padsz + (6 * 4);
642
643 call = afs_alloc_flat_call(
644 net, S_ISDIR(mode) ? &afs_RXFSMakeDir : &afs_RXFSCreateFile,
645 reqsz, (3 + 21 + 21 + 3 + 6) * 4);
646 if (!call)
647 return -ENOMEM;
648
649 call->key = fc->key;
650 call->out_dir_scb = dvnode_scb;
651 call->out_fid = newfid;
652 call->out_scb = new_scb;
653
654
655 bp = call->request;
656 *bp++ = htonl(S_ISDIR(mode) ? FSMAKEDIR : FSCREATEFILE);
657 *bp++ = htonl(dvnode->fid.vid);
658 *bp++ = htonl(dvnode->fid.vnode);
659 *bp++ = htonl(dvnode->fid.unique);
660 *bp++ = htonl(namesz);
661 memcpy(bp, name, namesz);
662 bp = (void *) bp + namesz;
663 if (padsz > 0) {
664 memset(bp, 0, padsz);
665 bp = (void *) bp + padsz;
666 }
667 *bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME);
668 *bp++ = htonl(dvnode->vfs_inode.i_mtime.tv_sec);
669 *bp++ = 0;
670 *bp++ = 0;
671 *bp++ = htonl(mode & S_IALLUGO);
672 *bp++ = 0;
673
674 afs_use_fs_server(call, fc->cbi);
675 trace_afs_make_fs_call1(call, &dvnode->fid, name);
676 afs_set_fc_call(call, fc);
677 afs_make_call(&fc->ac, call, GFP_NOFS);
678 return afs_wait_for_call_to_complete(call, &fc->ac);
679 }
680
681
682
683
684
685 static int afs_deliver_fs_dir_status_and_vol(struct afs_call *call)
686 {
687 const __be32 *bp;
688 int ret;
689
690 ret = afs_transfer_reply(call);
691 if (ret < 0)
692 return ret;
693
694
695 bp = call->buffer;
696 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
697 if (ret < 0)
698 return ret;
699 xdr_decode_AFSVolSync(&bp, call->out_volsync);
700
701 _leave(" = 0 [done]");
702 return 0;
703 }
704
705
706
707
708 static const struct afs_call_type afs_RXFSRemoveFile = {
709 .name = "FS.RemoveFile",
710 .op = afs_FS_RemoveFile,
711 .deliver = afs_deliver_fs_dir_status_and_vol,
712 .destructor = afs_flat_call_destructor,
713 };
714
715 static const struct afs_call_type afs_RXFSRemoveDir = {
716 .name = "FS.RemoveDir",
717 .op = afs_FS_RemoveDir,
718 .deliver = afs_deliver_fs_dir_status_and_vol,
719 .destructor = afs_flat_call_destructor,
720 };
721
722
723
724
725 int afs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
726 const char *name, bool isdir, struct afs_status_cb *dvnode_scb)
727 {
728 struct afs_vnode *dvnode = fc->vnode;
729 struct afs_call *call;
730 struct afs_net *net = afs_v2net(dvnode);
731 size_t namesz, reqsz, padsz;
732 __be32 *bp;
733
734 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
735 return yfs_fs_remove(fc, vnode, name, isdir, dvnode_scb);
736
737 _enter("");
738
739 namesz = strlen(name);
740 padsz = (4 - (namesz & 3)) & 3;
741 reqsz = (5 * 4) + namesz + padsz;
742
743 call = afs_alloc_flat_call(
744 net, isdir ? &afs_RXFSRemoveDir : &afs_RXFSRemoveFile,
745 reqsz, (21 + 6) * 4);
746 if (!call)
747 return -ENOMEM;
748
749 call->key = fc->key;
750 call->out_dir_scb = dvnode_scb;
751
752
753 bp = call->request;
754 *bp++ = htonl(isdir ? FSREMOVEDIR : FSREMOVEFILE);
755 *bp++ = htonl(dvnode->fid.vid);
756 *bp++ = htonl(dvnode->fid.vnode);
757 *bp++ = htonl(dvnode->fid.unique);
758 *bp++ = htonl(namesz);
759 memcpy(bp, name, namesz);
760 bp = (void *) bp + namesz;
761 if (padsz > 0) {
762 memset(bp, 0, padsz);
763 bp = (void *) bp + padsz;
764 }
765
766 afs_use_fs_server(call, fc->cbi);
767 trace_afs_make_fs_call1(call, &dvnode->fid, name);
768 afs_set_fc_call(call, fc);
769 afs_make_call(&fc->ac, call, GFP_NOFS);
770 return afs_wait_for_call_to_complete(call, &fc->ac);
771 }
772
773
774
775
776 static int afs_deliver_fs_link(struct afs_call *call)
777 {
778 const __be32 *bp;
779 int ret;
780
781 _enter("{%u}", call->unmarshall);
782
783 ret = afs_transfer_reply(call);
784 if (ret < 0)
785 return ret;
786
787
788 bp = call->buffer;
789 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
790 if (ret < 0)
791 return ret;
792 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
793 if (ret < 0)
794 return ret;
795 xdr_decode_AFSVolSync(&bp, call->out_volsync);
796
797 _leave(" = 0 [done]");
798 return 0;
799 }
800
801
802
803
804 static const struct afs_call_type afs_RXFSLink = {
805 .name = "FS.Link",
806 .op = afs_FS_Link,
807 .deliver = afs_deliver_fs_link,
808 .destructor = afs_flat_call_destructor,
809 };
810
811
812
813
814 int afs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
815 const char *name,
816 struct afs_status_cb *dvnode_scb,
817 struct afs_status_cb *vnode_scb)
818 {
819 struct afs_vnode *dvnode = fc->vnode;
820 struct afs_call *call;
821 struct afs_net *net = afs_v2net(vnode);
822 size_t namesz, reqsz, padsz;
823 __be32 *bp;
824
825 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
826 return yfs_fs_link(fc, vnode, name, dvnode_scb, vnode_scb);
827
828 _enter("");
829
830 namesz = strlen(name);
831 padsz = (4 - (namesz & 3)) & 3;
832 reqsz = (5 * 4) + namesz + padsz + (3 * 4);
833
834 call = afs_alloc_flat_call(net, &afs_RXFSLink, reqsz, (21 + 21 + 6) * 4);
835 if (!call)
836 return -ENOMEM;
837
838 call->key = fc->key;
839 call->out_dir_scb = dvnode_scb;
840 call->out_scb = vnode_scb;
841
842
843 bp = call->request;
844 *bp++ = htonl(FSLINK);
845 *bp++ = htonl(dvnode->fid.vid);
846 *bp++ = htonl(dvnode->fid.vnode);
847 *bp++ = htonl(dvnode->fid.unique);
848 *bp++ = htonl(namesz);
849 memcpy(bp, name, namesz);
850 bp = (void *) bp + namesz;
851 if (padsz > 0) {
852 memset(bp, 0, padsz);
853 bp = (void *) bp + padsz;
854 }
855 *bp++ = htonl(vnode->fid.vid);
856 *bp++ = htonl(vnode->fid.vnode);
857 *bp++ = htonl(vnode->fid.unique);
858
859 afs_use_fs_server(call, fc->cbi);
860 trace_afs_make_fs_call1(call, &vnode->fid, name);
861 afs_set_fc_call(call, fc);
862 afs_make_call(&fc->ac, call, GFP_NOFS);
863 return afs_wait_for_call_to_complete(call, &fc->ac);
864 }
865
866
867
868
869 static int afs_deliver_fs_symlink(struct afs_call *call)
870 {
871 const __be32 *bp;
872 int ret;
873
874 _enter("{%u}", call->unmarshall);
875
876 ret = afs_transfer_reply(call);
877 if (ret < 0)
878 return ret;
879
880
881 bp = call->buffer;
882 xdr_decode_AFSFid(&bp, call->out_fid);
883 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
884 if (ret < 0)
885 return ret;
886 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
887 if (ret < 0)
888 return ret;
889 xdr_decode_AFSVolSync(&bp, call->out_volsync);
890
891 _leave(" = 0 [done]");
892 return 0;
893 }
894
895
896
897
898 static const struct afs_call_type afs_RXFSSymlink = {
899 .name = "FS.Symlink",
900 .op = afs_FS_Symlink,
901 .deliver = afs_deliver_fs_symlink,
902 .destructor = afs_flat_call_destructor,
903 };
904
905
906
907
908 int afs_fs_symlink(struct afs_fs_cursor *fc,
909 const char *name,
910 const char *contents,
911 struct afs_status_cb *dvnode_scb,
912 struct afs_fid *newfid,
913 struct afs_status_cb *new_scb)
914 {
915 struct afs_vnode *dvnode = fc->vnode;
916 struct afs_call *call;
917 struct afs_net *net = afs_v2net(dvnode);
918 size_t namesz, reqsz, padsz, c_namesz, c_padsz;
919 __be32 *bp;
920
921 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
922 return yfs_fs_symlink(fc, name, contents, dvnode_scb,
923 newfid, new_scb);
924
925 _enter("");
926
927 namesz = strlen(name);
928 padsz = (4 - (namesz & 3)) & 3;
929
930 c_namesz = strlen(contents);
931 c_padsz = (4 - (c_namesz & 3)) & 3;
932
933 reqsz = (6 * 4) + namesz + padsz + c_namesz + c_padsz + (6 * 4);
934
935 call = afs_alloc_flat_call(net, &afs_RXFSSymlink, reqsz,
936 (3 + 21 + 21 + 6) * 4);
937 if (!call)
938 return -ENOMEM;
939
940 call->key = fc->key;
941 call->out_dir_scb = dvnode_scb;
942 call->out_fid = newfid;
943 call->out_scb = new_scb;
944
945
946 bp = call->request;
947 *bp++ = htonl(FSSYMLINK);
948 *bp++ = htonl(dvnode->fid.vid);
949 *bp++ = htonl(dvnode->fid.vnode);
950 *bp++ = htonl(dvnode->fid.unique);
951 *bp++ = htonl(namesz);
952 memcpy(bp, name, namesz);
953 bp = (void *) bp + namesz;
954 if (padsz > 0) {
955 memset(bp, 0, padsz);
956 bp = (void *) bp + padsz;
957 }
958 *bp++ = htonl(c_namesz);
959 memcpy(bp, contents, c_namesz);
960 bp = (void *) bp + c_namesz;
961 if (c_padsz > 0) {
962 memset(bp, 0, c_padsz);
963 bp = (void *) bp + c_padsz;
964 }
965 *bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME);
966 *bp++ = htonl(dvnode->vfs_inode.i_mtime.tv_sec);
967 *bp++ = 0;
968 *bp++ = 0;
969 *bp++ = htonl(S_IRWXUGO);
970 *bp++ = 0;
971
972 afs_use_fs_server(call, fc->cbi);
973 trace_afs_make_fs_call1(call, &dvnode->fid, name);
974 afs_set_fc_call(call, fc);
975 afs_make_call(&fc->ac, call, GFP_NOFS);
976 return afs_wait_for_call_to_complete(call, &fc->ac);
977 }
978
979
980
981
982 static int afs_deliver_fs_rename(struct afs_call *call)
983 {
984 const __be32 *bp;
985 int ret;
986
987 ret = afs_transfer_reply(call);
988 if (ret < 0)
989 return ret;
990
991
992
993
994 bp = call->buffer;
995 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
996 if (ret < 0)
997 return ret;
998 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
999 if (ret < 0)
1000 return ret;
1001 xdr_decode_AFSVolSync(&bp, call->out_volsync);
1002
1003 _leave(" = 0 [done]");
1004 return 0;
1005 }
1006
1007
1008
1009
1010 static const struct afs_call_type afs_RXFSRename = {
1011 .name = "FS.Rename",
1012 .op = afs_FS_Rename,
1013 .deliver = afs_deliver_fs_rename,
1014 .destructor = afs_flat_call_destructor,
1015 };
1016
1017
1018
1019
1020 int afs_fs_rename(struct afs_fs_cursor *fc,
1021 const char *orig_name,
1022 struct afs_vnode *new_dvnode,
1023 const char *new_name,
1024 struct afs_status_cb *orig_dvnode_scb,
1025 struct afs_status_cb *new_dvnode_scb)
1026 {
1027 struct afs_vnode *orig_dvnode = fc->vnode;
1028 struct afs_call *call;
1029 struct afs_net *net = afs_v2net(orig_dvnode);
1030 size_t reqsz, o_namesz, o_padsz, n_namesz, n_padsz;
1031 __be32 *bp;
1032
1033 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1034 return yfs_fs_rename(fc, orig_name,
1035 new_dvnode, new_name,
1036 orig_dvnode_scb,
1037 new_dvnode_scb);
1038
1039 _enter("");
1040
1041 o_namesz = strlen(orig_name);
1042 o_padsz = (4 - (o_namesz & 3)) & 3;
1043
1044 n_namesz = strlen(new_name);
1045 n_padsz = (4 - (n_namesz & 3)) & 3;
1046
1047 reqsz = (4 * 4) +
1048 4 + o_namesz + o_padsz +
1049 (3 * 4) +
1050 4 + n_namesz + n_padsz;
1051
1052 call = afs_alloc_flat_call(net, &afs_RXFSRename, reqsz, (21 + 21 + 6) * 4);
1053 if (!call)
1054 return -ENOMEM;
1055
1056 call->key = fc->key;
1057 call->out_dir_scb = orig_dvnode_scb;
1058 call->out_scb = new_dvnode_scb;
1059
1060
1061 bp = call->request;
1062 *bp++ = htonl(FSRENAME);
1063 *bp++ = htonl(orig_dvnode->fid.vid);
1064 *bp++ = htonl(orig_dvnode->fid.vnode);
1065 *bp++ = htonl(orig_dvnode->fid.unique);
1066 *bp++ = htonl(o_namesz);
1067 memcpy(bp, orig_name, o_namesz);
1068 bp = (void *) bp + o_namesz;
1069 if (o_padsz > 0) {
1070 memset(bp, 0, o_padsz);
1071 bp = (void *) bp + o_padsz;
1072 }
1073
1074 *bp++ = htonl(new_dvnode->fid.vid);
1075 *bp++ = htonl(new_dvnode->fid.vnode);
1076 *bp++ = htonl(new_dvnode->fid.unique);
1077 *bp++ = htonl(n_namesz);
1078 memcpy(bp, new_name, n_namesz);
1079 bp = (void *) bp + n_namesz;
1080 if (n_padsz > 0) {
1081 memset(bp, 0, n_padsz);
1082 bp = (void *) bp + n_padsz;
1083 }
1084
1085 afs_use_fs_server(call, fc->cbi);
1086 trace_afs_make_fs_call2(call, &orig_dvnode->fid, orig_name, new_name);
1087 afs_set_fc_call(call, fc);
1088 afs_make_call(&fc->ac, call, GFP_NOFS);
1089 return afs_wait_for_call_to_complete(call, &fc->ac);
1090 }
1091
1092
1093
1094
1095 static int afs_deliver_fs_store_data(struct afs_call *call)
1096 {
1097 const __be32 *bp;
1098 int ret;
1099
1100 _enter("");
1101
1102 ret = afs_transfer_reply(call);
1103 if (ret < 0)
1104 return ret;
1105
1106
1107 bp = call->buffer;
1108 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
1109 if (ret < 0)
1110 return ret;
1111 xdr_decode_AFSVolSync(&bp, call->out_volsync);
1112
1113 _leave(" = 0 [done]");
1114 return 0;
1115 }
1116
1117
1118
1119
1120 static const struct afs_call_type afs_RXFSStoreData = {
1121 .name = "FS.StoreData",
1122 .op = afs_FS_StoreData,
1123 .deliver = afs_deliver_fs_store_data,
1124 .destructor = afs_flat_call_destructor,
1125 };
1126
1127 static const struct afs_call_type afs_RXFSStoreData64 = {
1128 .name = "FS.StoreData64",
1129 .op = afs_FS_StoreData64,
1130 .deliver = afs_deliver_fs_store_data,
1131 .destructor = afs_flat_call_destructor,
1132 };
1133
1134
1135
1136
1137 static int afs_fs_store_data64(struct afs_fs_cursor *fc,
1138 struct address_space *mapping,
1139 pgoff_t first, pgoff_t last,
1140 unsigned offset, unsigned to,
1141 loff_t size, loff_t pos, loff_t i_size,
1142 struct afs_status_cb *scb)
1143 {
1144 struct afs_vnode *vnode = fc->vnode;
1145 struct afs_call *call;
1146 struct afs_net *net = afs_v2net(vnode);
1147 __be32 *bp;
1148
1149 _enter(",%x,{%llx:%llu},,",
1150 key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1151
1152 call = afs_alloc_flat_call(net, &afs_RXFSStoreData64,
1153 (4 + 6 + 3 * 2) * 4,
1154 (21 + 6) * 4);
1155 if (!call)
1156 return -ENOMEM;
1157
1158 call->key = fc->key;
1159 call->mapping = mapping;
1160 call->first = first;
1161 call->last = last;
1162 call->first_offset = offset;
1163 call->last_to = to;
1164 call->send_pages = true;
1165 call->out_scb = scb;
1166
1167
1168 bp = call->request;
1169 *bp++ = htonl(FSSTOREDATA64);
1170 *bp++ = htonl(vnode->fid.vid);
1171 *bp++ = htonl(vnode->fid.vnode);
1172 *bp++ = htonl(vnode->fid.unique);
1173
1174 *bp++ = htonl(AFS_SET_MTIME);
1175 *bp++ = htonl(vnode->vfs_inode.i_mtime.tv_sec);
1176 *bp++ = 0;
1177 *bp++ = 0;
1178 *bp++ = 0;
1179 *bp++ = 0;
1180
1181 *bp++ = htonl(pos >> 32);
1182 *bp++ = htonl((u32) pos);
1183 *bp++ = htonl(size >> 32);
1184 *bp++ = htonl((u32) size);
1185 *bp++ = htonl(i_size >> 32);
1186 *bp++ = htonl((u32) i_size);
1187
1188 trace_afs_make_fs_call(call, &vnode->fid);
1189 afs_set_fc_call(call, fc);
1190 afs_make_call(&fc->ac, call, GFP_NOFS);
1191 return afs_wait_for_call_to_complete(call, &fc->ac);
1192 }
1193
1194
1195
1196
1197 int afs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping,
1198 pgoff_t first, pgoff_t last,
1199 unsigned offset, unsigned to,
1200 struct afs_status_cb *scb)
1201 {
1202 struct afs_vnode *vnode = fc->vnode;
1203 struct afs_call *call;
1204 struct afs_net *net = afs_v2net(vnode);
1205 loff_t size, pos, i_size;
1206 __be32 *bp;
1207
1208 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1209 return yfs_fs_store_data(fc, mapping, first, last, offset, to, scb);
1210
1211 _enter(",%x,{%llx:%llu},,",
1212 key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1213
1214 size = (loff_t)to - (loff_t)offset;
1215 if (first != last)
1216 size += (loff_t)(last - first) << PAGE_SHIFT;
1217 pos = (loff_t)first << PAGE_SHIFT;
1218 pos += offset;
1219
1220 i_size = i_size_read(&vnode->vfs_inode);
1221 if (pos + size > i_size)
1222 i_size = size + pos;
1223
1224 _debug("size %llx, at %llx, i_size %llx",
1225 (unsigned long long) size, (unsigned long long) pos,
1226 (unsigned long long) i_size);
1227
1228 if (pos >> 32 || i_size >> 32 || size >> 32 || (pos + size) >> 32)
1229 return afs_fs_store_data64(fc, mapping, first, last, offset, to,
1230 size, pos, i_size, scb);
1231
1232 call = afs_alloc_flat_call(net, &afs_RXFSStoreData,
1233 (4 + 6 + 3) * 4,
1234 (21 + 6) * 4);
1235 if (!call)
1236 return -ENOMEM;
1237
1238 call->key = fc->key;
1239 call->mapping = mapping;
1240 call->first = first;
1241 call->last = last;
1242 call->first_offset = offset;
1243 call->last_to = to;
1244 call->send_pages = true;
1245 call->out_scb = scb;
1246
1247
1248 bp = call->request;
1249 *bp++ = htonl(FSSTOREDATA);
1250 *bp++ = htonl(vnode->fid.vid);
1251 *bp++ = htonl(vnode->fid.vnode);
1252 *bp++ = htonl(vnode->fid.unique);
1253
1254 *bp++ = htonl(AFS_SET_MTIME);
1255 *bp++ = htonl(vnode->vfs_inode.i_mtime.tv_sec);
1256 *bp++ = 0;
1257 *bp++ = 0;
1258 *bp++ = 0;
1259 *bp++ = 0;
1260
1261 *bp++ = htonl(pos);
1262 *bp++ = htonl(size);
1263 *bp++ = htonl(i_size);
1264
1265 afs_use_fs_server(call, fc->cbi);
1266 trace_afs_make_fs_call(call, &vnode->fid);
1267 afs_set_fc_call(call, fc);
1268 afs_make_call(&fc->ac, call, GFP_NOFS);
1269 return afs_wait_for_call_to_complete(call, &fc->ac);
1270 }
1271
1272
1273
1274
1275 static int afs_deliver_fs_store_status(struct afs_call *call)
1276 {
1277 const __be32 *bp;
1278 int ret;
1279
1280 _enter("");
1281
1282 ret = afs_transfer_reply(call);
1283 if (ret < 0)
1284 return ret;
1285
1286
1287 bp = call->buffer;
1288 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
1289 if (ret < 0)
1290 return ret;
1291 xdr_decode_AFSVolSync(&bp, call->out_volsync);
1292
1293 _leave(" = 0 [done]");
1294 return 0;
1295 }
1296
1297
1298
1299
1300 static const struct afs_call_type afs_RXFSStoreStatus = {
1301 .name = "FS.StoreStatus",
1302 .op = afs_FS_StoreStatus,
1303 .deliver = afs_deliver_fs_store_status,
1304 .destructor = afs_flat_call_destructor,
1305 };
1306
1307 static const struct afs_call_type afs_RXFSStoreData_as_Status = {
1308 .name = "FS.StoreData",
1309 .op = afs_FS_StoreData,
1310 .deliver = afs_deliver_fs_store_status,
1311 .destructor = afs_flat_call_destructor,
1312 };
1313
1314 static const struct afs_call_type afs_RXFSStoreData64_as_Status = {
1315 .name = "FS.StoreData64",
1316 .op = afs_FS_StoreData64,
1317 .deliver = afs_deliver_fs_store_status,
1318 .destructor = afs_flat_call_destructor,
1319 };
1320
1321
1322
1323
1324
1325 static int afs_fs_setattr_size64(struct afs_fs_cursor *fc, struct iattr *attr,
1326 struct afs_status_cb *scb)
1327 {
1328 struct afs_vnode *vnode = fc->vnode;
1329 struct afs_call *call;
1330 struct afs_net *net = afs_v2net(vnode);
1331 __be32 *bp;
1332
1333 _enter(",%x,{%llx:%llu},,",
1334 key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1335
1336 ASSERT(attr->ia_valid & ATTR_SIZE);
1337
1338 call = afs_alloc_flat_call(net, &afs_RXFSStoreData64_as_Status,
1339 (4 + 6 + 3 * 2) * 4,
1340 (21 + 6) * 4);
1341 if (!call)
1342 return -ENOMEM;
1343
1344 call->key = fc->key;
1345 call->out_scb = scb;
1346
1347
1348 bp = call->request;
1349 *bp++ = htonl(FSSTOREDATA64);
1350 *bp++ = htonl(vnode->fid.vid);
1351 *bp++ = htonl(vnode->fid.vnode);
1352 *bp++ = htonl(vnode->fid.unique);
1353
1354 xdr_encode_AFS_StoreStatus(&bp, attr);
1355
1356 *bp++ = htonl(attr->ia_size >> 32);
1357 *bp++ = htonl((u32) attr->ia_size);
1358 *bp++ = 0;
1359 *bp++ = 0;
1360 *bp++ = htonl(attr->ia_size >> 32);
1361 *bp++ = htonl((u32) attr->ia_size);
1362
1363 afs_use_fs_server(call, fc->cbi);
1364 trace_afs_make_fs_call(call, &vnode->fid);
1365 afs_set_fc_call(call, fc);
1366 afs_make_call(&fc->ac, call, GFP_NOFS);
1367 return afs_wait_for_call_to_complete(call, &fc->ac);
1368 }
1369
1370
1371
1372
1373
1374 static int afs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr,
1375 struct afs_status_cb *scb)
1376 {
1377 struct afs_vnode *vnode = fc->vnode;
1378 struct afs_call *call;
1379 struct afs_net *net = afs_v2net(vnode);
1380 __be32 *bp;
1381
1382 _enter(",%x,{%llx:%llu},,",
1383 key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1384
1385 ASSERT(attr->ia_valid & ATTR_SIZE);
1386 if (attr->ia_size >> 32)
1387 return afs_fs_setattr_size64(fc, attr, scb);
1388
1389 call = afs_alloc_flat_call(net, &afs_RXFSStoreData_as_Status,
1390 (4 + 6 + 3) * 4,
1391 (21 + 6) * 4);
1392 if (!call)
1393 return -ENOMEM;
1394
1395 call->key = fc->key;
1396 call->out_scb = scb;
1397
1398
1399 bp = call->request;
1400 *bp++ = htonl(FSSTOREDATA);
1401 *bp++ = htonl(vnode->fid.vid);
1402 *bp++ = htonl(vnode->fid.vnode);
1403 *bp++ = htonl(vnode->fid.unique);
1404
1405 xdr_encode_AFS_StoreStatus(&bp, attr);
1406
1407 *bp++ = htonl(attr->ia_size);
1408 *bp++ = 0;
1409 *bp++ = htonl(attr->ia_size);
1410
1411 afs_use_fs_server(call, fc->cbi);
1412 trace_afs_make_fs_call(call, &vnode->fid);
1413 afs_set_fc_call(call, fc);
1414 afs_make_call(&fc->ac, call, GFP_NOFS);
1415 return afs_wait_for_call_to_complete(call, &fc->ac);
1416 }
1417
1418
1419
1420
1421
1422 int afs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr,
1423 struct afs_status_cb *scb)
1424 {
1425 struct afs_vnode *vnode = fc->vnode;
1426 struct afs_call *call;
1427 struct afs_net *net = afs_v2net(vnode);
1428 __be32 *bp;
1429
1430 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1431 return yfs_fs_setattr(fc, attr, scb);
1432
1433 if (attr->ia_valid & ATTR_SIZE)
1434 return afs_fs_setattr_size(fc, attr, scb);
1435
1436 _enter(",%x,{%llx:%llu},,",
1437 key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1438
1439 call = afs_alloc_flat_call(net, &afs_RXFSStoreStatus,
1440 (4 + 6) * 4,
1441 (21 + 6) * 4);
1442 if (!call)
1443 return -ENOMEM;
1444
1445 call->key = fc->key;
1446 call->out_scb = scb;
1447
1448
1449 bp = call->request;
1450 *bp++ = htonl(FSSTORESTATUS);
1451 *bp++ = htonl(vnode->fid.vid);
1452 *bp++ = htonl(vnode->fid.vnode);
1453 *bp++ = htonl(vnode->fid.unique);
1454
1455 xdr_encode_AFS_StoreStatus(&bp, attr);
1456
1457 afs_use_fs_server(call, fc->cbi);
1458 trace_afs_make_fs_call(call, &vnode->fid);
1459 afs_set_fc_call(call, fc);
1460 afs_make_call(&fc->ac, call, GFP_NOFS);
1461 return afs_wait_for_call_to_complete(call, &fc->ac);
1462 }
1463
1464
1465
1466
1467 static int afs_deliver_fs_get_volume_status(struct afs_call *call)
1468 {
1469 const __be32 *bp;
1470 char *p;
1471 u32 size;
1472 int ret;
1473
1474 _enter("{%u}", call->unmarshall);
1475
1476 switch (call->unmarshall) {
1477 case 0:
1478 call->unmarshall++;
1479 afs_extract_to_buf(call, 12 * 4);
1480
1481
1482
1483 case 1:
1484 _debug("extract status");
1485 ret = afs_extract_data(call, true);
1486 if (ret < 0)
1487 return ret;
1488
1489 bp = call->buffer;
1490 xdr_decode_AFSFetchVolumeStatus(&bp, call->out_volstatus);
1491 call->unmarshall++;
1492 afs_extract_to_tmp(call);
1493
1494
1495
1496 case 2:
1497 ret = afs_extract_data(call, true);
1498 if (ret < 0)
1499 return ret;
1500
1501 call->count = ntohl(call->tmp);
1502 _debug("volname length: %u", call->count);
1503 if (call->count >= AFSNAMEMAX)
1504 return afs_protocol_error(call, -EBADMSG,
1505 afs_eproto_volname_len);
1506 size = (call->count + 3) & ~3;
1507 afs_extract_to_buf(call, size);
1508 call->unmarshall++;
1509
1510
1511
1512 case 3:
1513 _debug("extract volname");
1514 ret = afs_extract_data(call, true);
1515 if (ret < 0)
1516 return ret;
1517
1518 p = call->buffer;
1519 p[call->count] = 0;
1520 _debug("volname '%s'", p);
1521 afs_extract_to_tmp(call);
1522 call->unmarshall++;
1523
1524
1525
1526 case 4:
1527 ret = afs_extract_data(call, true);
1528 if (ret < 0)
1529 return ret;
1530
1531 call->count = ntohl(call->tmp);
1532 _debug("offline msg length: %u", call->count);
1533 if (call->count >= AFSNAMEMAX)
1534 return afs_protocol_error(call, -EBADMSG,
1535 afs_eproto_offline_msg_len);
1536 size = (call->count + 3) & ~3;
1537 afs_extract_to_buf(call, size);
1538 call->unmarshall++;
1539
1540
1541
1542 case 5:
1543 _debug("extract offline");
1544 ret = afs_extract_data(call, true);
1545 if (ret < 0)
1546 return ret;
1547
1548 p = call->buffer;
1549 p[call->count] = 0;
1550 _debug("offline '%s'", p);
1551
1552 afs_extract_to_tmp(call);
1553 call->unmarshall++;
1554
1555
1556
1557 case 6:
1558 ret = afs_extract_data(call, true);
1559 if (ret < 0)
1560 return ret;
1561
1562 call->count = ntohl(call->tmp);
1563 _debug("motd length: %u", call->count);
1564 if (call->count >= AFSNAMEMAX)
1565 return afs_protocol_error(call, -EBADMSG,
1566 afs_eproto_motd_len);
1567 size = (call->count + 3) & ~3;
1568 afs_extract_to_buf(call, size);
1569 call->unmarshall++;
1570
1571
1572
1573 case 7:
1574 _debug("extract motd");
1575 ret = afs_extract_data(call, false);
1576 if (ret < 0)
1577 return ret;
1578
1579 p = call->buffer;
1580 p[call->count] = 0;
1581 _debug("motd '%s'", p);
1582
1583 call->unmarshall++;
1584
1585 case 8:
1586 break;
1587 }
1588
1589 _leave(" = 0 [done]");
1590 return 0;
1591 }
1592
1593
1594
1595
1596 static const struct afs_call_type afs_RXFSGetVolumeStatus = {
1597 .name = "FS.GetVolumeStatus",
1598 .op = afs_FS_GetVolumeStatus,
1599 .deliver = afs_deliver_fs_get_volume_status,
1600 .destructor = afs_flat_call_destructor,
1601 };
1602
1603
1604
1605
1606 int afs_fs_get_volume_status(struct afs_fs_cursor *fc,
1607 struct afs_volume_status *vs)
1608 {
1609 struct afs_vnode *vnode = fc->vnode;
1610 struct afs_call *call;
1611 struct afs_net *net = afs_v2net(vnode);
1612 __be32 *bp;
1613
1614 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1615 return yfs_fs_get_volume_status(fc, vs);
1616
1617 _enter("");
1618
1619 call = afs_alloc_flat_call(net, &afs_RXFSGetVolumeStatus, 2 * 4,
1620 max(12 * 4, AFSOPAQUEMAX + 1));
1621 if (!call)
1622 return -ENOMEM;
1623
1624 call->key = fc->key;
1625 call->out_volstatus = vs;
1626
1627
1628 bp = call->request;
1629 bp[0] = htonl(FSGETVOLUMESTATUS);
1630 bp[1] = htonl(vnode->fid.vid);
1631
1632 afs_use_fs_server(call, fc->cbi);
1633 trace_afs_make_fs_call(call, &vnode->fid);
1634 afs_set_fc_call(call, fc);
1635 afs_make_call(&fc->ac, call, GFP_NOFS);
1636 return afs_wait_for_call_to_complete(call, &fc->ac);
1637 }
1638
1639
1640
1641
1642 static int afs_deliver_fs_xxxx_lock(struct afs_call *call)
1643 {
1644 const __be32 *bp;
1645 int ret;
1646
1647 _enter("{%u}", call->unmarshall);
1648
1649 ret = afs_transfer_reply(call);
1650 if (ret < 0)
1651 return ret;
1652
1653
1654 bp = call->buffer;
1655 xdr_decode_AFSVolSync(&bp, call->out_volsync);
1656
1657 _leave(" = 0 [done]");
1658 return 0;
1659 }
1660
1661
1662
1663
1664 static const struct afs_call_type afs_RXFSSetLock = {
1665 .name = "FS.SetLock",
1666 .op = afs_FS_SetLock,
1667 .deliver = afs_deliver_fs_xxxx_lock,
1668 .done = afs_lock_op_done,
1669 .destructor = afs_flat_call_destructor,
1670 };
1671
1672
1673
1674
1675 static const struct afs_call_type afs_RXFSExtendLock = {
1676 .name = "FS.ExtendLock",
1677 .op = afs_FS_ExtendLock,
1678 .deliver = afs_deliver_fs_xxxx_lock,
1679 .done = afs_lock_op_done,
1680 .destructor = afs_flat_call_destructor,
1681 };
1682
1683
1684
1685
1686 static const struct afs_call_type afs_RXFSReleaseLock = {
1687 .name = "FS.ReleaseLock",
1688 .op = afs_FS_ReleaseLock,
1689 .deliver = afs_deliver_fs_xxxx_lock,
1690 .destructor = afs_flat_call_destructor,
1691 };
1692
1693
1694
1695
1696 int afs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type,
1697 struct afs_status_cb *scb)
1698 {
1699 struct afs_vnode *vnode = fc->vnode;
1700 struct afs_call *call;
1701 struct afs_net *net = afs_v2net(vnode);
1702 __be32 *bp;
1703
1704 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1705 return yfs_fs_set_lock(fc, type, scb);
1706
1707 _enter("");
1708
1709 call = afs_alloc_flat_call(net, &afs_RXFSSetLock, 5 * 4, 6 * 4);
1710 if (!call)
1711 return -ENOMEM;
1712
1713 call->key = fc->key;
1714 call->lvnode = vnode;
1715 call->out_scb = scb;
1716
1717
1718 bp = call->request;
1719 *bp++ = htonl(FSSETLOCK);
1720 *bp++ = htonl(vnode->fid.vid);
1721 *bp++ = htonl(vnode->fid.vnode);
1722 *bp++ = htonl(vnode->fid.unique);
1723 *bp++ = htonl(type);
1724
1725 afs_use_fs_server(call, fc->cbi);
1726 trace_afs_make_fs_calli(call, &vnode->fid, type);
1727 afs_set_fc_call(call, fc);
1728 afs_make_call(&fc->ac, call, GFP_NOFS);
1729 return afs_wait_for_call_to_complete(call, &fc->ac);
1730 }
1731
1732
1733
1734
1735 int afs_fs_extend_lock(struct afs_fs_cursor *fc, struct afs_status_cb *scb)
1736 {
1737 struct afs_vnode *vnode = fc->vnode;
1738 struct afs_call *call;
1739 struct afs_net *net = afs_v2net(vnode);
1740 __be32 *bp;
1741
1742 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1743 return yfs_fs_extend_lock(fc, scb);
1744
1745 _enter("");
1746
1747 call = afs_alloc_flat_call(net, &afs_RXFSExtendLock, 4 * 4, 6 * 4);
1748 if (!call)
1749 return -ENOMEM;
1750
1751 call->key = fc->key;
1752 call->lvnode = vnode;
1753 call->out_scb = scb;
1754
1755
1756 bp = call->request;
1757 *bp++ = htonl(FSEXTENDLOCK);
1758 *bp++ = htonl(vnode->fid.vid);
1759 *bp++ = htonl(vnode->fid.vnode);
1760 *bp++ = htonl(vnode->fid.unique);
1761
1762 afs_use_fs_server(call, fc->cbi);
1763 trace_afs_make_fs_call(call, &vnode->fid);
1764 afs_set_fc_call(call, fc);
1765 afs_make_call(&fc->ac, call, GFP_NOFS);
1766 return afs_wait_for_call_to_complete(call, &fc->ac);
1767 }
1768
1769
1770
1771
1772 int afs_fs_release_lock(struct afs_fs_cursor *fc, struct afs_status_cb *scb)
1773 {
1774 struct afs_vnode *vnode = fc->vnode;
1775 struct afs_call *call;
1776 struct afs_net *net = afs_v2net(vnode);
1777 __be32 *bp;
1778
1779 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1780 return yfs_fs_release_lock(fc, scb);
1781
1782 _enter("");
1783
1784 call = afs_alloc_flat_call(net, &afs_RXFSReleaseLock, 4 * 4, 6 * 4);
1785 if (!call)
1786 return -ENOMEM;
1787
1788 call->key = fc->key;
1789 call->lvnode = vnode;
1790 call->out_scb = scb;
1791
1792
1793 bp = call->request;
1794 *bp++ = htonl(FSRELEASELOCK);
1795 *bp++ = htonl(vnode->fid.vid);
1796 *bp++ = htonl(vnode->fid.vnode);
1797 *bp++ = htonl(vnode->fid.unique);
1798
1799 afs_use_fs_server(call, fc->cbi);
1800 trace_afs_make_fs_call(call, &vnode->fid);
1801 afs_set_fc_call(call, fc);
1802 afs_make_call(&fc->ac, call, GFP_NOFS);
1803 return afs_wait_for_call_to_complete(call, &fc->ac);
1804 }
1805
1806
1807
1808
1809 static int afs_deliver_fs_give_up_all_callbacks(struct afs_call *call)
1810 {
1811 return afs_transfer_reply(call);
1812 }
1813
1814
1815
1816
1817 static const struct afs_call_type afs_RXFSGiveUpAllCallBacks = {
1818 .name = "FS.GiveUpAllCallBacks",
1819 .op = afs_FS_GiveUpAllCallBacks,
1820 .deliver = afs_deliver_fs_give_up_all_callbacks,
1821 .destructor = afs_flat_call_destructor,
1822 };
1823
1824
1825
1826
1827 int afs_fs_give_up_all_callbacks(struct afs_net *net,
1828 struct afs_server *server,
1829 struct afs_addr_cursor *ac,
1830 struct key *key)
1831 {
1832 struct afs_call *call;
1833 __be32 *bp;
1834
1835 _enter("");
1836
1837 call = afs_alloc_flat_call(net, &afs_RXFSGiveUpAllCallBacks, 1 * 4, 0);
1838 if (!call)
1839 return -ENOMEM;
1840
1841 call->key = key;
1842
1843
1844 bp = call->request;
1845 *bp++ = htonl(FSGIVEUPALLCALLBACKS);
1846
1847
1848 afs_make_call(ac, call, GFP_NOFS);
1849 return afs_wait_for_call_to_complete(call, ac);
1850 }
1851
1852
1853
1854
1855 static int afs_deliver_fs_get_capabilities(struct afs_call *call)
1856 {
1857 u32 count;
1858 int ret;
1859
1860 _enter("{%u,%zu}", call->unmarshall, iov_iter_count(&call->iter));
1861
1862 switch (call->unmarshall) {
1863 case 0:
1864 afs_extract_to_tmp(call);
1865 call->unmarshall++;
1866
1867
1868
1869 case 1:
1870 ret = afs_extract_data(call, true);
1871 if (ret < 0)
1872 return ret;
1873
1874 count = ntohl(call->tmp);
1875
1876 call->count = count;
1877 call->count2 = count;
1878 afs_extract_discard(call, count * sizeof(__be32));
1879 call->unmarshall++;
1880
1881
1882
1883 case 2:
1884 ret = afs_extract_data(call, false);
1885 if (ret < 0)
1886 return ret;
1887
1888
1889
1890 call->unmarshall++;
1891 break;
1892 }
1893
1894 _leave(" = 0 [done]");
1895 return 0;
1896 }
1897
1898
1899
1900
1901 static const struct afs_call_type afs_RXFSGetCapabilities = {
1902 .name = "FS.GetCapabilities",
1903 .op = afs_FS_GetCapabilities,
1904 .deliver = afs_deliver_fs_get_capabilities,
1905 .done = afs_fileserver_probe_result,
1906 .destructor = afs_flat_call_destructor,
1907 };
1908
1909
1910
1911
1912
1913 struct afs_call *afs_fs_get_capabilities(struct afs_net *net,
1914 struct afs_server *server,
1915 struct afs_addr_cursor *ac,
1916 struct key *key,
1917 unsigned int server_index)
1918 {
1919 struct afs_call *call;
1920 __be32 *bp;
1921
1922 _enter("");
1923
1924 call = afs_alloc_flat_call(net, &afs_RXFSGetCapabilities, 1 * 4, 16 * 4);
1925 if (!call)
1926 return ERR_PTR(-ENOMEM);
1927
1928 call->key = key;
1929 call->server = afs_get_server(server, afs_server_trace_get_caps);
1930 call->server_index = server_index;
1931 call->upgrade = true;
1932 call->async = true;
1933 call->max_lifespan = AFS_PROBE_MAX_LIFESPAN;
1934
1935
1936 bp = call->request;
1937 *bp++ = htonl(FSGETCAPABILITIES);
1938
1939
1940 trace_afs_make_fs_call(call, NULL);
1941 afs_make_call(ac, call, GFP_NOFS);
1942 return call;
1943 }
1944
1945
1946
1947
1948 static int afs_deliver_fs_fetch_status(struct afs_call *call)
1949 {
1950 const __be32 *bp;
1951 int ret;
1952
1953 ret = afs_transfer_reply(call);
1954 if (ret < 0)
1955 return ret;
1956
1957
1958 bp = call->buffer;
1959 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
1960 if (ret < 0)
1961 return ret;
1962 xdr_decode_AFSCallBack(&bp, call, call->out_scb);
1963 xdr_decode_AFSVolSync(&bp, call->out_volsync);
1964
1965 _leave(" = 0 [done]");
1966 return 0;
1967 }
1968
1969
1970
1971
1972 static const struct afs_call_type afs_RXFSFetchStatus = {
1973 .name = "FS.FetchStatus",
1974 .op = afs_FS_FetchStatus,
1975 .deliver = afs_deliver_fs_fetch_status,
1976 .destructor = afs_flat_call_destructor,
1977 };
1978
1979
1980
1981
1982 int afs_fs_fetch_status(struct afs_fs_cursor *fc,
1983 struct afs_net *net,
1984 struct afs_fid *fid,
1985 struct afs_status_cb *scb,
1986 struct afs_volsync *volsync)
1987 {
1988 struct afs_call *call;
1989 __be32 *bp;
1990
1991 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1992 return yfs_fs_fetch_status(fc, net, fid, scb, volsync);
1993
1994 _enter(",%x,{%llx:%llu},,",
1995 key_serial(fc->key), fid->vid, fid->vnode);
1996
1997 call = afs_alloc_flat_call(net, &afs_RXFSFetchStatus, 16, (21 + 3 + 6) * 4);
1998 if (!call) {
1999 fc->ac.error = -ENOMEM;
2000 return -ENOMEM;
2001 }
2002
2003 call->key = fc->key;
2004 call->out_fid = fid;
2005 call->out_scb = scb;
2006 call->out_volsync = volsync;
2007
2008
2009 bp = call->request;
2010 bp[0] = htonl(FSFETCHSTATUS);
2011 bp[1] = htonl(fid->vid);
2012 bp[2] = htonl(fid->vnode);
2013 bp[3] = htonl(fid->unique);
2014
2015 afs_use_fs_server(call, fc->cbi);
2016 trace_afs_make_fs_call(call, fid);
2017 afs_set_fc_call(call, fc);
2018 afs_make_call(&fc->ac, call, GFP_NOFS);
2019 return afs_wait_for_call_to_complete(call, &fc->ac);
2020 }
2021
2022
2023
2024
2025 static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
2026 {
2027 struct afs_status_cb *scb;
2028 const __be32 *bp;
2029 u32 tmp;
2030 int ret;
2031
2032 _enter("{%u}", call->unmarshall);
2033
2034 switch (call->unmarshall) {
2035 case 0:
2036 afs_extract_to_tmp(call);
2037 call->unmarshall++;
2038
2039
2040
2041 case 1:
2042 _debug("extract status count");
2043 ret = afs_extract_data(call, true);
2044 if (ret < 0)
2045 return ret;
2046
2047 tmp = ntohl(call->tmp);
2048 _debug("status count: %u/%u", tmp, call->count2);
2049 if (tmp != call->count2)
2050 return afs_protocol_error(call, -EBADMSG,
2051 afs_eproto_ibulkst_count);
2052
2053 call->count = 0;
2054 call->unmarshall++;
2055 more_counts:
2056 afs_extract_to_buf(call, 21 * sizeof(__be32));
2057
2058
2059 case 2:
2060 _debug("extract status array %u", call->count);
2061 ret = afs_extract_data(call, true);
2062 if (ret < 0)
2063 return ret;
2064
2065 bp = call->buffer;
2066 scb = &call->out_scb[call->count];
2067 ret = xdr_decode_AFSFetchStatus(&bp, call, scb);
2068 if (ret < 0)
2069 return ret;
2070
2071 call->count++;
2072 if (call->count < call->count2)
2073 goto more_counts;
2074
2075 call->count = 0;
2076 call->unmarshall++;
2077 afs_extract_to_tmp(call);
2078
2079
2080
2081 case 3:
2082 _debug("extract CB count");
2083 ret = afs_extract_data(call, true);
2084 if (ret < 0)
2085 return ret;
2086
2087 tmp = ntohl(call->tmp);
2088 _debug("CB count: %u", tmp);
2089 if (tmp != call->count2)
2090 return afs_protocol_error(call, -EBADMSG,
2091 afs_eproto_ibulkst_cb_count);
2092 call->count = 0;
2093 call->unmarshall++;
2094 more_cbs:
2095 afs_extract_to_buf(call, 3 * sizeof(__be32));
2096
2097
2098 case 4:
2099 _debug("extract CB array");
2100 ret = afs_extract_data(call, true);
2101 if (ret < 0)
2102 return ret;
2103
2104 _debug("unmarshall CB array");
2105 bp = call->buffer;
2106 scb = &call->out_scb[call->count];
2107 xdr_decode_AFSCallBack(&bp, call, scb);
2108 call->count++;
2109 if (call->count < call->count2)
2110 goto more_cbs;
2111
2112 afs_extract_to_buf(call, 6 * sizeof(__be32));
2113 call->unmarshall++;
2114
2115
2116 case 5:
2117 ret = afs_extract_data(call, false);
2118 if (ret < 0)
2119 return ret;
2120
2121 bp = call->buffer;
2122 xdr_decode_AFSVolSync(&bp, call->out_volsync);
2123
2124 call->unmarshall++;
2125
2126 case 6:
2127 break;
2128 }
2129
2130 _leave(" = 0 [done]");
2131 return 0;
2132 }
2133
2134
2135
2136
2137 static const struct afs_call_type afs_RXFSInlineBulkStatus = {
2138 .name = "FS.InlineBulkStatus",
2139 .op = afs_FS_InlineBulkStatus,
2140 .deliver = afs_deliver_fs_inline_bulk_status,
2141 .destructor = afs_flat_call_destructor,
2142 };
2143
2144
2145
2146
2147 int afs_fs_inline_bulk_status(struct afs_fs_cursor *fc,
2148 struct afs_net *net,
2149 struct afs_fid *fids,
2150 struct afs_status_cb *statuses,
2151 unsigned int nr_fids,
2152 struct afs_volsync *volsync)
2153 {
2154 struct afs_call *call;
2155 __be32 *bp;
2156 int i;
2157
2158 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
2159 return yfs_fs_inline_bulk_status(fc, net, fids, statuses,
2160 nr_fids, volsync);
2161
2162 _enter(",%x,{%llx:%llu},%u",
2163 key_serial(fc->key), fids[0].vid, fids[1].vnode, nr_fids);
2164
2165 call = afs_alloc_flat_call(net, &afs_RXFSInlineBulkStatus,
2166 (2 + nr_fids * 3) * 4,
2167 21 * 4);
2168 if (!call) {
2169 fc->ac.error = -ENOMEM;
2170 return -ENOMEM;
2171 }
2172
2173 call->key = fc->key;
2174 call->out_scb = statuses;
2175 call->out_volsync = volsync;
2176 call->count2 = nr_fids;
2177
2178
2179 bp = call->request;
2180 *bp++ = htonl(FSINLINEBULKSTATUS);
2181 *bp++ = htonl(nr_fids);
2182 for (i = 0; i < nr_fids; i++) {
2183 *bp++ = htonl(fids[i].vid);
2184 *bp++ = htonl(fids[i].vnode);
2185 *bp++ = htonl(fids[i].unique);
2186 }
2187
2188 afs_use_fs_server(call, fc->cbi);
2189 trace_afs_make_fs_call(call, &fids[0]);
2190 afs_set_fc_call(call, fc);
2191 afs_make_call(&fc->ac, call, GFP_NOFS);
2192 return afs_wait_for_call_to_complete(call, &fc->ac);
2193 }
2194
2195
2196
2197
2198 static int afs_deliver_fs_fetch_acl(struct afs_call *call)
2199 {
2200 struct afs_acl *acl;
2201 const __be32 *bp;
2202 unsigned int size;
2203 int ret;
2204
2205 _enter("{%u}", call->unmarshall);
2206
2207 switch (call->unmarshall) {
2208 case 0:
2209 afs_extract_to_tmp(call);
2210 call->unmarshall++;
2211
2212
2213
2214 case 1:
2215 ret = afs_extract_data(call, true);
2216 if (ret < 0)
2217 return ret;
2218
2219 size = call->count2 = ntohl(call->tmp);
2220 size = round_up(size, 4);
2221
2222 acl = kmalloc(struct_size(acl, data, size), GFP_KERNEL);
2223 if (!acl)
2224 return -ENOMEM;
2225 call->ret_acl = acl;
2226 acl->size = call->count2;
2227 afs_extract_begin(call, acl->data, size);
2228 call->unmarshall++;
2229
2230
2231
2232 case 2:
2233 ret = afs_extract_data(call, true);
2234 if (ret < 0)
2235 return ret;
2236
2237 afs_extract_to_buf(call, (21 + 6) * 4);
2238 call->unmarshall++;
2239
2240
2241
2242 case 3:
2243 ret = afs_extract_data(call, false);
2244 if (ret < 0)
2245 return ret;
2246
2247 bp = call->buffer;
2248 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
2249 if (ret < 0)
2250 return ret;
2251 xdr_decode_AFSVolSync(&bp, call->out_volsync);
2252
2253 call->unmarshall++;
2254
2255 case 4:
2256 break;
2257 }
2258
2259 _leave(" = 0 [done]");
2260 return 0;
2261 }
2262
2263 static void afs_destroy_fs_fetch_acl(struct afs_call *call)
2264 {
2265 kfree(call->ret_acl);
2266 afs_flat_call_destructor(call);
2267 }
2268
2269
2270
2271
2272 static const struct afs_call_type afs_RXFSFetchACL = {
2273 .name = "FS.FetchACL",
2274 .op = afs_FS_FetchACL,
2275 .deliver = afs_deliver_fs_fetch_acl,
2276 .destructor = afs_destroy_fs_fetch_acl,
2277 };
2278
2279
2280
2281
2282 struct afs_acl *afs_fs_fetch_acl(struct afs_fs_cursor *fc,
2283 struct afs_status_cb *scb)
2284 {
2285 struct afs_vnode *vnode = fc->vnode;
2286 struct afs_call *call;
2287 struct afs_net *net = afs_v2net(vnode);
2288 __be32 *bp;
2289
2290 _enter(",%x,{%llx:%llu},,",
2291 key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
2292
2293 call = afs_alloc_flat_call(net, &afs_RXFSFetchACL, 16, (21 + 6) * 4);
2294 if (!call) {
2295 fc->ac.error = -ENOMEM;
2296 return ERR_PTR(-ENOMEM);
2297 }
2298
2299 call->key = fc->key;
2300 call->ret_acl = NULL;
2301 call->out_scb = scb;
2302 call->out_volsync = NULL;
2303
2304
2305 bp = call->request;
2306 bp[0] = htonl(FSFETCHACL);
2307 bp[1] = htonl(vnode->fid.vid);
2308 bp[2] = htonl(vnode->fid.vnode);
2309 bp[3] = htonl(vnode->fid.unique);
2310
2311 afs_use_fs_server(call, fc->cbi);
2312 trace_afs_make_fs_call(call, &vnode->fid);
2313 afs_make_call(&fc->ac, call, GFP_KERNEL);
2314 return (struct afs_acl *)afs_wait_for_call_to_complete(call, &fc->ac);
2315 }
2316
2317
2318
2319
2320
2321 static int afs_deliver_fs_file_status_and_vol(struct afs_call *call)
2322 {
2323 const __be32 *bp;
2324 int ret;
2325
2326 ret = afs_transfer_reply(call);
2327 if (ret < 0)
2328 return ret;
2329
2330 bp = call->buffer;
2331 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
2332 if (ret < 0)
2333 return ret;
2334 xdr_decode_AFSVolSync(&bp, call->out_volsync);
2335
2336 _leave(" = 0 [done]");
2337 return 0;
2338 }
2339
2340
2341
2342
2343 static const struct afs_call_type afs_RXFSStoreACL = {
2344 .name = "FS.StoreACL",
2345 .op = afs_FS_StoreACL,
2346 .deliver = afs_deliver_fs_file_status_and_vol,
2347 .destructor = afs_flat_call_destructor,
2348 };
2349
2350
2351
2352
2353 int afs_fs_store_acl(struct afs_fs_cursor *fc, const struct afs_acl *acl,
2354 struct afs_status_cb *scb)
2355 {
2356 struct afs_vnode *vnode = fc->vnode;
2357 struct afs_call *call;
2358 struct afs_net *net = afs_v2net(vnode);
2359 size_t size;
2360 __be32 *bp;
2361
2362 _enter(",%x,{%llx:%llu},,",
2363 key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
2364
2365 size = round_up(acl->size, 4);
2366 call = afs_alloc_flat_call(net, &afs_RXFSStoreACL,
2367 5 * 4 + size, (21 + 6) * 4);
2368 if (!call) {
2369 fc->ac.error = -ENOMEM;
2370 return -ENOMEM;
2371 }
2372
2373 call->key = fc->key;
2374 call->out_scb = scb;
2375 call->out_volsync = NULL;
2376
2377
2378 bp = call->request;
2379 bp[0] = htonl(FSSTOREACL);
2380 bp[1] = htonl(vnode->fid.vid);
2381 bp[2] = htonl(vnode->fid.vnode);
2382 bp[3] = htonl(vnode->fid.unique);
2383 bp[4] = htonl(acl->size);
2384 memcpy(&bp[5], acl->data, acl->size);
2385 if (acl->size != size)
2386 memset((void *)&bp[5] + acl->size, 0, size - acl->size);
2387
2388 trace_afs_make_fs_call(call, &vnode->fid);
2389 afs_make_call(&fc->ac, call, GFP_KERNEL);
2390 return afs_wait_for_call_to_complete(call, &fc->ac);
2391 }