xref: /openbmc/linux/fs/afs/fsclient.c (revision f8bcb061)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* AFS File Server client stubs
3  *
4  * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
5  * Written by David Howells (dhowells@redhat.com)
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 <linux/netfs.h>
14 #include "internal.h"
15 #include "afs_fs.h"
16 #include "xdr_fs.h"
17 
18 /*
19  * decode an AFSFid block
20  */
21 static void xdr_decode_AFSFid(const __be32 **_bp, struct afs_fid *fid)
22 {
23 	const __be32 *bp = *_bp;
24 
25 	fid->vid		= ntohl(*bp++);
26 	fid->vnode		= ntohl(*bp++);
27 	fid->unique		= ntohl(*bp++);
28 	*_bp = bp;
29 }
30 
31 /*
32  * Dump a bad file status record.
33  */
34 static void xdr_dump_bad(const __be32 *bp)
35 {
36 	__be32 x[4];
37 	int i;
38 
39 	pr_notice("AFS XDR: Bad status record\n");
40 	for (i = 0; i < 5 * 4 * 4; i += 16) {
41 		memcpy(x, bp, 16);
42 		bp += 4;
43 		pr_notice("%03x: %08x %08x %08x %08x\n",
44 			  i, ntohl(x[0]), ntohl(x[1]), ntohl(x[2]), ntohl(x[3]));
45 	}
46 
47 	memcpy(x, bp, 4);
48 	pr_notice("0x50: %08x\n", ntohl(x[0]));
49 }
50 
51 /*
52  * decode an AFSFetchStatus block
53  */
54 static void xdr_decode_AFSFetchStatus(const __be32 **_bp,
55 				      struct afs_call *call,
56 				      struct afs_status_cb *scb)
57 {
58 	const struct afs_xdr_AFSFetchStatus *xdr = (const void *)*_bp;
59 	struct afs_file_status *status = &scb->status;
60 	bool inline_error = (call->operation_ID == afs_FS_InlineBulkStatus);
61 	u64 data_version, size;
62 	u32 type, abort_code;
63 
64 	abort_code = ntohl(xdr->abort_code);
65 
66 	if (xdr->if_version != htonl(AFS_FSTATUS_VERSION)) {
67 		if (xdr->if_version == htonl(0) &&
68 		    abort_code != 0 &&
69 		    inline_error) {
70 			/* The OpenAFS fileserver has a bug in FS.InlineBulkStatus
71 			 * whereby it doesn't set the interface version in the error
72 			 * case.
73 			 */
74 			status->abort_code = abort_code;
75 			scb->have_error = true;
76 			goto advance;
77 		}
78 
79 		pr_warn("Unknown AFSFetchStatus version %u\n", ntohl(xdr->if_version));
80 		goto bad;
81 	}
82 
83 	if (abort_code != 0 && inline_error) {
84 		status->abort_code = abort_code;
85 		scb->have_error = true;
86 		goto advance;
87 	}
88 
89 	type = ntohl(xdr->type);
90 	switch (type) {
91 	case AFS_FTYPE_FILE:
92 	case AFS_FTYPE_DIR:
93 	case AFS_FTYPE_SYMLINK:
94 		status->type = type;
95 		break;
96 	default:
97 		goto bad;
98 	}
99 
100 	status->nlink		= ntohl(xdr->nlink);
101 	status->author		= ntohl(xdr->author);
102 	status->owner		= ntohl(xdr->owner);
103 	status->caller_access	= ntohl(xdr->caller_access); /* Ticket dependent */
104 	status->anon_access	= ntohl(xdr->anon_access);
105 	status->mode		= ntohl(xdr->mode) & S_IALLUGO;
106 	status->group		= ntohl(xdr->group);
107 	status->lock_count	= ntohl(xdr->lock_count);
108 
109 	status->mtime_client.tv_sec = ntohl(xdr->mtime_client);
110 	status->mtime_client.tv_nsec = 0;
111 	status->mtime_server.tv_sec = ntohl(xdr->mtime_server);
112 	status->mtime_server.tv_nsec = 0;
113 
114 	size  = (u64)ntohl(xdr->size_lo);
115 	size |= (u64)ntohl(xdr->size_hi) << 32;
116 	status->size = size;
117 
118 	data_version  = (u64)ntohl(xdr->data_version_lo);
119 	data_version |= (u64)ntohl(xdr->data_version_hi) << 32;
120 	status->data_version = data_version;
121 	scb->have_status = true;
122 advance:
123 	*_bp = (const void *)*_bp + sizeof(*xdr);
124 	return;
125 
126 bad:
127 	xdr_dump_bad(*_bp);
128 	afs_protocol_error(call, afs_eproto_bad_status);
129 	goto advance;
130 }
131 
132 static time64_t xdr_decode_expiry(struct afs_call *call, u32 expiry)
133 {
134 	return ktime_divns(call->reply_time, NSEC_PER_SEC) + expiry;
135 }
136 
137 static void xdr_decode_AFSCallBack(const __be32 **_bp,
138 				   struct afs_call *call,
139 				   struct afs_status_cb *scb)
140 {
141 	struct afs_callback *cb = &scb->callback;
142 	const __be32 *bp = *_bp;
143 
144 	bp++; /* version */
145 	cb->expires_at	= xdr_decode_expiry(call, ntohl(*bp++));
146 	bp++; /* type */
147 	scb->have_cb	= true;
148 	*_bp = bp;
149 }
150 
151 /*
152  * decode an AFSVolSync block
153  */
154 static void xdr_decode_AFSVolSync(const __be32 **_bp,
155 				  struct afs_volsync *volsync)
156 {
157 	const __be32 *bp = *_bp;
158 	u32 creation;
159 
160 	creation = ntohl(*bp++);
161 	bp++; /* spare2 */
162 	bp++; /* spare3 */
163 	bp++; /* spare4 */
164 	bp++; /* spare5 */
165 	bp++; /* spare6 */
166 	*_bp = bp;
167 
168 	if (volsync)
169 		volsync->creation = creation;
170 }
171 
172 /*
173  * encode the requested attributes into an AFSStoreStatus block
174  */
175 static void xdr_encode_AFS_StoreStatus(__be32 **_bp, struct iattr *attr)
176 {
177 	__be32 *bp = *_bp;
178 	u32 mask = 0, mtime = 0, owner = 0, group = 0, mode = 0;
179 
180 	mask = 0;
181 	if (attr->ia_valid & ATTR_MTIME) {
182 		mask |= AFS_SET_MTIME;
183 		mtime = attr->ia_mtime.tv_sec;
184 	}
185 
186 	if (attr->ia_valid & ATTR_UID) {
187 		mask |= AFS_SET_OWNER;
188 		owner = from_kuid(&init_user_ns, attr->ia_uid);
189 	}
190 
191 	if (attr->ia_valid & ATTR_GID) {
192 		mask |= AFS_SET_GROUP;
193 		group = from_kgid(&init_user_ns, attr->ia_gid);
194 	}
195 
196 	if (attr->ia_valid & ATTR_MODE) {
197 		mask |= AFS_SET_MODE;
198 		mode = attr->ia_mode & S_IALLUGO;
199 	}
200 
201 	*bp++ = htonl(mask);
202 	*bp++ = htonl(mtime);
203 	*bp++ = htonl(owner);
204 	*bp++ = htonl(group);
205 	*bp++ = htonl(mode);
206 	*bp++ = 0;		/* segment size */
207 	*_bp = bp;
208 }
209 
210 /*
211  * decode an AFSFetchVolumeStatus block
212  */
213 static void xdr_decode_AFSFetchVolumeStatus(const __be32 **_bp,
214 					    struct afs_volume_status *vs)
215 {
216 	const __be32 *bp = *_bp;
217 
218 	vs->vid			= ntohl(*bp++);
219 	vs->parent_id		= ntohl(*bp++);
220 	vs->online		= ntohl(*bp++);
221 	vs->in_service		= ntohl(*bp++);
222 	vs->blessed		= ntohl(*bp++);
223 	vs->needs_salvage	= ntohl(*bp++);
224 	vs->type		= ntohl(*bp++);
225 	vs->min_quota		= ntohl(*bp++);
226 	vs->max_quota		= ntohl(*bp++);
227 	vs->blocks_in_use	= ntohl(*bp++);
228 	vs->part_blocks_avail	= ntohl(*bp++);
229 	vs->part_max_blocks	= ntohl(*bp++);
230 	vs->vol_copy_date	= 0;
231 	vs->vol_backup_date	= 0;
232 	*_bp = bp;
233 }
234 
235 /*
236  * deliver reply data to an FS.FetchStatus
237  */
238 static int afs_deliver_fs_fetch_status(struct afs_call *call)
239 {
240 	struct afs_operation *op = call->op;
241 	struct afs_vnode_param *vp = &op->file[op->fetch_status.which];
242 	const __be32 *bp;
243 	int ret;
244 
245 	ret = afs_transfer_reply(call);
246 	if (ret < 0)
247 		return ret;
248 
249 	/* unmarshall the reply once we've received all of it */
250 	bp = call->buffer;
251 	xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
252 	xdr_decode_AFSCallBack(&bp, call, &vp->scb);
253 	xdr_decode_AFSVolSync(&bp, &op->volsync);
254 
255 	_leave(" = 0 [done]");
256 	return 0;
257 }
258 
259 /*
260  * FS.FetchStatus operation type
261  */
262 static const struct afs_call_type afs_RXFSFetchStatus = {
263 	.name		= "FS.FetchStatus",
264 	.op		= afs_FS_FetchStatus,
265 	.deliver	= afs_deliver_fs_fetch_status,
266 	.destructor	= afs_flat_call_destructor,
267 };
268 
269 /*
270  * fetch the status information for a file
271  */
272 void afs_fs_fetch_status(struct afs_operation *op)
273 {
274 	struct afs_vnode_param *vp = &op->file[op->fetch_status.which];
275 	struct afs_call *call;
276 	__be32 *bp;
277 
278 	_enter(",%x,{%llx:%llu},,",
279 	       key_serial(op->key), vp->fid.vid, vp->fid.vnode);
280 
281 	call = afs_alloc_flat_call(op->net, &afs_RXFSFetchStatus,
282 				   16, (21 + 3 + 6) * 4);
283 	if (!call)
284 		return afs_op_nomem(op);
285 
286 	/* marshall the parameters */
287 	bp = call->request;
288 	bp[0] = htonl(FSFETCHSTATUS);
289 	bp[1] = htonl(vp->fid.vid);
290 	bp[2] = htonl(vp->fid.vnode);
291 	bp[3] = htonl(vp->fid.unique);
292 
293 	trace_afs_make_fs_call(call, &vp->fid);
294 	afs_make_op_call(op, call, GFP_NOFS);
295 }
296 
297 /*
298  * deliver reply data to an FS.FetchData
299  */
300 static int afs_deliver_fs_fetch_data(struct afs_call *call)
301 {
302 	struct afs_operation *op = call->op;
303 	struct afs_vnode_param *vp = &op->file[0];
304 	struct afs_read *req = op->fetch.req;
305 	const __be32 *bp;
306 	int ret;
307 
308 	_enter("{%u,%zu,%zu/%llu}",
309 	       call->unmarshall, call->iov_len, iov_iter_count(call->iter),
310 	       req->actual_len);
311 
312 	switch (call->unmarshall) {
313 	case 0:
314 		req->actual_len = 0;
315 		call->unmarshall++;
316 		if (call->operation_ID == FSFETCHDATA64) {
317 			afs_extract_to_tmp64(call);
318 		} else {
319 			call->tmp_u = htonl(0);
320 			afs_extract_to_tmp(call);
321 		}
322 		fallthrough;
323 
324 		/* Extract the returned data length into
325 		 * ->actual_len.  This may indicate more or less data than was
326 		 * requested will be returned.
327 		 */
328 	case 1:
329 		_debug("extract data length");
330 		ret = afs_extract_data(call, true);
331 		if (ret < 0)
332 			return ret;
333 
334 		req->actual_len = be64_to_cpu(call->tmp64);
335 		_debug("DATA length: %llu", req->actual_len);
336 
337 		if (req->actual_len == 0)
338 			goto no_more_data;
339 
340 		call->iter = req->iter;
341 		call->iov_len = min(req->actual_len, req->len);
342 		call->unmarshall++;
343 		fallthrough;
344 
345 		/* extract the returned data */
346 	case 2:
347 		_debug("extract data %zu/%llu",
348 		       iov_iter_count(call->iter), req->actual_len);
349 
350 		ret = afs_extract_data(call, true);
351 		if (ret < 0)
352 			return ret;
353 
354 		call->iter = &call->def_iter;
355 		if (req->actual_len <= req->len)
356 			goto no_more_data;
357 
358 		/* Discard any excess data the server gave us */
359 		afs_extract_discard(call, req->actual_len - req->len);
360 		call->unmarshall = 3;
361 		fallthrough;
362 
363 	case 3:
364 		_debug("extract discard %zu/%llu",
365 		       iov_iter_count(call->iter), req->actual_len - req->len);
366 
367 		ret = afs_extract_data(call, true);
368 		if (ret < 0)
369 			return ret;
370 
371 	no_more_data:
372 		call->unmarshall = 4;
373 		afs_extract_to_buf(call, (21 + 3 + 6) * 4);
374 		fallthrough;
375 
376 		/* extract the metadata */
377 	case 4:
378 		ret = afs_extract_data(call, false);
379 		if (ret < 0)
380 			return ret;
381 
382 		bp = call->buffer;
383 		xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
384 		xdr_decode_AFSCallBack(&bp, call, &vp->scb);
385 		xdr_decode_AFSVolSync(&bp, &op->volsync);
386 
387 		req->data_version = vp->scb.status.data_version;
388 		req->file_size = vp->scb.status.size;
389 
390 		call->unmarshall++;
391 
392 	case 5:
393 		break;
394 	}
395 
396 	_leave(" = 0 [done]");
397 	return 0;
398 }
399 
400 /*
401  * FS.FetchData operation type
402  */
403 static const struct afs_call_type afs_RXFSFetchData = {
404 	.name		= "FS.FetchData",
405 	.op		= afs_FS_FetchData,
406 	.deliver	= afs_deliver_fs_fetch_data,
407 	.destructor	= afs_flat_call_destructor,
408 };
409 
410 static const struct afs_call_type afs_RXFSFetchData64 = {
411 	.name		= "FS.FetchData64",
412 	.op		= afs_FS_FetchData64,
413 	.deliver	= afs_deliver_fs_fetch_data,
414 	.destructor	= afs_flat_call_destructor,
415 };
416 
417 /*
418  * fetch data from a very large file
419  */
420 static void afs_fs_fetch_data64(struct afs_operation *op)
421 {
422 	struct afs_vnode_param *vp = &op->file[0];
423 	struct afs_read *req = op->fetch.req;
424 	struct afs_call *call;
425 	__be32 *bp;
426 
427 	_enter("");
428 
429 	call = afs_alloc_flat_call(op->net, &afs_RXFSFetchData64, 32, (21 + 3 + 6) * 4);
430 	if (!call)
431 		return afs_op_nomem(op);
432 
433 	/* marshall the parameters */
434 	bp = call->request;
435 	bp[0] = htonl(FSFETCHDATA64);
436 	bp[1] = htonl(vp->fid.vid);
437 	bp[2] = htonl(vp->fid.vnode);
438 	bp[3] = htonl(vp->fid.unique);
439 	bp[4] = htonl(upper_32_bits(req->pos));
440 	bp[5] = htonl(lower_32_bits(req->pos));
441 	bp[6] = 0;
442 	bp[7] = htonl(lower_32_bits(req->len));
443 
444 	trace_afs_make_fs_call(call, &vp->fid);
445 	afs_make_op_call(op, call, GFP_NOFS);
446 }
447 
448 /*
449  * fetch data from a file
450  */
451 void afs_fs_fetch_data(struct afs_operation *op)
452 {
453 	struct afs_vnode_param *vp = &op->file[0];
454 	struct afs_call *call;
455 	struct afs_read *req = op->fetch.req;
456 	__be32 *bp;
457 
458 	if (upper_32_bits(req->pos) ||
459 	    upper_32_bits(req->len) ||
460 	    upper_32_bits(req->pos + req->len))
461 		return afs_fs_fetch_data64(op);
462 
463 	_enter("");
464 
465 	call = afs_alloc_flat_call(op->net, &afs_RXFSFetchData, 24, (21 + 3 + 6) * 4);
466 	if (!call)
467 		return afs_op_nomem(op);
468 
469 	req->call_debug_id = call->debug_id;
470 
471 	/* marshall the parameters */
472 	bp = call->request;
473 	bp[0] = htonl(FSFETCHDATA);
474 	bp[1] = htonl(vp->fid.vid);
475 	bp[2] = htonl(vp->fid.vnode);
476 	bp[3] = htonl(vp->fid.unique);
477 	bp[4] = htonl(lower_32_bits(req->pos));
478 	bp[5] = htonl(lower_32_bits(req->len));
479 
480 	trace_afs_make_fs_call(call, &vp->fid);
481 	afs_make_op_call(op, call, GFP_NOFS);
482 }
483 
484 /*
485  * deliver reply data to an FS.CreateFile or an FS.MakeDir
486  */
487 static int afs_deliver_fs_create_vnode(struct afs_call *call)
488 {
489 	struct afs_operation *op = call->op;
490 	struct afs_vnode_param *dvp = &op->file[0];
491 	struct afs_vnode_param *vp = &op->file[1];
492 	const __be32 *bp;
493 	int ret;
494 
495 	ret = afs_transfer_reply(call);
496 	if (ret < 0)
497 		return ret;
498 
499 	/* unmarshall the reply once we've received all of it */
500 	bp = call->buffer;
501 	xdr_decode_AFSFid(&bp, &op->file[1].fid);
502 	xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
503 	xdr_decode_AFSFetchStatus(&bp, call, &dvp->scb);
504 	xdr_decode_AFSCallBack(&bp, call, &vp->scb);
505 	xdr_decode_AFSVolSync(&bp, &op->volsync);
506 
507 	_leave(" = 0 [done]");
508 	return 0;
509 }
510 
511 /*
512  * FS.CreateFile and FS.MakeDir operation type
513  */
514 static const struct afs_call_type afs_RXFSCreateFile = {
515 	.name		= "FS.CreateFile",
516 	.op		= afs_FS_CreateFile,
517 	.deliver	= afs_deliver_fs_create_vnode,
518 	.destructor	= afs_flat_call_destructor,
519 };
520 
521 /*
522  * Create a file.
523  */
524 void afs_fs_create_file(struct afs_operation *op)
525 {
526 	const struct qstr *name = &op->dentry->d_name;
527 	struct afs_vnode_param *dvp = &op->file[0];
528 	struct afs_call *call;
529 	size_t namesz, reqsz, padsz;
530 	__be32 *bp;
531 
532 	_enter("");
533 
534 	namesz = name->len;
535 	padsz = (4 - (namesz & 3)) & 3;
536 	reqsz = (5 * 4) + namesz + padsz + (6 * 4);
537 
538 	call = afs_alloc_flat_call(op->net, &afs_RXFSCreateFile,
539 				   reqsz, (3 + 21 + 21 + 3 + 6) * 4);
540 	if (!call)
541 		return afs_op_nomem(op);
542 
543 	/* marshall the parameters */
544 	bp = call->request;
545 	*bp++ = htonl(FSCREATEFILE);
546 	*bp++ = htonl(dvp->fid.vid);
547 	*bp++ = htonl(dvp->fid.vnode);
548 	*bp++ = htonl(dvp->fid.unique);
549 	*bp++ = htonl(namesz);
550 	memcpy(bp, name->name, namesz);
551 	bp = (void *) bp + namesz;
552 	if (padsz > 0) {
553 		memset(bp, 0, padsz);
554 		bp = (void *) bp + padsz;
555 	}
556 	*bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME);
557 	*bp++ = htonl(op->mtime.tv_sec); /* mtime */
558 	*bp++ = 0; /* owner */
559 	*bp++ = 0; /* group */
560 	*bp++ = htonl(op->create.mode & S_IALLUGO); /* unix mode */
561 	*bp++ = 0; /* segment size */
562 
563 	trace_afs_make_fs_call1(call, &dvp->fid, name);
564 	afs_make_op_call(op, call, GFP_NOFS);
565 }
566 
567 static const struct afs_call_type afs_RXFSMakeDir = {
568 	.name		= "FS.MakeDir",
569 	.op		= afs_FS_MakeDir,
570 	.deliver	= afs_deliver_fs_create_vnode,
571 	.destructor	= afs_flat_call_destructor,
572 };
573 
574 /*
575  * Create a new directory
576  */
577 void afs_fs_make_dir(struct afs_operation *op)
578 {
579 	const struct qstr *name = &op->dentry->d_name;
580 	struct afs_vnode_param *dvp = &op->file[0];
581 	struct afs_call *call;
582 	size_t namesz, reqsz, padsz;
583 	__be32 *bp;
584 
585 	_enter("");
586 
587 	namesz = name->len;
588 	padsz = (4 - (namesz & 3)) & 3;
589 	reqsz = (5 * 4) + namesz + padsz + (6 * 4);
590 
591 	call = afs_alloc_flat_call(op->net, &afs_RXFSMakeDir,
592 				   reqsz, (3 + 21 + 21 + 3 + 6) * 4);
593 	if (!call)
594 		return afs_op_nomem(op);
595 
596 	/* marshall the parameters */
597 	bp = call->request;
598 	*bp++ = htonl(FSMAKEDIR);
599 	*bp++ = htonl(dvp->fid.vid);
600 	*bp++ = htonl(dvp->fid.vnode);
601 	*bp++ = htonl(dvp->fid.unique);
602 	*bp++ = htonl(namesz);
603 	memcpy(bp, name->name, namesz);
604 	bp = (void *) bp + namesz;
605 	if (padsz > 0) {
606 		memset(bp, 0, padsz);
607 		bp = (void *) bp + padsz;
608 	}
609 	*bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME);
610 	*bp++ = htonl(op->mtime.tv_sec); /* mtime */
611 	*bp++ = 0; /* owner */
612 	*bp++ = 0; /* group */
613 	*bp++ = htonl(op->create.mode & S_IALLUGO); /* unix mode */
614 	*bp++ = 0; /* segment size */
615 
616 	trace_afs_make_fs_call1(call, &dvp->fid, name);
617 	afs_make_op_call(op, call, GFP_NOFS);
618 }
619 
620 /*
621  * Deliver reply data to any operation that returns status and volume sync.
622  */
623 static int afs_deliver_fs_file_status_and_vol(struct afs_call *call)
624 {
625 	struct afs_operation *op = call->op;
626 	struct afs_vnode_param *vp = &op->file[0];
627 	const __be32 *bp;
628 	int ret;
629 
630 	ret = afs_transfer_reply(call);
631 	if (ret < 0)
632 		return ret;
633 
634 	/* unmarshall the reply once we've received all of it */
635 	bp = call->buffer;
636 	xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
637 	xdr_decode_AFSVolSync(&bp, &op->volsync);
638 
639 	_leave(" = 0 [done]");
640 	return 0;
641 }
642 
643 /*
644  * FS.RemoveFile operation type
645  */
646 static const struct afs_call_type afs_RXFSRemoveFile = {
647 	.name		= "FS.RemoveFile",
648 	.op		= afs_FS_RemoveFile,
649 	.deliver	= afs_deliver_fs_file_status_and_vol,
650 	.destructor	= afs_flat_call_destructor,
651 };
652 
653 /*
654  * Remove a file.
655  */
656 void afs_fs_remove_file(struct afs_operation *op)
657 {
658 	const struct qstr *name = &op->dentry->d_name;
659 	struct afs_vnode_param *dvp = &op->file[0];
660 	struct afs_call *call;
661 	size_t namesz, reqsz, padsz;
662 	__be32 *bp;
663 
664 	_enter("");
665 
666 	namesz = name->len;
667 	padsz = (4 - (namesz & 3)) & 3;
668 	reqsz = (5 * 4) + namesz + padsz;
669 
670 	call = afs_alloc_flat_call(op->net, &afs_RXFSRemoveFile,
671 				   reqsz, (21 + 6) * 4);
672 	if (!call)
673 		return afs_op_nomem(op);
674 
675 	/* marshall the parameters */
676 	bp = call->request;
677 	*bp++ = htonl(FSREMOVEFILE);
678 	*bp++ = htonl(dvp->fid.vid);
679 	*bp++ = htonl(dvp->fid.vnode);
680 	*bp++ = htonl(dvp->fid.unique);
681 	*bp++ = htonl(namesz);
682 	memcpy(bp, name->name, namesz);
683 	bp = (void *) bp + namesz;
684 	if (padsz > 0) {
685 		memset(bp, 0, padsz);
686 		bp = (void *) bp + padsz;
687 	}
688 
689 	trace_afs_make_fs_call1(call, &dvp->fid, name);
690 	afs_make_op_call(op, call, GFP_NOFS);
691 }
692 
693 static const struct afs_call_type afs_RXFSRemoveDir = {
694 	.name		= "FS.RemoveDir",
695 	.op		= afs_FS_RemoveDir,
696 	.deliver	= afs_deliver_fs_file_status_and_vol,
697 	.destructor	= afs_flat_call_destructor,
698 };
699 
700 /*
701  * Remove a directory.
702  */
703 void afs_fs_remove_dir(struct afs_operation *op)
704 {
705 	const struct qstr *name = &op->dentry->d_name;
706 	struct afs_vnode_param *dvp = &op->file[0];
707 	struct afs_call *call;
708 	size_t namesz, reqsz, padsz;
709 	__be32 *bp;
710 
711 	_enter("");
712 
713 	namesz = name->len;
714 	padsz = (4 - (namesz & 3)) & 3;
715 	reqsz = (5 * 4) + namesz + padsz;
716 
717 	call = afs_alloc_flat_call(op->net, &afs_RXFSRemoveDir,
718 				   reqsz, (21 + 6) * 4);
719 	if (!call)
720 		return afs_op_nomem(op);
721 
722 	/* marshall the parameters */
723 	bp = call->request;
724 	*bp++ = htonl(FSREMOVEDIR);
725 	*bp++ = htonl(dvp->fid.vid);
726 	*bp++ = htonl(dvp->fid.vnode);
727 	*bp++ = htonl(dvp->fid.unique);
728 	*bp++ = htonl(namesz);
729 	memcpy(bp, name->name, namesz);
730 	bp = (void *) bp + namesz;
731 	if (padsz > 0) {
732 		memset(bp, 0, padsz);
733 		bp = (void *) bp + padsz;
734 	}
735 
736 	trace_afs_make_fs_call1(call, &dvp->fid, name);
737 	afs_make_op_call(op, call, GFP_NOFS);
738 }
739 
740 /*
741  * deliver reply data to an FS.Link
742  */
743 static int afs_deliver_fs_link(struct afs_call *call)
744 {
745 	struct afs_operation *op = call->op;
746 	struct afs_vnode_param *dvp = &op->file[0];
747 	struct afs_vnode_param *vp = &op->file[1];
748 	const __be32 *bp;
749 	int ret;
750 
751 	_enter("{%u}", call->unmarshall);
752 
753 	ret = afs_transfer_reply(call);
754 	if (ret < 0)
755 		return ret;
756 
757 	/* unmarshall the reply once we've received all of it */
758 	bp = call->buffer;
759 	xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
760 	xdr_decode_AFSFetchStatus(&bp, call, &dvp->scb);
761 	xdr_decode_AFSVolSync(&bp, &op->volsync);
762 
763 	_leave(" = 0 [done]");
764 	return 0;
765 }
766 
767 /*
768  * FS.Link operation type
769  */
770 static const struct afs_call_type afs_RXFSLink = {
771 	.name		= "FS.Link",
772 	.op		= afs_FS_Link,
773 	.deliver	= afs_deliver_fs_link,
774 	.destructor	= afs_flat_call_destructor,
775 };
776 
777 /*
778  * make a hard link
779  */
780 void afs_fs_link(struct afs_operation *op)
781 {
782 	const struct qstr *name = &op->dentry->d_name;
783 	struct afs_vnode_param *dvp = &op->file[0];
784 	struct afs_vnode_param *vp = &op->file[1];
785 	struct afs_call *call;
786 	size_t namesz, reqsz, padsz;
787 	__be32 *bp;
788 
789 	_enter("");
790 
791 	namesz = name->len;
792 	padsz = (4 - (namesz & 3)) & 3;
793 	reqsz = (5 * 4) + namesz + padsz + (3 * 4);
794 
795 	call = afs_alloc_flat_call(op->net, &afs_RXFSLink, reqsz, (21 + 21 + 6) * 4);
796 	if (!call)
797 		return afs_op_nomem(op);
798 
799 	/* marshall the parameters */
800 	bp = call->request;
801 	*bp++ = htonl(FSLINK);
802 	*bp++ = htonl(dvp->fid.vid);
803 	*bp++ = htonl(dvp->fid.vnode);
804 	*bp++ = htonl(dvp->fid.unique);
805 	*bp++ = htonl(namesz);
806 	memcpy(bp, name->name, namesz);
807 	bp = (void *) bp + namesz;
808 	if (padsz > 0) {
809 		memset(bp, 0, padsz);
810 		bp = (void *) bp + padsz;
811 	}
812 	*bp++ = htonl(vp->fid.vid);
813 	*bp++ = htonl(vp->fid.vnode);
814 	*bp++ = htonl(vp->fid.unique);
815 
816 	trace_afs_make_fs_call1(call, &vp->fid, name);
817 	afs_make_op_call(op, call, GFP_NOFS);
818 }
819 
820 /*
821  * deliver reply data to an FS.Symlink
822  */
823 static int afs_deliver_fs_symlink(struct afs_call *call)
824 {
825 	struct afs_operation *op = call->op;
826 	struct afs_vnode_param *dvp = &op->file[0];
827 	struct afs_vnode_param *vp = &op->file[1];
828 	const __be32 *bp;
829 	int ret;
830 
831 	_enter("{%u}", call->unmarshall);
832 
833 	ret = afs_transfer_reply(call);
834 	if (ret < 0)
835 		return ret;
836 
837 	/* unmarshall the reply once we've received all of it */
838 	bp = call->buffer;
839 	xdr_decode_AFSFid(&bp, &vp->fid);
840 	xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
841 	xdr_decode_AFSFetchStatus(&bp, call, &dvp->scb);
842 	xdr_decode_AFSVolSync(&bp, &op->volsync);
843 
844 	_leave(" = 0 [done]");
845 	return 0;
846 }
847 
848 /*
849  * FS.Symlink operation type
850  */
851 static const struct afs_call_type afs_RXFSSymlink = {
852 	.name		= "FS.Symlink",
853 	.op		= afs_FS_Symlink,
854 	.deliver	= afs_deliver_fs_symlink,
855 	.destructor	= afs_flat_call_destructor,
856 };
857 
858 /*
859  * create a symbolic link
860  */
861 void afs_fs_symlink(struct afs_operation *op)
862 {
863 	const struct qstr *name = &op->dentry->d_name;
864 	struct afs_vnode_param *dvp = &op->file[0];
865 	struct afs_call *call;
866 	size_t namesz, reqsz, padsz, c_namesz, c_padsz;
867 	__be32 *bp;
868 
869 	_enter("");
870 
871 	namesz = name->len;
872 	padsz = (4 - (namesz & 3)) & 3;
873 
874 	c_namesz = strlen(op->create.symlink);
875 	c_padsz = (4 - (c_namesz & 3)) & 3;
876 
877 	reqsz = (6 * 4) + namesz + padsz + c_namesz + c_padsz + (6 * 4);
878 
879 	call = afs_alloc_flat_call(op->net, &afs_RXFSSymlink, reqsz,
880 				   (3 + 21 + 21 + 6) * 4);
881 	if (!call)
882 		return afs_op_nomem(op);
883 
884 	/* marshall the parameters */
885 	bp = call->request;
886 	*bp++ = htonl(FSSYMLINK);
887 	*bp++ = htonl(dvp->fid.vid);
888 	*bp++ = htonl(dvp->fid.vnode);
889 	*bp++ = htonl(dvp->fid.unique);
890 	*bp++ = htonl(namesz);
891 	memcpy(bp, name->name, namesz);
892 	bp = (void *) bp + namesz;
893 	if (padsz > 0) {
894 		memset(bp, 0, padsz);
895 		bp = (void *) bp + padsz;
896 	}
897 	*bp++ = htonl(c_namesz);
898 	memcpy(bp, op->create.symlink, c_namesz);
899 	bp = (void *) bp + c_namesz;
900 	if (c_padsz > 0) {
901 		memset(bp, 0, c_padsz);
902 		bp = (void *) bp + c_padsz;
903 	}
904 	*bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME);
905 	*bp++ = htonl(op->mtime.tv_sec); /* mtime */
906 	*bp++ = 0; /* owner */
907 	*bp++ = 0; /* group */
908 	*bp++ = htonl(S_IRWXUGO); /* unix mode */
909 	*bp++ = 0; /* segment size */
910 
911 	trace_afs_make_fs_call1(call, &dvp->fid, name);
912 	afs_make_op_call(op, call, GFP_NOFS);
913 }
914 
915 /*
916  * deliver reply data to an FS.Rename
917  */
918 static int afs_deliver_fs_rename(struct afs_call *call)
919 {
920 	struct afs_operation *op = call->op;
921 	struct afs_vnode_param *orig_dvp = &op->file[0];
922 	struct afs_vnode_param *new_dvp = &op->file[1];
923 	const __be32 *bp;
924 	int ret;
925 
926 	ret = afs_transfer_reply(call);
927 	if (ret < 0)
928 		return ret;
929 
930 	bp = call->buffer;
931 	/* If the two dirs are the same, we have two copies of the same status
932 	 * report, so we just decode it twice.
933 	 */
934 	xdr_decode_AFSFetchStatus(&bp, call, &orig_dvp->scb);
935 	xdr_decode_AFSFetchStatus(&bp, call, &new_dvp->scb);
936 	xdr_decode_AFSVolSync(&bp, &op->volsync);
937 
938 	_leave(" = 0 [done]");
939 	return 0;
940 }
941 
942 /*
943  * FS.Rename operation type
944  */
945 static const struct afs_call_type afs_RXFSRename = {
946 	.name		= "FS.Rename",
947 	.op		= afs_FS_Rename,
948 	.deliver	= afs_deliver_fs_rename,
949 	.destructor	= afs_flat_call_destructor,
950 };
951 
952 /*
953  * Rename/move a file or directory.
954  */
955 void afs_fs_rename(struct afs_operation *op)
956 {
957 	struct afs_vnode_param *orig_dvp = &op->file[0];
958 	struct afs_vnode_param *new_dvp = &op->file[1];
959 	const struct qstr *orig_name = &op->dentry->d_name;
960 	const struct qstr *new_name = &op->dentry_2->d_name;
961 	struct afs_call *call;
962 	size_t reqsz, o_namesz, o_padsz, n_namesz, n_padsz;
963 	__be32 *bp;
964 
965 	_enter("");
966 
967 	o_namesz = orig_name->len;
968 	o_padsz = (4 - (o_namesz & 3)) & 3;
969 
970 	n_namesz = new_name->len;
971 	n_padsz = (4 - (n_namesz & 3)) & 3;
972 
973 	reqsz = (4 * 4) +
974 		4 + o_namesz + o_padsz +
975 		(3 * 4) +
976 		4 + n_namesz + n_padsz;
977 
978 	call = afs_alloc_flat_call(op->net, &afs_RXFSRename, reqsz, (21 + 21 + 6) * 4);
979 	if (!call)
980 		return afs_op_nomem(op);
981 
982 	/* marshall the parameters */
983 	bp = call->request;
984 	*bp++ = htonl(FSRENAME);
985 	*bp++ = htonl(orig_dvp->fid.vid);
986 	*bp++ = htonl(orig_dvp->fid.vnode);
987 	*bp++ = htonl(orig_dvp->fid.unique);
988 	*bp++ = htonl(o_namesz);
989 	memcpy(bp, orig_name->name, o_namesz);
990 	bp = (void *) bp + o_namesz;
991 	if (o_padsz > 0) {
992 		memset(bp, 0, o_padsz);
993 		bp = (void *) bp + o_padsz;
994 	}
995 
996 	*bp++ = htonl(new_dvp->fid.vid);
997 	*bp++ = htonl(new_dvp->fid.vnode);
998 	*bp++ = htonl(new_dvp->fid.unique);
999 	*bp++ = htonl(n_namesz);
1000 	memcpy(bp, new_name->name, n_namesz);
1001 	bp = (void *) bp + n_namesz;
1002 	if (n_padsz > 0) {
1003 		memset(bp, 0, n_padsz);
1004 		bp = (void *) bp + n_padsz;
1005 	}
1006 
1007 	trace_afs_make_fs_call2(call, &orig_dvp->fid, orig_name, new_name);
1008 	afs_make_op_call(op, call, GFP_NOFS);
1009 }
1010 
1011 /*
1012  * Deliver reply data to FS.StoreData or FS.StoreStatus
1013  */
1014 static int afs_deliver_fs_store_data(struct afs_call *call)
1015 {
1016 	struct afs_operation *op = call->op;
1017 	struct afs_vnode_param *vp = &op->file[0];
1018 	const __be32 *bp;
1019 	int ret;
1020 
1021 	_enter("");
1022 
1023 	ret = afs_transfer_reply(call);
1024 	if (ret < 0)
1025 		return ret;
1026 
1027 	/* unmarshall the reply once we've received all of it */
1028 	bp = call->buffer;
1029 	xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
1030 	xdr_decode_AFSVolSync(&bp, &op->volsync);
1031 
1032 	_leave(" = 0 [done]");
1033 	return 0;
1034 }
1035 
1036 /*
1037  * FS.StoreData operation type
1038  */
1039 static const struct afs_call_type afs_RXFSStoreData = {
1040 	.name		= "FS.StoreData",
1041 	.op		= afs_FS_StoreData,
1042 	.deliver	= afs_deliver_fs_store_data,
1043 	.destructor	= afs_flat_call_destructor,
1044 };
1045 
1046 static const struct afs_call_type afs_RXFSStoreData64 = {
1047 	.name		= "FS.StoreData64",
1048 	.op		= afs_FS_StoreData64,
1049 	.deliver	= afs_deliver_fs_store_data,
1050 	.destructor	= afs_flat_call_destructor,
1051 };
1052 
1053 /*
1054  * store a set of pages to a very large file
1055  */
1056 static void afs_fs_store_data64(struct afs_operation *op)
1057 {
1058 	struct afs_vnode_param *vp = &op->file[0];
1059 	struct afs_call *call;
1060 	__be32 *bp;
1061 
1062 	_enter(",%x,{%llx:%llu},,",
1063 	       key_serial(op->key), vp->fid.vid, vp->fid.vnode);
1064 
1065 	call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData64,
1066 				   (4 + 6 + 3 * 2) * 4,
1067 				   (21 + 6) * 4);
1068 	if (!call)
1069 		return afs_op_nomem(op);
1070 
1071 	call->write_iter = op->store.write_iter;
1072 
1073 	/* marshall the parameters */
1074 	bp = call->request;
1075 	*bp++ = htonl(FSSTOREDATA64);
1076 	*bp++ = htonl(vp->fid.vid);
1077 	*bp++ = htonl(vp->fid.vnode);
1078 	*bp++ = htonl(vp->fid.unique);
1079 
1080 	*bp++ = htonl(AFS_SET_MTIME); /* mask */
1081 	*bp++ = htonl(op->mtime.tv_sec); /* mtime */
1082 	*bp++ = 0; /* owner */
1083 	*bp++ = 0; /* group */
1084 	*bp++ = 0; /* unix mode */
1085 	*bp++ = 0; /* segment size */
1086 
1087 	*bp++ = htonl(upper_32_bits(op->store.pos));
1088 	*bp++ = htonl(lower_32_bits(op->store.pos));
1089 	*bp++ = htonl(upper_32_bits(op->store.size));
1090 	*bp++ = htonl(lower_32_bits(op->store.size));
1091 	*bp++ = htonl(upper_32_bits(op->store.i_size));
1092 	*bp++ = htonl(lower_32_bits(op->store.i_size));
1093 
1094 	trace_afs_make_fs_call(call, &vp->fid);
1095 	afs_make_op_call(op, call, GFP_NOFS);
1096 }
1097 
1098 /*
1099  * Write data to a file on the server.
1100  */
1101 void afs_fs_store_data(struct afs_operation *op)
1102 {
1103 	struct afs_vnode_param *vp = &op->file[0];
1104 	struct afs_call *call;
1105 	__be32 *bp;
1106 
1107 	_enter(",%x,{%llx:%llu},,",
1108 	       key_serial(op->key), vp->fid.vid, vp->fid.vnode);
1109 
1110 	_debug("size %llx, at %llx, i_size %llx",
1111 	       (unsigned long long)op->store.size,
1112 	       (unsigned long long)op->store.pos,
1113 	       (unsigned long long)op->store.i_size);
1114 
1115 	if (upper_32_bits(op->store.pos) ||
1116 	    upper_32_bits(op->store.size) ||
1117 	    upper_32_bits(op->store.i_size))
1118 		return afs_fs_store_data64(op);
1119 
1120 	call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData,
1121 				   (4 + 6 + 3) * 4,
1122 				   (21 + 6) * 4);
1123 	if (!call)
1124 		return afs_op_nomem(op);
1125 
1126 	call->write_iter = op->store.write_iter;
1127 
1128 	/* marshall the parameters */
1129 	bp = call->request;
1130 	*bp++ = htonl(FSSTOREDATA);
1131 	*bp++ = htonl(vp->fid.vid);
1132 	*bp++ = htonl(vp->fid.vnode);
1133 	*bp++ = htonl(vp->fid.unique);
1134 
1135 	*bp++ = htonl(AFS_SET_MTIME); /* mask */
1136 	*bp++ = htonl(op->mtime.tv_sec); /* mtime */
1137 	*bp++ = 0; /* owner */
1138 	*bp++ = 0; /* group */
1139 	*bp++ = 0; /* unix mode */
1140 	*bp++ = 0; /* segment size */
1141 
1142 	*bp++ = htonl(lower_32_bits(op->store.pos));
1143 	*bp++ = htonl(lower_32_bits(op->store.size));
1144 	*bp++ = htonl(lower_32_bits(op->store.i_size));
1145 
1146 	trace_afs_make_fs_call(call, &vp->fid);
1147 	afs_make_op_call(op, call, GFP_NOFS);
1148 }
1149 
1150 /*
1151  * FS.StoreStatus operation type
1152  */
1153 static const struct afs_call_type afs_RXFSStoreStatus = {
1154 	.name		= "FS.StoreStatus",
1155 	.op		= afs_FS_StoreStatus,
1156 	.deliver	= afs_deliver_fs_store_data,
1157 	.destructor	= afs_flat_call_destructor,
1158 };
1159 
1160 static const struct afs_call_type afs_RXFSStoreData_as_Status = {
1161 	.name		= "FS.StoreData",
1162 	.op		= afs_FS_StoreData,
1163 	.deliver	= afs_deliver_fs_store_data,
1164 	.destructor	= afs_flat_call_destructor,
1165 };
1166 
1167 static const struct afs_call_type afs_RXFSStoreData64_as_Status = {
1168 	.name		= "FS.StoreData64",
1169 	.op		= afs_FS_StoreData64,
1170 	.deliver	= afs_deliver_fs_store_data,
1171 	.destructor	= afs_flat_call_destructor,
1172 };
1173 
1174 /*
1175  * set the attributes on a very large file, using FS.StoreData rather than
1176  * FS.StoreStatus so as to alter the file size also
1177  */
1178 static void afs_fs_setattr_size64(struct afs_operation *op)
1179 {
1180 	struct afs_vnode_param *vp = &op->file[0];
1181 	struct afs_call *call;
1182 	struct iattr *attr = op->setattr.attr;
1183 	__be32 *bp;
1184 
1185 	_enter(",%x,{%llx:%llu},,",
1186 	       key_serial(op->key), vp->fid.vid, vp->fid.vnode);
1187 
1188 	ASSERT(attr->ia_valid & ATTR_SIZE);
1189 
1190 	call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData64_as_Status,
1191 				   (4 + 6 + 3 * 2) * 4,
1192 				   (21 + 6) * 4);
1193 	if (!call)
1194 		return afs_op_nomem(op);
1195 
1196 	/* marshall the parameters */
1197 	bp = call->request;
1198 	*bp++ = htonl(FSSTOREDATA64);
1199 	*bp++ = htonl(vp->fid.vid);
1200 	*bp++ = htonl(vp->fid.vnode);
1201 	*bp++ = htonl(vp->fid.unique);
1202 
1203 	xdr_encode_AFS_StoreStatus(&bp, attr);
1204 
1205 	*bp++ = htonl(upper_32_bits(attr->ia_size));	/* position of start of write */
1206 	*bp++ = htonl(lower_32_bits(attr->ia_size));
1207 	*bp++ = 0;					/* size of write */
1208 	*bp++ = 0;
1209 	*bp++ = htonl(upper_32_bits(attr->ia_size));	/* new file length */
1210 	*bp++ = htonl(lower_32_bits(attr->ia_size));
1211 
1212 	trace_afs_make_fs_call(call, &vp->fid);
1213 	afs_make_op_call(op, call, GFP_NOFS);
1214 }
1215 
1216 /*
1217  * set the attributes on a file, using FS.StoreData rather than FS.StoreStatus
1218  * so as to alter the file size also
1219  */
1220 static void afs_fs_setattr_size(struct afs_operation *op)
1221 {
1222 	struct afs_vnode_param *vp = &op->file[0];
1223 	struct afs_call *call;
1224 	struct iattr *attr = op->setattr.attr;
1225 	__be32 *bp;
1226 
1227 	_enter(",%x,{%llx:%llu},,",
1228 	       key_serial(op->key), vp->fid.vid, vp->fid.vnode);
1229 
1230 	ASSERT(attr->ia_valid & ATTR_SIZE);
1231 	if (upper_32_bits(attr->ia_size))
1232 		return afs_fs_setattr_size64(op);
1233 
1234 	call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData_as_Status,
1235 				   (4 + 6 + 3) * 4,
1236 				   (21 + 6) * 4);
1237 	if (!call)
1238 		return afs_op_nomem(op);
1239 
1240 	/* marshall the parameters */
1241 	bp = call->request;
1242 	*bp++ = htonl(FSSTOREDATA);
1243 	*bp++ = htonl(vp->fid.vid);
1244 	*bp++ = htonl(vp->fid.vnode);
1245 	*bp++ = htonl(vp->fid.unique);
1246 
1247 	xdr_encode_AFS_StoreStatus(&bp, attr);
1248 
1249 	*bp++ = htonl(attr->ia_size);		/* position of start of write */
1250 	*bp++ = 0;				/* size of write */
1251 	*bp++ = htonl(attr->ia_size);		/* new file length */
1252 
1253 	trace_afs_make_fs_call(call, &vp->fid);
1254 	afs_make_op_call(op, call, GFP_NOFS);
1255 }
1256 
1257 /*
1258  * set the attributes on a file, using FS.StoreData if there's a change in file
1259  * size, and FS.StoreStatus otherwise
1260  */
1261 void afs_fs_setattr(struct afs_operation *op)
1262 {
1263 	struct afs_vnode_param *vp = &op->file[0];
1264 	struct afs_call *call;
1265 	struct iattr *attr = op->setattr.attr;
1266 	__be32 *bp;
1267 
1268 	if (attr->ia_valid & ATTR_SIZE)
1269 		return afs_fs_setattr_size(op);
1270 
1271 	_enter(",%x,{%llx:%llu},,",
1272 	       key_serial(op->key), vp->fid.vid, vp->fid.vnode);
1273 
1274 	call = afs_alloc_flat_call(op->net, &afs_RXFSStoreStatus,
1275 				   (4 + 6) * 4,
1276 				   (21 + 6) * 4);
1277 	if (!call)
1278 		return afs_op_nomem(op);
1279 
1280 	/* marshall the parameters */
1281 	bp = call->request;
1282 	*bp++ = htonl(FSSTORESTATUS);
1283 	*bp++ = htonl(vp->fid.vid);
1284 	*bp++ = htonl(vp->fid.vnode);
1285 	*bp++ = htonl(vp->fid.unique);
1286 
1287 	xdr_encode_AFS_StoreStatus(&bp, op->setattr.attr);
1288 
1289 	trace_afs_make_fs_call(call, &vp->fid);
1290 	afs_make_op_call(op, call, GFP_NOFS);
1291 }
1292 
1293 /*
1294  * deliver reply data to an FS.GetVolumeStatus
1295  */
1296 static int afs_deliver_fs_get_volume_status(struct afs_call *call)
1297 {
1298 	struct afs_operation *op = call->op;
1299 	const __be32 *bp;
1300 	char *p;
1301 	u32 size;
1302 	int ret;
1303 
1304 	_enter("{%u}", call->unmarshall);
1305 
1306 	switch (call->unmarshall) {
1307 	case 0:
1308 		call->unmarshall++;
1309 		afs_extract_to_buf(call, 12 * 4);
1310 		fallthrough;
1311 
1312 		/* extract the returned status record */
1313 	case 1:
1314 		_debug("extract status");
1315 		ret = afs_extract_data(call, true);
1316 		if (ret < 0)
1317 			return ret;
1318 
1319 		bp = call->buffer;
1320 		xdr_decode_AFSFetchVolumeStatus(&bp, &op->volstatus.vs);
1321 		call->unmarshall++;
1322 		afs_extract_to_tmp(call);
1323 		fallthrough;
1324 
1325 		/* extract the volume name length */
1326 	case 2:
1327 		ret = afs_extract_data(call, true);
1328 		if (ret < 0)
1329 			return ret;
1330 
1331 		call->count = ntohl(call->tmp);
1332 		_debug("volname length: %u", call->count);
1333 		if (call->count >= AFSNAMEMAX)
1334 			return afs_protocol_error(call, afs_eproto_volname_len);
1335 		size = (call->count + 3) & ~3; /* It's padded */
1336 		afs_extract_to_buf(call, size);
1337 		call->unmarshall++;
1338 		fallthrough;
1339 
1340 		/* extract the volume name */
1341 	case 3:
1342 		_debug("extract volname");
1343 		ret = afs_extract_data(call, true);
1344 		if (ret < 0)
1345 			return ret;
1346 
1347 		p = call->buffer;
1348 		p[call->count] = 0;
1349 		_debug("volname '%s'", p);
1350 		afs_extract_to_tmp(call);
1351 		call->unmarshall++;
1352 		fallthrough;
1353 
1354 		/* extract the offline message length */
1355 	case 4:
1356 		ret = afs_extract_data(call, true);
1357 		if (ret < 0)
1358 			return ret;
1359 
1360 		call->count = ntohl(call->tmp);
1361 		_debug("offline msg length: %u", call->count);
1362 		if (call->count >= AFSNAMEMAX)
1363 			return afs_protocol_error(call, afs_eproto_offline_msg_len);
1364 		size = (call->count + 3) & ~3; /* It's padded */
1365 		afs_extract_to_buf(call, size);
1366 		call->unmarshall++;
1367 		fallthrough;
1368 
1369 		/* extract the offline message */
1370 	case 5:
1371 		_debug("extract offline");
1372 		ret = afs_extract_data(call, true);
1373 		if (ret < 0)
1374 			return ret;
1375 
1376 		p = call->buffer;
1377 		p[call->count] = 0;
1378 		_debug("offline '%s'", p);
1379 
1380 		afs_extract_to_tmp(call);
1381 		call->unmarshall++;
1382 		fallthrough;
1383 
1384 		/* extract the message of the day length */
1385 	case 6:
1386 		ret = afs_extract_data(call, true);
1387 		if (ret < 0)
1388 			return ret;
1389 
1390 		call->count = ntohl(call->tmp);
1391 		_debug("motd length: %u", call->count);
1392 		if (call->count >= AFSNAMEMAX)
1393 			return afs_protocol_error(call, afs_eproto_motd_len);
1394 		size = (call->count + 3) & ~3; /* It's padded */
1395 		afs_extract_to_buf(call, size);
1396 		call->unmarshall++;
1397 		fallthrough;
1398 
1399 		/* extract the message of the day */
1400 	case 7:
1401 		_debug("extract motd");
1402 		ret = afs_extract_data(call, false);
1403 		if (ret < 0)
1404 			return ret;
1405 
1406 		p = call->buffer;
1407 		p[call->count] = 0;
1408 		_debug("motd '%s'", p);
1409 
1410 		call->unmarshall++;
1411 
1412 	case 8:
1413 		break;
1414 	}
1415 
1416 	_leave(" = 0 [done]");
1417 	return 0;
1418 }
1419 
1420 /*
1421  * FS.GetVolumeStatus operation type
1422  */
1423 static const struct afs_call_type afs_RXFSGetVolumeStatus = {
1424 	.name		= "FS.GetVolumeStatus",
1425 	.op		= afs_FS_GetVolumeStatus,
1426 	.deliver	= afs_deliver_fs_get_volume_status,
1427 	.destructor	= afs_flat_call_destructor,
1428 };
1429 
1430 /*
1431  * fetch the status of a volume
1432  */
1433 void afs_fs_get_volume_status(struct afs_operation *op)
1434 {
1435 	struct afs_vnode_param *vp = &op->file[0];
1436 	struct afs_call *call;
1437 	__be32 *bp;
1438 
1439 	_enter("");
1440 
1441 	call = afs_alloc_flat_call(op->net, &afs_RXFSGetVolumeStatus, 2 * 4,
1442 				   max(12 * 4, AFSOPAQUEMAX + 1));
1443 	if (!call)
1444 		return afs_op_nomem(op);
1445 
1446 	/* marshall the parameters */
1447 	bp = call->request;
1448 	bp[0] = htonl(FSGETVOLUMESTATUS);
1449 	bp[1] = htonl(vp->fid.vid);
1450 
1451 	trace_afs_make_fs_call(call, &vp->fid);
1452 	afs_make_op_call(op, call, GFP_NOFS);
1453 }
1454 
1455 /*
1456  * deliver reply data to an FS.SetLock, FS.ExtendLock or FS.ReleaseLock
1457  */
1458 static int afs_deliver_fs_xxxx_lock(struct afs_call *call)
1459 {
1460 	struct afs_operation *op = call->op;
1461 	const __be32 *bp;
1462 	int ret;
1463 
1464 	_enter("{%u}", call->unmarshall);
1465 
1466 	ret = afs_transfer_reply(call);
1467 	if (ret < 0)
1468 		return ret;
1469 
1470 	/* unmarshall the reply once we've received all of it */
1471 	bp = call->buffer;
1472 	xdr_decode_AFSVolSync(&bp, &op->volsync);
1473 
1474 	_leave(" = 0 [done]");
1475 	return 0;
1476 }
1477 
1478 /*
1479  * FS.SetLock operation type
1480  */
1481 static const struct afs_call_type afs_RXFSSetLock = {
1482 	.name		= "FS.SetLock",
1483 	.op		= afs_FS_SetLock,
1484 	.deliver	= afs_deliver_fs_xxxx_lock,
1485 	.done		= afs_lock_op_done,
1486 	.destructor	= afs_flat_call_destructor,
1487 };
1488 
1489 /*
1490  * FS.ExtendLock operation type
1491  */
1492 static const struct afs_call_type afs_RXFSExtendLock = {
1493 	.name		= "FS.ExtendLock",
1494 	.op		= afs_FS_ExtendLock,
1495 	.deliver	= afs_deliver_fs_xxxx_lock,
1496 	.done		= afs_lock_op_done,
1497 	.destructor	= afs_flat_call_destructor,
1498 };
1499 
1500 /*
1501  * FS.ReleaseLock operation type
1502  */
1503 static const struct afs_call_type afs_RXFSReleaseLock = {
1504 	.name		= "FS.ReleaseLock",
1505 	.op		= afs_FS_ReleaseLock,
1506 	.deliver	= afs_deliver_fs_xxxx_lock,
1507 	.destructor	= afs_flat_call_destructor,
1508 };
1509 
1510 /*
1511  * Set a lock on a file
1512  */
1513 void afs_fs_set_lock(struct afs_operation *op)
1514 {
1515 	struct afs_vnode_param *vp = &op->file[0];
1516 	struct afs_call *call;
1517 	__be32 *bp;
1518 
1519 	_enter("");
1520 
1521 	call = afs_alloc_flat_call(op->net, &afs_RXFSSetLock, 5 * 4, 6 * 4);
1522 	if (!call)
1523 		return afs_op_nomem(op);
1524 
1525 	/* marshall the parameters */
1526 	bp = call->request;
1527 	*bp++ = htonl(FSSETLOCK);
1528 	*bp++ = htonl(vp->fid.vid);
1529 	*bp++ = htonl(vp->fid.vnode);
1530 	*bp++ = htonl(vp->fid.unique);
1531 	*bp++ = htonl(op->lock.type);
1532 
1533 	trace_afs_make_fs_calli(call, &vp->fid, op->lock.type);
1534 	afs_make_op_call(op, call, GFP_NOFS);
1535 }
1536 
1537 /*
1538  * extend a lock on a file
1539  */
1540 void afs_fs_extend_lock(struct afs_operation *op)
1541 {
1542 	struct afs_vnode_param *vp = &op->file[0];
1543 	struct afs_call *call;
1544 	__be32 *bp;
1545 
1546 	_enter("");
1547 
1548 	call = afs_alloc_flat_call(op->net, &afs_RXFSExtendLock, 4 * 4, 6 * 4);
1549 	if (!call)
1550 		return afs_op_nomem(op);
1551 
1552 	/* marshall the parameters */
1553 	bp = call->request;
1554 	*bp++ = htonl(FSEXTENDLOCK);
1555 	*bp++ = htonl(vp->fid.vid);
1556 	*bp++ = htonl(vp->fid.vnode);
1557 	*bp++ = htonl(vp->fid.unique);
1558 
1559 	trace_afs_make_fs_call(call, &vp->fid);
1560 	afs_make_op_call(op, call, GFP_NOFS);
1561 }
1562 
1563 /*
1564  * release a lock on a file
1565  */
1566 void afs_fs_release_lock(struct afs_operation *op)
1567 {
1568 	struct afs_vnode_param *vp = &op->file[0];
1569 	struct afs_call *call;
1570 	__be32 *bp;
1571 
1572 	_enter("");
1573 
1574 	call = afs_alloc_flat_call(op->net, &afs_RXFSReleaseLock, 4 * 4, 6 * 4);
1575 	if (!call)
1576 		return afs_op_nomem(op);
1577 
1578 	/* marshall the parameters */
1579 	bp = call->request;
1580 	*bp++ = htonl(FSRELEASELOCK);
1581 	*bp++ = htonl(vp->fid.vid);
1582 	*bp++ = htonl(vp->fid.vnode);
1583 	*bp++ = htonl(vp->fid.unique);
1584 
1585 	trace_afs_make_fs_call(call, &vp->fid);
1586 	afs_make_op_call(op, call, GFP_NOFS);
1587 }
1588 
1589 /*
1590  * Deliver reply data to an FS.GiveUpAllCallBacks operation.
1591  */
1592 static int afs_deliver_fs_give_up_all_callbacks(struct afs_call *call)
1593 {
1594 	return afs_transfer_reply(call);
1595 }
1596 
1597 /*
1598  * FS.GiveUpAllCallBacks operation type
1599  */
1600 static const struct afs_call_type afs_RXFSGiveUpAllCallBacks = {
1601 	.name		= "FS.GiveUpAllCallBacks",
1602 	.op		= afs_FS_GiveUpAllCallBacks,
1603 	.deliver	= afs_deliver_fs_give_up_all_callbacks,
1604 	.destructor	= afs_flat_call_destructor,
1605 };
1606 
1607 /*
1608  * Flush all the callbacks we have on a server.
1609  */
1610 int afs_fs_give_up_all_callbacks(struct afs_net *net,
1611 				 struct afs_server *server,
1612 				 struct afs_addr_cursor *ac,
1613 				 struct key *key)
1614 {
1615 	struct afs_call *call;
1616 	__be32 *bp;
1617 
1618 	_enter("");
1619 
1620 	call = afs_alloc_flat_call(net, &afs_RXFSGiveUpAllCallBacks, 1 * 4, 0);
1621 	if (!call)
1622 		return -ENOMEM;
1623 
1624 	call->key = key;
1625 
1626 	/* marshall the parameters */
1627 	bp = call->request;
1628 	*bp++ = htonl(FSGIVEUPALLCALLBACKS);
1629 
1630 	call->server = afs_use_server(server, afs_server_trace_give_up_cb);
1631 	afs_make_call(ac, call, GFP_NOFS);
1632 	return afs_wait_for_call_to_complete(call, ac);
1633 }
1634 
1635 /*
1636  * Deliver reply data to an FS.GetCapabilities operation.
1637  */
1638 static int afs_deliver_fs_get_capabilities(struct afs_call *call)
1639 {
1640 	u32 count;
1641 	int ret;
1642 
1643 	_enter("{%u,%zu}", call->unmarshall, iov_iter_count(call->iter));
1644 
1645 	switch (call->unmarshall) {
1646 	case 0:
1647 		afs_extract_to_tmp(call);
1648 		call->unmarshall++;
1649 		fallthrough;
1650 
1651 		/* Extract the capabilities word count */
1652 	case 1:
1653 		ret = afs_extract_data(call, true);
1654 		if (ret < 0)
1655 			return ret;
1656 
1657 		count = ntohl(call->tmp);
1658 
1659 		call->count = count;
1660 		call->count2 = count;
1661 		afs_extract_discard(call, count * sizeof(__be32));
1662 		call->unmarshall++;
1663 		fallthrough;
1664 
1665 		/* Extract capabilities words */
1666 	case 2:
1667 		ret = afs_extract_data(call, false);
1668 		if (ret < 0)
1669 			return ret;
1670 
1671 		/* TODO: Examine capabilities */
1672 
1673 		call->unmarshall++;
1674 		break;
1675 	}
1676 
1677 	_leave(" = 0 [done]");
1678 	return 0;
1679 }
1680 
1681 /*
1682  * FS.GetCapabilities operation type
1683  */
1684 static const struct afs_call_type afs_RXFSGetCapabilities = {
1685 	.name		= "FS.GetCapabilities",
1686 	.op		= afs_FS_GetCapabilities,
1687 	.deliver	= afs_deliver_fs_get_capabilities,
1688 	.done		= afs_fileserver_probe_result,
1689 	.destructor	= afs_flat_call_destructor,
1690 };
1691 
1692 /*
1693  * Probe a fileserver for the capabilities that it supports.  This RPC can
1694  * reply with up to 196 words.  The operation is asynchronous and if we managed
1695  * to allocate a call, true is returned the result is delivered through the
1696  * ->done() - otherwise we return false to indicate we didn't even try.
1697  */
1698 bool afs_fs_get_capabilities(struct afs_net *net, struct afs_server *server,
1699 			     struct afs_addr_cursor *ac, struct key *key)
1700 {
1701 	struct afs_call *call;
1702 	__be32 *bp;
1703 
1704 	_enter("");
1705 
1706 	call = afs_alloc_flat_call(net, &afs_RXFSGetCapabilities, 1 * 4, 16 * 4);
1707 	if (!call)
1708 		return false;
1709 
1710 	call->key = key;
1711 	call->server = afs_use_server(server, afs_server_trace_get_caps);
1712 	call->upgrade = true;
1713 	call->async = true;
1714 	call->max_lifespan = AFS_PROBE_MAX_LIFESPAN;
1715 
1716 	/* marshall the parameters */
1717 	bp = call->request;
1718 	*bp++ = htonl(FSGETCAPABILITIES);
1719 
1720 	trace_afs_make_fs_call(call, NULL);
1721 	afs_make_call(ac, call, GFP_NOFS);
1722 	afs_put_call(call);
1723 	return true;
1724 }
1725 
1726 /*
1727  * Deliver reply data to an FS.InlineBulkStatus call
1728  */
1729 static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
1730 {
1731 	struct afs_operation *op = call->op;
1732 	struct afs_status_cb *scb;
1733 	const __be32 *bp;
1734 	u32 tmp;
1735 	int ret;
1736 
1737 	_enter("{%u}", call->unmarshall);
1738 
1739 	switch (call->unmarshall) {
1740 	case 0:
1741 		afs_extract_to_tmp(call);
1742 		call->unmarshall++;
1743 		fallthrough;
1744 
1745 		/* Extract the file status count and array in two steps */
1746 	case 1:
1747 		_debug("extract status count");
1748 		ret = afs_extract_data(call, true);
1749 		if (ret < 0)
1750 			return ret;
1751 
1752 		tmp = ntohl(call->tmp);
1753 		_debug("status count: %u/%u", tmp, op->nr_files);
1754 		if (tmp != op->nr_files)
1755 			return afs_protocol_error(call, afs_eproto_ibulkst_count);
1756 
1757 		call->count = 0;
1758 		call->unmarshall++;
1759 	more_counts:
1760 		afs_extract_to_buf(call, 21 * sizeof(__be32));
1761 		fallthrough;
1762 
1763 	case 2:
1764 		_debug("extract status array %u", call->count);
1765 		ret = afs_extract_data(call, true);
1766 		if (ret < 0)
1767 			return ret;
1768 
1769 		switch (call->count) {
1770 		case 0:
1771 			scb = &op->file[0].scb;
1772 			break;
1773 		case 1:
1774 			scb = &op->file[1].scb;
1775 			break;
1776 		default:
1777 			scb = &op->more_files[call->count - 2].scb;
1778 			break;
1779 		}
1780 
1781 		bp = call->buffer;
1782 		xdr_decode_AFSFetchStatus(&bp, call, scb);
1783 
1784 		call->count++;
1785 		if (call->count < op->nr_files)
1786 			goto more_counts;
1787 
1788 		call->count = 0;
1789 		call->unmarshall++;
1790 		afs_extract_to_tmp(call);
1791 		fallthrough;
1792 
1793 		/* Extract the callback count and array in two steps */
1794 	case 3:
1795 		_debug("extract CB count");
1796 		ret = afs_extract_data(call, true);
1797 		if (ret < 0)
1798 			return ret;
1799 
1800 		tmp = ntohl(call->tmp);
1801 		_debug("CB count: %u", tmp);
1802 		if (tmp != op->nr_files)
1803 			return afs_protocol_error(call, afs_eproto_ibulkst_cb_count);
1804 		call->count = 0;
1805 		call->unmarshall++;
1806 	more_cbs:
1807 		afs_extract_to_buf(call, 3 * sizeof(__be32));
1808 		fallthrough;
1809 
1810 	case 4:
1811 		_debug("extract CB array");
1812 		ret = afs_extract_data(call, true);
1813 		if (ret < 0)
1814 			return ret;
1815 
1816 		_debug("unmarshall CB array");
1817 		switch (call->count) {
1818 		case 0:
1819 			scb = &op->file[0].scb;
1820 			break;
1821 		case 1:
1822 			scb = &op->file[1].scb;
1823 			break;
1824 		default:
1825 			scb = &op->more_files[call->count - 2].scb;
1826 			break;
1827 		}
1828 
1829 		bp = call->buffer;
1830 		xdr_decode_AFSCallBack(&bp, call, scb);
1831 		call->count++;
1832 		if (call->count < op->nr_files)
1833 			goto more_cbs;
1834 
1835 		afs_extract_to_buf(call, 6 * sizeof(__be32));
1836 		call->unmarshall++;
1837 		fallthrough;
1838 
1839 	case 5:
1840 		ret = afs_extract_data(call, false);
1841 		if (ret < 0)
1842 			return ret;
1843 
1844 		bp = call->buffer;
1845 		xdr_decode_AFSVolSync(&bp, &op->volsync);
1846 
1847 		call->unmarshall++;
1848 
1849 	case 6:
1850 		break;
1851 	}
1852 
1853 	_leave(" = 0 [done]");
1854 	return 0;
1855 }
1856 
1857 static void afs_done_fs_inline_bulk_status(struct afs_call *call)
1858 {
1859 	if (call->error == -ECONNABORTED &&
1860 	    call->abort_code == RX_INVALID_OPERATION) {
1861 		set_bit(AFS_SERVER_FL_NO_IBULK, &call->server->flags);
1862 		if (call->op)
1863 			set_bit(AFS_VOLUME_MAYBE_NO_IBULK, &call->op->volume->flags);
1864 	}
1865 }
1866 
1867 /*
1868  * FS.InlineBulkStatus operation type
1869  */
1870 static const struct afs_call_type afs_RXFSInlineBulkStatus = {
1871 	.name		= "FS.InlineBulkStatus",
1872 	.op		= afs_FS_InlineBulkStatus,
1873 	.deliver	= afs_deliver_fs_inline_bulk_status,
1874 	.done		= afs_done_fs_inline_bulk_status,
1875 	.destructor	= afs_flat_call_destructor,
1876 };
1877 
1878 /*
1879  * Fetch the status information for up to 50 files
1880  */
1881 void afs_fs_inline_bulk_status(struct afs_operation *op)
1882 {
1883 	struct afs_vnode_param *dvp = &op->file[0];
1884 	struct afs_vnode_param *vp = &op->file[1];
1885 	struct afs_call *call;
1886 	__be32 *bp;
1887 	int i;
1888 
1889 	if (test_bit(AFS_SERVER_FL_NO_IBULK, &op->server->flags)) {
1890 		op->error = -ENOTSUPP;
1891 		return;
1892 	}
1893 
1894 	_enter(",%x,{%llx:%llu},%u",
1895 	       key_serial(op->key), vp->fid.vid, vp->fid.vnode, op->nr_files);
1896 
1897 	call = afs_alloc_flat_call(op->net, &afs_RXFSInlineBulkStatus,
1898 				   (2 + op->nr_files * 3) * 4,
1899 				   21 * 4);
1900 	if (!call)
1901 		return afs_op_nomem(op);
1902 
1903 	/* marshall the parameters */
1904 	bp = call->request;
1905 	*bp++ = htonl(FSINLINEBULKSTATUS);
1906 	*bp++ = htonl(op->nr_files);
1907 	*bp++ = htonl(dvp->fid.vid);
1908 	*bp++ = htonl(dvp->fid.vnode);
1909 	*bp++ = htonl(dvp->fid.unique);
1910 	*bp++ = htonl(vp->fid.vid);
1911 	*bp++ = htonl(vp->fid.vnode);
1912 	*bp++ = htonl(vp->fid.unique);
1913 	for (i = 0; i < op->nr_files - 2; i++) {
1914 		*bp++ = htonl(op->more_files[i].fid.vid);
1915 		*bp++ = htonl(op->more_files[i].fid.vnode);
1916 		*bp++ = htonl(op->more_files[i].fid.unique);
1917 	}
1918 
1919 	trace_afs_make_fs_call(call, &vp->fid);
1920 	afs_make_op_call(op, call, GFP_NOFS);
1921 }
1922 
1923 /*
1924  * deliver reply data to an FS.FetchACL
1925  */
1926 static int afs_deliver_fs_fetch_acl(struct afs_call *call)
1927 {
1928 	struct afs_operation *op = call->op;
1929 	struct afs_vnode_param *vp = &op->file[0];
1930 	struct afs_acl *acl;
1931 	const __be32 *bp;
1932 	unsigned int size;
1933 	int ret;
1934 
1935 	_enter("{%u}", call->unmarshall);
1936 
1937 	switch (call->unmarshall) {
1938 	case 0:
1939 		afs_extract_to_tmp(call);
1940 		call->unmarshall++;
1941 		fallthrough;
1942 
1943 		/* extract the returned data length */
1944 	case 1:
1945 		ret = afs_extract_data(call, true);
1946 		if (ret < 0)
1947 			return ret;
1948 
1949 		size = call->count2 = ntohl(call->tmp);
1950 		size = round_up(size, 4);
1951 
1952 		acl = kmalloc(struct_size(acl, data, size), GFP_KERNEL);
1953 		if (!acl)
1954 			return -ENOMEM;
1955 		op->acl = acl;
1956 		acl->size = call->count2;
1957 		afs_extract_begin(call, acl->data, size);
1958 		call->unmarshall++;
1959 		fallthrough;
1960 
1961 		/* extract the returned data */
1962 	case 2:
1963 		ret = afs_extract_data(call, true);
1964 		if (ret < 0)
1965 			return ret;
1966 
1967 		afs_extract_to_buf(call, (21 + 6) * 4);
1968 		call->unmarshall++;
1969 		fallthrough;
1970 
1971 		/* extract the metadata */
1972 	case 3:
1973 		ret = afs_extract_data(call, false);
1974 		if (ret < 0)
1975 			return ret;
1976 
1977 		bp = call->buffer;
1978 		xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
1979 		xdr_decode_AFSVolSync(&bp, &op->volsync);
1980 
1981 		call->unmarshall++;
1982 
1983 	case 4:
1984 		break;
1985 	}
1986 
1987 	_leave(" = 0 [done]");
1988 	return 0;
1989 }
1990 
1991 /*
1992  * FS.FetchACL operation type
1993  */
1994 static const struct afs_call_type afs_RXFSFetchACL = {
1995 	.name		= "FS.FetchACL",
1996 	.op		= afs_FS_FetchACL,
1997 	.deliver	= afs_deliver_fs_fetch_acl,
1998 };
1999 
2000 /*
2001  * Fetch the ACL for a file.
2002  */
2003 void afs_fs_fetch_acl(struct afs_operation *op)
2004 {
2005 	struct afs_vnode_param *vp = &op->file[0];
2006 	struct afs_call *call;
2007 	__be32 *bp;
2008 
2009 	_enter(",%x,{%llx:%llu},,",
2010 	       key_serial(op->key), vp->fid.vid, vp->fid.vnode);
2011 
2012 	call = afs_alloc_flat_call(op->net, &afs_RXFSFetchACL, 16, (21 + 6) * 4);
2013 	if (!call)
2014 		return afs_op_nomem(op);
2015 
2016 	/* marshall the parameters */
2017 	bp = call->request;
2018 	bp[0] = htonl(FSFETCHACL);
2019 	bp[1] = htonl(vp->fid.vid);
2020 	bp[2] = htonl(vp->fid.vnode);
2021 	bp[3] = htonl(vp->fid.unique);
2022 
2023 	trace_afs_make_fs_call(call, &vp->fid);
2024 	afs_make_op_call(op, call, GFP_KERNEL);
2025 }
2026 
2027 /*
2028  * FS.StoreACL operation type
2029  */
2030 static const struct afs_call_type afs_RXFSStoreACL = {
2031 	.name		= "FS.StoreACL",
2032 	.op		= afs_FS_StoreACL,
2033 	.deliver	= afs_deliver_fs_file_status_and_vol,
2034 	.destructor	= afs_flat_call_destructor,
2035 };
2036 
2037 /*
2038  * Fetch the ACL for a file.
2039  */
2040 void afs_fs_store_acl(struct afs_operation *op)
2041 {
2042 	struct afs_vnode_param *vp = &op->file[0];
2043 	struct afs_call *call;
2044 	const struct afs_acl *acl = op->acl;
2045 	size_t size;
2046 	__be32 *bp;
2047 
2048 	_enter(",%x,{%llx:%llu},,",
2049 	       key_serial(op->key), vp->fid.vid, vp->fid.vnode);
2050 
2051 	size = round_up(acl->size, 4);
2052 	call = afs_alloc_flat_call(op->net, &afs_RXFSStoreACL,
2053 				   5 * 4 + size, (21 + 6) * 4);
2054 	if (!call)
2055 		return afs_op_nomem(op);
2056 
2057 	/* marshall the parameters */
2058 	bp = call->request;
2059 	bp[0] = htonl(FSSTOREACL);
2060 	bp[1] = htonl(vp->fid.vid);
2061 	bp[2] = htonl(vp->fid.vnode);
2062 	bp[3] = htonl(vp->fid.unique);
2063 	bp[4] = htonl(acl->size);
2064 	memcpy(&bp[5], acl->data, acl->size);
2065 	if (acl->size != size)
2066 		memset((void *)&bp[5] + acl->size, 0, size - acl->size);
2067 
2068 	trace_afs_make_fs_call(call, &vp->fid);
2069 	afs_make_op_call(op, call, GFP_KERNEL);
2070 }
2071