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