xref: /linux/fs/afs/fsclient.c (revision 781070551c26def14784ce5ca14194d7ca234b04)
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->reply[0];
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->reply[1]);
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->reply[0] = vnode;
454 	call->reply[1] = 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->reply[0];
480 	struct afs_read *req = call->reply[2];
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->reply[1]);
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->reply[2];
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->reply[0] = vnode;
645 	call->reply[1] = NULL; /* volsync */
646 	call->reply[2] = 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->reply[0] = vnode;
696 	call->reply[1] = NULL; /* volsync */
697 	call->reply[2] = 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 *vnode = call->reply[0];
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->reply[1]);
737 	ret = afs_decode_status(call, &bp, call->reply[2], NULL, NULL, NULL);
738 	if (ret < 0)
739 		return ret;
740 	ret = afs_decode_status(call, &bp, &vnode->status, vnode,
741 				&call->expected_version, NULL);
742 	if (ret < 0)
743 		return ret;
744 	xdr_decode_AFSCallBack_raw(call, call->reply[3], &bp);
745 	/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
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 *vnode = fc->vnode;
780 	struct afs_call *call;
781 	struct afs_net *net = afs_v2net(vnode);
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->reply[0] = vnode;
808 	call->reply[1] = newfid;
809 	call->reply[2] = newstatus;
810 	call->reply[3] = 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(vnode->fid.vid);
818 	*bp++ = htonl(vnode->fid.vnode);
819 	*bp++ = htonl(vnode->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(vnode->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, &vnode->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 file status and volume
843  * sync.
844  */
845 static int afs_deliver_fs_status_and_vol(struct afs_call *call)
846 {
847 	struct afs_vnode *vnode = call->reply[0];
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, &vnode->status, vnode,
860 				&call->expected_version, NULL);
861 	if (ret < 0)
862 		return ret;
863 	/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
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_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_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->reply[0] = dvnode;
915 	call->reply[1] = 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->reply[0], *vnode = call->reply[1];
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->reply[X]); */
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->reply[0] = dvnode;
1006 	call->reply[1] = 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 *vnode = call->reply[0];
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->reply[1]);
1051 	ret = afs_decode_status(call, &bp, call->reply[2], NULL, NULL, NULL);
1052 	if (ret < 0)
1053 		return ret;
1054 	ret = afs_decode_status(call, &bp, &vnode->status, vnode,
1055 				&call->expected_version, NULL);
1056 	if (ret < 0)
1057 		return ret;
1058 	/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
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 *vnode = fc->vnode;
1085 	struct afs_call *call;
1086 	struct afs_net *net = afs_v2net(vnode);
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->reply[0] = vnode;
1111 	call->reply[1] = newfid;
1112 	call->reply[2] = 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(vnode->fid.vid);
1119 	*bp++ = htonl(vnode->fid.vnode);
1120 	*bp++ = htonl(vnode->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(vnode->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, &vnode->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->reply[0], *new_dvnode = call->reply[1];
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->reply[X]); */
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->reply[0] = orig_dvnode;
1233 	call->reply[1] = 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->reply[0];
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->reply[X]); */
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->reply[0] = 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->reply[0] = 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->reply[0];
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->reply[X]); */
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->reply[0] = 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->reply[0] = 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->reply[0] = 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->reply[1]);
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_begin(call, call->reply[2], 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->reply[2];
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_begin(call, call->reply[2], 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->reply[2];
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_begin(call, call->reply[2], 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->reply[2];
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  * destroy an FS.GetVolumeStatus call
1771  */
1772 static void afs_get_volume_status_call_destructor(struct afs_call *call)
1773 {
1774 	kfree(call->reply[2]);
1775 	call->reply[2] = NULL;
1776 	afs_flat_call_destructor(call);
1777 }
1778 
1779 /*
1780  * FS.GetVolumeStatus operation type
1781  */
1782 static const struct afs_call_type afs_RXFSGetVolumeStatus = {
1783 	.name		= "FS.GetVolumeStatus",
1784 	.op		= afs_FS_GetVolumeStatus,
1785 	.deliver	= afs_deliver_fs_get_volume_status,
1786 	.destructor	= afs_get_volume_status_call_destructor,
1787 };
1788 
1789 /*
1790  * fetch the status of a volume
1791  */
1792 int afs_fs_get_volume_status(struct afs_fs_cursor *fc,
1793 			     struct afs_volume_status *vs)
1794 {
1795 	struct afs_vnode *vnode = fc->vnode;
1796 	struct afs_call *call;
1797 	struct afs_net *net = afs_v2net(vnode);
1798 	__be32 *bp;
1799 	void *tmpbuf;
1800 
1801 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1802 		return yfs_fs_get_volume_status(fc, vs);
1803 
1804 	_enter("");
1805 
1806 	tmpbuf = kmalloc(AFSOPAQUEMAX, GFP_KERNEL);
1807 	if (!tmpbuf)
1808 		return -ENOMEM;
1809 
1810 	call = afs_alloc_flat_call(net, &afs_RXFSGetVolumeStatus, 2 * 4, 12 * 4);
1811 	if (!call) {
1812 		kfree(tmpbuf);
1813 		return -ENOMEM;
1814 	}
1815 
1816 	call->key = fc->key;
1817 	call->reply[0] = vnode;
1818 	call->reply[1] = vs;
1819 	call->reply[2] = tmpbuf;
1820 
1821 	/* marshall the parameters */
1822 	bp = call->request;
1823 	bp[0] = htonl(FSGETVOLUMESTATUS);
1824 	bp[1] = htonl(vnode->fid.vid);
1825 
1826 	afs_use_fs_server(call, fc->cbi);
1827 	trace_afs_make_fs_call(call, &vnode->fid);
1828 	afs_set_fc_call(call, fc);
1829 	afs_make_call(&fc->ac, call, GFP_NOFS);
1830 	return afs_wait_for_call_to_complete(call, &fc->ac);
1831 }
1832 
1833 /*
1834  * deliver reply data to an FS.SetLock, FS.ExtendLock or FS.ReleaseLock
1835  */
1836 static int afs_deliver_fs_xxxx_lock(struct afs_call *call)
1837 {
1838 	const __be32 *bp;
1839 	int ret;
1840 
1841 	_enter("{%u}", call->unmarshall);
1842 
1843 	ret = afs_transfer_reply(call);
1844 	if (ret < 0)
1845 		return ret;
1846 
1847 	/* unmarshall the reply once we've received all of it */
1848 	bp = call->buffer;
1849 	/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
1850 
1851 	_leave(" = 0 [done]");
1852 	return 0;
1853 }
1854 
1855 /*
1856  * FS.SetLock operation type
1857  */
1858 static const struct afs_call_type afs_RXFSSetLock = {
1859 	.name		= "FS.SetLock",
1860 	.op		= afs_FS_SetLock,
1861 	.deliver	= afs_deliver_fs_xxxx_lock,
1862 	.done		= afs_lock_op_done,
1863 	.destructor	= afs_flat_call_destructor,
1864 };
1865 
1866 /*
1867  * FS.ExtendLock operation type
1868  */
1869 static const struct afs_call_type afs_RXFSExtendLock = {
1870 	.name		= "FS.ExtendLock",
1871 	.op		= afs_FS_ExtendLock,
1872 	.deliver	= afs_deliver_fs_xxxx_lock,
1873 	.done		= afs_lock_op_done,
1874 	.destructor	= afs_flat_call_destructor,
1875 };
1876 
1877 /*
1878  * FS.ReleaseLock operation type
1879  */
1880 static const struct afs_call_type afs_RXFSReleaseLock = {
1881 	.name		= "FS.ReleaseLock",
1882 	.op		= afs_FS_ReleaseLock,
1883 	.deliver	= afs_deliver_fs_xxxx_lock,
1884 	.destructor	= afs_flat_call_destructor,
1885 };
1886 
1887 /*
1888  * Set a lock on a file
1889  */
1890 int afs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type)
1891 {
1892 	struct afs_vnode *vnode = fc->vnode;
1893 	struct afs_call *call;
1894 	struct afs_net *net = afs_v2net(vnode);
1895 	__be32 *bp;
1896 
1897 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1898 		return yfs_fs_set_lock(fc, type);
1899 
1900 	_enter("");
1901 
1902 	call = afs_alloc_flat_call(net, &afs_RXFSSetLock, 5 * 4, 6 * 4);
1903 	if (!call)
1904 		return -ENOMEM;
1905 
1906 	call->key = fc->key;
1907 	call->reply[0] = vnode;
1908 	call->want_reply_time = true;
1909 
1910 	/* marshall the parameters */
1911 	bp = call->request;
1912 	*bp++ = htonl(FSSETLOCK);
1913 	*bp++ = htonl(vnode->fid.vid);
1914 	*bp++ = htonl(vnode->fid.vnode);
1915 	*bp++ = htonl(vnode->fid.unique);
1916 	*bp++ = htonl(type);
1917 
1918 	afs_use_fs_server(call, fc->cbi);
1919 	trace_afs_make_fs_calli(call, &vnode->fid, type);
1920 	afs_set_fc_call(call, fc);
1921 	afs_make_call(&fc->ac, call, GFP_NOFS);
1922 	return afs_wait_for_call_to_complete(call, &fc->ac);
1923 }
1924 
1925 /*
1926  * extend a lock on a file
1927  */
1928 int afs_fs_extend_lock(struct afs_fs_cursor *fc)
1929 {
1930 	struct afs_vnode *vnode = fc->vnode;
1931 	struct afs_call *call;
1932 	struct afs_net *net = afs_v2net(vnode);
1933 	__be32 *bp;
1934 
1935 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1936 		return yfs_fs_extend_lock(fc);
1937 
1938 	_enter("");
1939 
1940 	call = afs_alloc_flat_call(net, &afs_RXFSExtendLock, 4 * 4, 6 * 4);
1941 	if (!call)
1942 		return -ENOMEM;
1943 
1944 	call->key = fc->key;
1945 	call->reply[0] = vnode;
1946 	call->want_reply_time = true;
1947 
1948 	/* marshall the parameters */
1949 	bp = call->request;
1950 	*bp++ = htonl(FSEXTENDLOCK);
1951 	*bp++ = htonl(vnode->fid.vid);
1952 	*bp++ = htonl(vnode->fid.vnode);
1953 	*bp++ = htonl(vnode->fid.unique);
1954 
1955 	afs_use_fs_server(call, fc->cbi);
1956 	trace_afs_make_fs_call(call, &vnode->fid);
1957 	afs_set_fc_call(call, fc);
1958 	afs_make_call(&fc->ac, call, GFP_NOFS);
1959 	return afs_wait_for_call_to_complete(call, &fc->ac);
1960 }
1961 
1962 /*
1963  * release a lock on a file
1964  */
1965 int afs_fs_release_lock(struct afs_fs_cursor *fc)
1966 {
1967 	struct afs_vnode *vnode = fc->vnode;
1968 	struct afs_call *call;
1969 	struct afs_net *net = afs_v2net(vnode);
1970 	__be32 *bp;
1971 
1972 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1973 		return yfs_fs_release_lock(fc);
1974 
1975 	_enter("");
1976 
1977 	call = afs_alloc_flat_call(net, &afs_RXFSReleaseLock, 4 * 4, 6 * 4);
1978 	if (!call)
1979 		return -ENOMEM;
1980 
1981 	call->key = fc->key;
1982 	call->reply[0] = vnode;
1983 
1984 	/* marshall the parameters */
1985 	bp = call->request;
1986 	*bp++ = htonl(FSRELEASELOCK);
1987 	*bp++ = htonl(vnode->fid.vid);
1988 	*bp++ = htonl(vnode->fid.vnode);
1989 	*bp++ = htonl(vnode->fid.unique);
1990 
1991 	afs_use_fs_server(call, fc->cbi);
1992 	trace_afs_make_fs_call(call, &vnode->fid);
1993 	afs_set_fc_call(call, fc);
1994 	afs_make_call(&fc->ac, call, GFP_NOFS);
1995 	return afs_wait_for_call_to_complete(call, &fc->ac);
1996 }
1997 
1998 /*
1999  * Deliver reply data to an FS.GiveUpAllCallBacks operation.
2000  */
2001 static int afs_deliver_fs_give_up_all_callbacks(struct afs_call *call)
2002 {
2003 	return afs_transfer_reply(call);
2004 }
2005 
2006 /*
2007  * FS.GiveUpAllCallBacks operation type
2008  */
2009 static const struct afs_call_type afs_RXFSGiveUpAllCallBacks = {
2010 	.name		= "FS.GiveUpAllCallBacks",
2011 	.op		= afs_FS_GiveUpAllCallBacks,
2012 	.deliver	= afs_deliver_fs_give_up_all_callbacks,
2013 	.destructor	= afs_flat_call_destructor,
2014 };
2015 
2016 /*
2017  * Flush all the callbacks we have on a server.
2018  */
2019 int afs_fs_give_up_all_callbacks(struct afs_net *net,
2020 				 struct afs_server *server,
2021 				 struct afs_addr_cursor *ac,
2022 				 struct key *key)
2023 {
2024 	struct afs_call *call;
2025 	__be32 *bp;
2026 
2027 	_enter("");
2028 
2029 	call = afs_alloc_flat_call(net, &afs_RXFSGiveUpAllCallBacks, 1 * 4, 0);
2030 	if (!call)
2031 		return -ENOMEM;
2032 
2033 	call->key = key;
2034 
2035 	/* marshall the parameters */
2036 	bp = call->request;
2037 	*bp++ = htonl(FSGIVEUPALLCALLBACKS);
2038 
2039 	/* Can't take a ref on server */
2040 	afs_make_call(ac, call, GFP_NOFS);
2041 	return afs_wait_for_call_to_complete(call, ac);
2042 }
2043 
2044 /*
2045  * Deliver reply data to an FS.GetCapabilities operation.
2046  */
2047 static int afs_deliver_fs_get_capabilities(struct afs_call *call)
2048 {
2049 	u32 count;
2050 	int ret;
2051 
2052 	_enter("{%u,%zu}", call->unmarshall, iov_iter_count(&call->iter));
2053 
2054 	switch (call->unmarshall) {
2055 	case 0:
2056 		afs_extract_to_tmp(call);
2057 		call->unmarshall++;
2058 
2059 		/* Fall through - and extract the capabilities word count */
2060 	case 1:
2061 		ret = afs_extract_data(call, true);
2062 		if (ret < 0)
2063 			return ret;
2064 
2065 		count = ntohl(call->tmp);
2066 
2067 		call->count = count;
2068 		call->count2 = count;
2069 		iov_iter_discard(&call->iter, READ, count * sizeof(__be32));
2070 		call->unmarshall++;
2071 
2072 		/* Fall through - and extract capabilities words */
2073 	case 2:
2074 		ret = afs_extract_data(call, false);
2075 		if (ret < 0)
2076 			return ret;
2077 
2078 		/* TODO: Examine capabilities */
2079 
2080 		call->unmarshall++;
2081 		break;
2082 	}
2083 
2084 	_leave(" = 0 [done]");
2085 	return 0;
2086 }
2087 
2088 static void afs_destroy_fs_get_capabilities(struct afs_call *call)
2089 {
2090 	struct afs_server *server = call->reply[0];
2091 
2092 	afs_put_server(call->net, server);
2093 	afs_flat_call_destructor(call);
2094 }
2095 
2096 /*
2097  * FS.GetCapabilities operation type
2098  */
2099 static const struct afs_call_type afs_RXFSGetCapabilities = {
2100 	.name		= "FS.GetCapabilities",
2101 	.op		= afs_FS_GetCapabilities,
2102 	.deliver	= afs_deliver_fs_get_capabilities,
2103 	.done		= afs_fileserver_probe_result,
2104 	.destructor	= afs_destroy_fs_get_capabilities,
2105 };
2106 
2107 /*
2108  * Probe a fileserver for the capabilities that it supports.  This can
2109  * return up to 196 words.
2110  */
2111 struct afs_call *afs_fs_get_capabilities(struct afs_net *net,
2112 					 struct afs_server *server,
2113 					 struct afs_addr_cursor *ac,
2114 					 struct key *key,
2115 					 unsigned int server_index)
2116 {
2117 	struct afs_call *call;
2118 	__be32 *bp;
2119 
2120 	_enter("");
2121 
2122 	call = afs_alloc_flat_call(net, &afs_RXFSGetCapabilities, 1 * 4, 16 * 4);
2123 	if (!call)
2124 		return ERR_PTR(-ENOMEM);
2125 
2126 	call->key = key;
2127 	call->reply[0] = afs_get_server(server);
2128 	call->reply[1] = (void *)(long)server_index;
2129 	call->upgrade = true;
2130 	call->want_reply_time = true;
2131 	call->async = true;
2132 	call->max_lifespan = AFS_PROBE_MAX_LIFESPAN;
2133 
2134 	/* marshall the parameters */
2135 	bp = call->request;
2136 	*bp++ = htonl(FSGETCAPABILITIES);
2137 
2138 	/* Can't take a ref on server */
2139 	trace_afs_make_fs_call(call, NULL);
2140 	afs_make_call(ac, call, GFP_NOFS);
2141 	return call;
2142 }
2143 
2144 /*
2145  * Deliver reply data to an FS.FetchStatus with no vnode.
2146  */
2147 static int afs_deliver_fs_fetch_status(struct afs_call *call)
2148 {
2149 	struct afs_file_status *status = call->reply[1];
2150 	struct afs_callback *callback = call->reply[2];
2151 	struct afs_volsync *volsync = call->reply[3];
2152 	struct afs_fid *fid = call->reply[0];
2153 	const __be32 *bp;
2154 	int ret;
2155 
2156 	ret = afs_transfer_reply(call);
2157 	if (ret < 0)
2158 		return ret;
2159 
2160 	_enter("{%llx:%llu}", fid->vid, fid->vnode);
2161 
2162 	/* unmarshall the reply once we've received all of it */
2163 	bp = call->buffer;
2164 	ret = afs_decode_status(call, &bp, status, NULL,
2165 				&call->expected_version, NULL);
2166 	if (ret < 0)
2167 		return ret;
2168 	xdr_decode_AFSCallBack_raw(call, callback, &bp);
2169 	xdr_decode_AFSVolSync(&bp, volsync);
2170 
2171 	_leave(" = 0 [done]");
2172 	return 0;
2173 }
2174 
2175 /*
2176  * FS.FetchStatus operation type
2177  */
2178 static const struct afs_call_type afs_RXFSFetchStatus = {
2179 	.name		= "FS.FetchStatus",
2180 	.op		= afs_FS_FetchStatus,
2181 	.deliver	= afs_deliver_fs_fetch_status,
2182 	.destructor	= afs_flat_call_destructor,
2183 };
2184 
2185 /*
2186  * Fetch the status information for a fid without needing a vnode handle.
2187  */
2188 int afs_fs_fetch_status(struct afs_fs_cursor *fc,
2189 			struct afs_net *net,
2190 			struct afs_fid *fid,
2191 			struct afs_file_status *status,
2192 			struct afs_callback *callback,
2193 			struct afs_volsync *volsync)
2194 {
2195 	struct afs_call *call;
2196 	__be32 *bp;
2197 
2198 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
2199 		return yfs_fs_fetch_status(fc, net, fid, status, callback, volsync);
2200 
2201 	_enter(",%x,{%llx:%llu},,",
2202 	       key_serial(fc->key), fid->vid, fid->vnode);
2203 
2204 	call = afs_alloc_flat_call(net, &afs_RXFSFetchStatus, 16, (21 + 3 + 6) * 4);
2205 	if (!call) {
2206 		fc->ac.error = -ENOMEM;
2207 		return -ENOMEM;
2208 	}
2209 
2210 	call->key = fc->key;
2211 	call->reply[0] = fid;
2212 	call->reply[1] = status;
2213 	call->reply[2] = callback;
2214 	call->reply[3] = volsync;
2215 	call->expected_version = 1; /* vnode->status.data_version */
2216 	call->want_reply_time = true;
2217 
2218 	/* marshall the parameters */
2219 	bp = call->request;
2220 	bp[0] = htonl(FSFETCHSTATUS);
2221 	bp[1] = htonl(fid->vid);
2222 	bp[2] = htonl(fid->vnode);
2223 	bp[3] = htonl(fid->unique);
2224 
2225 	call->cb_break = fc->cb_break;
2226 	afs_use_fs_server(call, fc->cbi);
2227 	trace_afs_make_fs_call(call, fid);
2228 	afs_set_fc_call(call, fc);
2229 	afs_make_call(&fc->ac, call, GFP_NOFS);
2230 	return afs_wait_for_call_to_complete(call, &fc->ac);
2231 }
2232 
2233 /*
2234  * Deliver reply data to an FS.InlineBulkStatus call
2235  */
2236 static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
2237 {
2238 	struct afs_file_status *statuses;
2239 	struct afs_callback *callbacks;
2240 	struct afs_vnode *vnode = call->reply[0];
2241 	const __be32 *bp;
2242 	u32 tmp;
2243 	int ret;
2244 
2245 	_enter("{%u}", call->unmarshall);
2246 
2247 	switch (call->unmarshall) {
2248 	case 0:
2249 		afs_extract_to_tmp(call);
2250 		call->unmarshall++;
2251 
2252 		/* Extract the file status count and array in two steps */
2253 		/* Fall through */
2254 	case 1:
2255 		_debug("extract status count");
2256 		ret = afs_extract_data(call, true);
2257 		if (ret < 0)
2258 			return ret;
2259 
2260 		tmp = ntohl(call->tmp);
2261 		_debug("status count: %u/%u", tmp, call->count2);
2262 		if (tmp != call->count2)
2263 			return afs_protocol_error(call, -EBADMSG,
2264 						  afs_eproto_ibulkst_count);
2265 
2266 		call->count = 0;
2267 		call->unmarshall++;
2268 	more_counts:
2269 		afs_extract_to_buf(call, 21 * sizeof(__be32));
2270 
2271 		/* Fall through */
2272 	case 2:
2273 		_debug("extract status array %u", call->count);
2274 		ret = afs_extract_data(call, true);
2275 		if (ret < 0)
2276 			return ret;
2277 
2278 		bp = call->buffer;
2279 		statuses = call->reply[1];
2280 		ret = afs_decode_status(call, &bp, &statuses[call->count],
2281 					call->count == 0 ? vnode : NULL,
2282 					NULL, NULL);
2283 		if (ret < 0)
2284 			return ret;
2285 
2286 		call->count++;
2287 		if (call->count < call->count2)
2288 			goto more_counts;
2289 
2290 		call->count = 0;
2291 		call->unmarshall++;
2292 		afs_extract_to_tmp(call);
2293 
2294 		/* Extract the callback count and array in two steps */
2295 		/* Fall through */
2296 	case 3:
2297 		_debug("extract CB count");
2298 		ret = afs_extract_data(call, true);
2299 		if (ret < 0)
2300 			return ret;
2301 
2302 		tmp = ntohl(call->tmp);
2303 		_debug("CB count: %u", tmp);
2304 		if (tmp != call->count2)
2305 			return afs_protocol_error(call, -EBADMSG,
2306 						  afs_eproto_ibulkst_cb_count);
2307 		call->count = 0;
2308 		call->unmarshall++;
2309 	more_cbs:
2310 		afs_extract_to_buf(call, 3 * sizeof(__be32));
2311 
2312 		/* Fall through */
2313 	case 4:
2314 		_debug("extract CB array");
2315 		ret = afs_extract_data(call, true);
2316 		if (ret < 0)
2317 			return ret;
2318 
2319 		_debug("unmarshall CB array");
2320 		bp = call->buffer;
2321 		callbacks = call->reply[2];
2322 		xdr_decode_AFSCallBack_raw(call, &callbacks[call->count], &bp);
2323 		statuses = call->reply[1];
2324 		if (call->count == 0 && vnode && statuses[0].abort_code == 0)
2325 			xdr_decode_AFSCallBack(call, vnode, &bp);
2326 		call->count++;
2327 		if (call->count < call->count2)
2328 			goto more_cbs;
2329 
2330 		afs_extract_to_buf(call, 6 * sizeof(__be32));
2331 		call->unmarshall++;
2332 
2333 		/* Fall through */
2334 	case 5:
2335 		ret = afs_extract_data(call, false);
2336 		if (ret < 0)
2337 			return ret;
2338 
2339 		bp = call->buffer;
2340 		xdr_decode_AFSVolSync(&bp, call->reply[3]);
2341 
2342 		call->unmarshall++;
2343 
2344 	case 6:
2345 		break;
2346 	}
2347 
2348 	_leave(" = 0 [done]");
2349 	return 0;
2350 }
2351 
2352 /*
2353  * FS.InlineBulkStatus operation type
2354  */
2355 static const struct afs_call_type afs_RXFSInlineBulkStatus = {
2356 	.name		= "FS.InlineBulkStatus",
2357 	.op		= afs_FS_InlineBulkStatus,
2358 	.deliver	= afs_deliver_fs_inline_bulk_status,
2359 	.destructor	= afs_flat_call_destructor,
2360 };
2361 
2362 /*
2363  * Fetch the status information for up to 50 files
2364  */
2365 int afs_fs_inline_bulk_status(struct afs_fs_cursor *fc,
2366 			      struct afs_net *net,
2367 			      struct afs_fid *fids,
2368 			      struct afs_file_status *statuses,
2369 			      struct afs_callback *callbacks,
2370 			      unsigned int nr_fids,
2371 			      struct afs_volsync *volsync)
2372 {
2373 	struct afs_call *call;
2374 	__be32 *bp;
2375 	int i;
2376 
2377 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
2378 		return yfs_fs_inline_bulk_status(fc, net, fids, statuses, callbacks,
2379 						 nr_fids, volsync);
2380 
2381 	_enter(",%x,{%llx:%llu},%u",
2382 	       key_serial(fc->key), fids[0].vid, fids[1].vnode, nr_fids);
2383 
2384 	call = afs_alloc_flat_call(net, &afs_RXFSInlineBulkStatus,
2385 				   (2 + nr_fids * 3) * 4,
2386 				   21 * 4);
2387 	if (!call) {
2388 		fc->ac.error = -ENOMEM;
2389 		return -ENOMEM;
2390 	}
2391 
2392 	call->key = fc->key;
2393 	call->reply[0] = NULL; /* vnode for fid[0] */
2394 	call->reply[1] = statuses;
2395 	call->reply[2] = callbacks;
2396 	call->reply[3] = volsync;
2397 	call->count2 = nr_fids;
2398 	call->want_reply_time = true;
2399 
2400 	/* marshall the parameters */
2401 	bp = call->request;
2402 	*bp++ = htonl(FSINLINEBULKSTATUS);
2403 	*bp++ = htonl(nr_fids);
2404 	for (i = 0; i < nr_fids; i++) {
2405 		*bp++ = htonl(fids[i].vid);
2406 		*bp++ = htonl(fids[i].vnode);
2407 		*bp++ = htonl(fids[i].unique);
2408 	}
2409 
2410 	call->cb_break = fc->cb_break;
2411 	afs_use_fs_server(call, fc->cbi);
2412 	trace_afs_make_fs_call(call, &fids[0]);
2413 	afs_set_fc_call(call, fc);
2414 	afs_make_call(&fc->ac, call, GFP_NOFS);
2415 	return afs_wait_for_call_to_complete(call, &fc->ac);
2416 }
2417 
2418 /*
2419  * deliver reply data to an FS.FetchACL
2420  */
2421 static int afs_deliver_fs_fetch_acl(struct afs_call *call)
2422 {
2423 	struct afs_vnode *vnode = call->reply[1];
2424 	struct afs_acl *acl;
2425 	const __be32 *bp;
2426 	unsigned int size;
2427 	int ret;
2428 
2429 	_enter("{%u}", call->unmarshall);
2430 
2431 	switch (call->unmarshall) {
2432 	case 0:
2433 		afs_extract_to_tmp(call);
2434 		call->unmarshall++;
2435 
2436 		/* extract the returned data length */
2437 	case 1:
2438 		ret = afs_extract_data(call, true);
2439 		if (ret < 0)
2440 			return ret;
2441 
2442 		size = call->count2 = ntohl(call->tmp);
2443 		size = round_up(size, 4);
2444 
2445 		acl = kmalloc(struct_size(acl, data, size), GFP_KERNEL);
2446 		if (!acl)
2447 			return -ENOMEM;
2448 		call->reply[0] = acl;
2449 		acl->size = call->count2;
2450 		afs_extract_begin(call, acl->data, size);
2451 		call->unmarshall++;
2452 
2453 		/* extract the returned data */
2454 	case 2:
2455 		ret = afs_extract_data(call, true);
2456 		if (ret < 0)
2457 			return ret;
2458 
2459 		afs_extract_to_buf(call, (21 + 6) * 4);
2460 		call->unmarshall++;
2461 
2462 		/* extract the metadata */
2463 	case 3:
2464 		ret = afs_extract_data(call, false);
2465 		if (ret < 0)
2466 			return ret;
2467 
2468 		bp = call->buffer;
2469 		ret = afs_decode_status(call, &bp, &vnode->status, vnode,
2470 					&vnode->status.data_version, NULL);
2471 		if (ret < 0)
2472 			return ret;
2473 		xdr_decode_AFSVolSync(&bp, call->reply[2]);
2474 
2475 		call->unmarshall++;
2476 
2477 	case 4:
2478 		break;
2479 	}
2480 
2481 	_leave(" = 0 [done]");
2482 	return 0;
2483 }
2484 
2485 static void afs_destroy_fs_fetch_acl(struct afs_call *call)
2486 {
2487 	kfree(call->reply[0]);
2488 	afs_flat_call_destructor(call);
2489 }
2490 
2491 /*
2492  * FS.FetchACL operation type
2493  */
2494 static const struct afs_call_type afs_RXFSFetchACL = {
2495 	.name		= "FS.FetchACL",
2496 	.op		= afs_FS_FetchACL,
2497 	.deliver	= afs_deliver_fs_fetch_acl,
2498 	.destructor	= afs_destroy_fs_fetch_acl,
2499 };
2500 
2501 /*
2502  * Fetch the ACL for a file.
2503  */
2504 struct afs_acl *afs_fs_fetch_acl(struct afs_fs_cursor *fc)
2505 {
2506 	struct afs_vnode *vnode = fc->vnode;
2507 	struct afs_call *call;
2508 	struct afs_net *net = afs_v2net(vnode);
2509 	__be32 *bp;
2510 
2511 	_enter(",%x,{%llx:%llu},,",
2512 	       key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
2513 
2514 	call = afs_alloc_flat_call(net, &afs_RXFSFetchACL, 16, (21 + 6) * 4);
2515 	if (!call) {
2516 		fc->ac.error = -ENOMEM;
2517 		return ERR_PTR(-ENOMEM);
2518 	}
2519 
2520 	call->key = fc->key;
2521 	call->reply[0] = NULL;
2522 	call->reply[1] = vnode;
2523 	call->reply[2] = NULL; /* volsync */
2524 	call->ret_reply0 = true;
2525 
2526 	/* marshall the parameters */
2527 	bp = call->request;
2528 	bp[0] = htonl(FSFETCHACL);
2529 	bp[1] = htonl(vnode->fid.vid);
2530 	bp[2] = htonl(vnode->fid.vnode);
2531 	bp[3] = htonl(vnode->fid.unique);
2532 
2533 	call->cb_break = fc->cb_break;
2534 	afs_use_fs_server(call, fc->cbi);
2535 	trace_afs_make_fs_call(call, &vnode->fid);
2536 	afs_make_call(&fc->ac, call, GFP_KERNEL);
2537 	return (struct afs_acl *)afs_wait_for_call_to_complete(call, &fc->ac);
2538 }
2539 
2540 /*
2541  * FS.StoreACL operation type
2542  */
2543 static const struct afs_call_type afs_RXFSStoreACL = {
2544 	.name		= "FS.StoreACL",
2545 	.op		= afs_FS_StoreACL,
2546 	.deliver	= afs_deliver_fs_status_and_vol,
2547 	.destructor	= afs_flat_call_destructor,
2548 };
2549 
2550 /*
2551  * Fetch the ACL for a file.
2552  */
2553 int afs_fs_store_acl(struct afs_fs_cursor *fc, const struct afs_acl *acl)
2554 {
2555 	struct afs_vnode *vnode = fc->vnode;
2556 	struct afs_call *call;
2557 	struct afs_net *net = afs_v2net(vnode);
2558 	size_t size;
2559 	__be32 *bp;
2560 
2561 	_enter(",%x,{%llx:%llu},,",
2562 	       key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
2563 
2564 	size = round_up(acl->size, 4);
2565 	call = afs_alloc_flat_call(net, &afs_RXFSStoreACL,
2566 				   5 * 4 + size, (21 + 6) * 4);
2567 	if (!call) {
2568 		fc->ac.error = -ENOMEM;
2569 		return -ENOMEM;
2570 	}
2571 
2572 	call->key = fc->key;
2573 	call->reply[0] = vnode;
2574 	call->reply[2] = NULL; /* volsync */
2575 
2576 	/* marshall the parameters */
2577 	bp = call->request;
2578 	bp[0] = htonl(FSSTOREACL);
2579 	bp[1] = htonl(vnode->fid.vid);
2580 	bp[2] = htonl(vnode->fid.vnode);
2581 	bp[3] = htonl(vnode->fid.unique);
2582 	bp[4] = htonl(acl->size);
2583 	memcpy(&bp[5], acl->data, acl->size);
2584 	if (acl->size != size)
2585 		memset((void *)&bp[5] + acl->size, 0, size - acl->size);
2586 
2587 	trace_afs_make_fs_call(call, &vnode->fid);
2588 	afs_make_call(&fc->ac, call, GFP_KERNEL);
2589 	return afs_wait_for_call_to_complete(call, &fc->ac);
2590 }
2591